-
-
Notifications
You must be signed in to change notification settings - Fork 932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion on Authentication of users #264
Comments
The entire point of the authentication code grant flow is not to expose the user's credentials to the client application, so naturally I agree with you on that point. Quoting @nunofgs' previous response to my questions:
So the auth code grant flow starts with a request to the Personally I opted for overriding with a custom auth handler (session user id lookup) since I didn't like the concept of issuing double token pairs for every auth code grant, but as I understand it, the two flows remain separate. I'm also not 100% clear on how one would go about distinguishing whether or not to redirect or to show the grant dialog when processing |
Yeah, I just don't see this as a common flow. It also isn't correct to include a The older version required a callback to the authorization method, which was used to validate the user. This seems the most common flow to me. I almost feel like the library should expect that, and return an error if the authenticationHandler isn't present, and allow an additional, settable option to use a password-grant flow as an alternate authentication mechanism. I think this will lead to less confusion overall. Thoughts? |
IMO something like that'd be preferable, but it would be nice to get more input before proceeding with changes. With clear examples (primarily in the wrappers) it shouldn't be too hard to communicate how to bypass the current default. |
Same... Any input? |
Hey guys! Really happy about moving forward on node-oauth2-server, especially the change into an oauthjs org.
I do have this implemented in a production app and I have to say it works great. Obviously I'm biased in this matter but I feel like using OAuth as an authentication solution (even during the authorization code flow) is a great alternative to simply requiring every user to bake in their own login mechanism.
You nailed it. I seem them exactly as two separate flows and the OAuth spec says nothing about how you can authenticate a user during the authorization flow. I also don't see an issue with "double token pairs". In fact, the user will most likely already possess an Authorization token (thus, they are already "logged in"). Even if they don't, when they login you can store that token for the regular password flow (ie: the token will not go to waste)
If I understand you correctly, it's simply a matter of redirecting the user to a /login page if they didn't present an "Authorization" header.
While I agree it's not very common I still believe it is at least useful enough to document as a starting point for any developer wanting a full OAuth-authentication solution.
I do agree that this is not the most common of authentication mechanisms (during authorization code flow) so if you prefer, we can simply remove the default and make the Agreed? |
Yeah, I'm excited. Thanks for moving the express wrapper over there!
You have a point, it makes sense.
I think you're right. Offering a login option will be good for users, I just don't think we want to confuse users in that they have to use our login option.
100%. Let's remove the default, make authenticationHandler a required parameter, and document the option of having the library handle authentication/login. Works for me! |
So, I agree with you on the authenticationHandler, I am trying to get it to work, and I'm running into an issue. I'm using The issue I'm facing is that I already have the user before the authorization request, and I want to pass it directly to the |
I just realized the |
@steffansluis: I solved it by injecting the user ID into the request body right before passing along to my custom authenticateHandler. Here's an example. Edit: This is using a custom wrapper for Koa, but it should essentially be the same. |
@maxtruxa What's your take here? |
I think the use case that the default handler covers is one of the rarer ones, as most OAuth2 servers probably implement user authentication using an existing (session-based) login mechanism. On a related note, making the handler a simple function instead of an object with a |
how do you trigger the right redirect if you have no user to return from the authenticationHandler? It just throws an error. |
@knightcode If you don't have a user at that point something else is wrong and there is no sane way to recover from this condition. @mjsalinger @lfk @nunofgs: I'm going to go ahead and create a PR removing the default handler. Are we sure about keeping the name/signature the same? I still think that a solution similar to what I proposed earlier in this issue (simplifying the signature and possibly moving the handler to the model) would be the cleanest. Sorry for the typos, my phone likes to auto-correct me... |
Stemming off a discussion from PR #203, the question on whether the library should include authentication via the Password grant by default. To me this presents several problems:
From the spec:
(B) The authorization server authenticates the resource owner (via the user-agent) and establishes whether the resource owner grants or denies the client's access request.
This implies that it is done via the user agent as a separate request. If the auth request is unauthenticated, then the library should redirect back to the calling program to retrieve credentials. To assume the password grant in this case is not a safe assumption.
Credentials should not be included in a grant request imo - that's beyond the scope of what the OAuth spec provides for the authorization request.
Unless I'm misunderstanding something. Any thoughts?
/cc:
@nunofgs
@lfk
@thomseddon
@ruimarinho
@night
The text was updated successfully, but these errors were encountered: