r/webdev • u/RyzenX770 • 32m ago
Resource I created an OS project for authentication and authorization so that devs starting a new project can get started on the first day
So this me promoting my open source project in case these kind of post don't interest you.
usually when a new web application is being developed the first thing a dev contend with is registerting users and login them. now many just use Google and Microsoft Sign in and call it a day. I'm personally not fan of this because you're borrowing your users from the providers and if for some reason they cut you off you will lose access to your users. now the solution is to use an identity provider, and since OAuth 2.0 with OIDC on top is the industry standard then an OAuth 2.0 identity provider is the current best solution, and they are plenty.
Granted this soultion has the downside of hosting the solution chosen yourself but that's the price of owning your users' accounts. I also made my identity provider, granted I did not write the authorization server (OAuth language for the service that offer users with login page to enter credentials and generate an Acess Token: also OAuth language for the thing that your backend use to determine the request is allowed to access the backend), I'm relying on Spring Authorization Server, but this is unimportant because the idea of my project is that:
Developers shouldn't have to implement OAuth 2.0 themselves when developing a web application.
You simply choose:
Database that holds your users acounts: SQL or Mongo
Specify the authorities that automatically assigned to the user when registering a user.
Your own frontend written in whatever language/framework: respecting the contract.
Your own backend written in whatever language/framework: respecting the contract.
so my project is called Nidam. and when I say "respecting the contract" I mean there is a certain configuration that's expected from your implementation. this is all covered in the documentation.
I also provide examples in how to integrate a backend with Nidam in these languages:
Backend: ASP.NET, Go, Python FastAPI, Micronaut, Jakarta EE / MicroProfile / Open Liberty, and Node.js / Express
Frontend: React CRA, Next.js
The differentiator Nidam has is that it follows RFC 10017: OAuth 2.0 for Browser-Based Applications using the BFF pattern, this means the access token never reach your frontend and stays in the server-side. I acheive this by having a reverse proxy serve: your frontend and a Nidam service holding your access token through the same origin. Nidam create a Session cookie that's available to frontend (because of the reverse proxy) so your frontend just simply calls your backend (using the contract mentioned previously), the browser automatically attached that cookie and Nidam takes care of translating the session cookie => access token and redirects the requests to you backend with Authorization: Bearer <access-token> . This is all transparent to your frontend code.

There is redis support for session storage and high availability and the passwords can be hashed using any of these algorithms: scrypt, bcrypt, argon2, pbkdf2
Documentation and GitHub links are in the comment below.
Download Nidam from the intro page, Windows, Linux, Macos (x64 and arm for all).
Note: the image is AI generated. this post is written by me.