-
-
Notifications
You must be signed in to change notification settings - Fork 931
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
Add CORS feature to support AJAX use of password grant flow #171
Comments
Have you thought about using the Implicit Flow instead of the Password Grant Type. This'll be a much cleaner implementation. https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2#grant-type:-implicit |
Yes I did give implicit flow a thought but the line "it does not support refresh token" does not meet my requirements. I guess my thought stems more from the point of view that one would configure the allowable CORS origins and then only respond with a CORS ACAO header for the client requests send from that origin. I think almost all of the Auth SaaS solutions out there today do that sort of magic. |
You can configure your /authorize Endpoint that it does the redirect directly without comfirmimg if the user allready did once. |
I think CORS is probably out of scope of this module, as @maennchen say's you should be able to do this using existing plugins? |
If you run a multi tenanted OAuth server and you want to configure your client registration to only send CORS headers when they come from a specific URL location then you have no way of adding CORS headers during the Auth request as you never have access to the client registration, request and response objects in a single place. Maybe another option would be to have a callback handler pattern in the OAuth server that will be consulted while processing the client requests. One could register any odd callbacks in there and when the callbacks are called, the OAuth server will pass in the client registration (the object it gets from the model) and the http request and response. This way one could write any type of plugins like some custom CORS handler with all the information about the client and request etc. in one place. Just a thought. @maennchen, the |
General overrides has actually been spec'd here: https://github.com/thomseddon/node-oauth2-server/issues/115 |
Closing on no activity - please reopen if needed :) |
Hi there,
I am using the password grant flow via an ajax call where the requesting app is not running on the same domain as the OAuth server. Without CORS headers, the oauth password grant flow from a web client posting to the oauth server does not work. I did see some people just globally adding the CORS headers in the oauth server middleware or the fronting apache proxy, e.g.
Making CORS part of the client configuration will enable a per client configuration. The only thing that needs to be added is a configuration property to the client like
client.addCorsHeader
and for the actual header to be returned one could use theclient.redirectUri
parameter on the client. If theaddCorsHeader
property is enabled, simply strip off the path from the client redirectUri and return this in theAccess-Control-Allow-Origin
header with the response.Et voila the OAuth server would now support CORS multiple different oauth clients that call from different domains using the password grant.
Does that work as a proposal and more importantly would this be a valid use case?
Cheers, Niels
Detailed use case:
OAuth server running on
https://oauth.fancydomain.com
Client App running on
https://myclient.com
Client App client is configured like:
OAuth server and Client App are from the same developer and the Client App only wants to post following to get an access token for use of some other backend API that is a protected resource server:
The response the client is after will look something like this:
The text was updated successfully, but these errors were encountered: