|
|
|
|
|
by jaypaulynice
3703 days ago
|
|
OAuth2 is the way to go for REST services especially if you plan to let users give other apps/developers access without giving out their passwords. For better security, you want to decouple the authentication server from your web application (2 separate databases at least) The authentication server stores email/username, encrypted password, and roles. To access the web app, you first get a token from the authentication server by exchanging a client_id, secret, username, password and grant type. The token is used whenever you want to make a request to the web app. The authentication server has an endpoint that lets the web app check to see if the token is valid and what roles the client has. The token is only valid for a short time and can be revoked. To know who is making the request, you associate the username/email from the authentication server with a user object on the web application so you can look up based on username/email. It's not worth doing this from scratch as there are plenty of open source implementations out there already like Spring Security Oauth2 and other libraries for Django/python, but they all require some reading to get started. I've used Spring Security Oauth2, but it's not very well documented. I've thought about open sourcing my work, but not sure yet. |
|
I can see the benefit when scaling but starting with this design seems to be a little bit of an overkill / harder to manage? Care to elaborate?
Cheers