-
-
Notifications
You must be signed in to change notification settings - Fork 253
Definition of the redirect_uri endpoint #240
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
Comments
The "normal" way of using lua-resty-openidc is a setup, where the configured It doesn't have to be used that way, though. A setup where redirect URI is not part of the protected URI space is perfectly possible but will only work if all of your blocks have access to the same session - which in general means you need to configure Cookies to use |
You totally understand the architecture I'm trying to achieve! 🌟 I'd like to use a single callback living only on nginx so all my apps don't have to worry about the auth flow at all. And as you noticed, they'll all live under the same domain so cookie sharing was where I wanted to go. (actually they'll live under sub-subdomain so I hope cookie sharing is still possible using the primary domain as Cookie domain) Is it possible to configure a cookie domain with In my Thank you so much for the indications! EDIT : Just saw the |
I happen to know an installation that does something similar to what you are trying to achieve :-) For the configuration of the session cookie you need to look into configuring lua-resty-session - see https://github.com/bungle/lua-resty-session I don't think there is anything special you need to configure apart from that, personally I'd recommend to set |
@bodewig thanks for the advices! I was able to set the domain using local session_opts = { cookie = { domain = ".mydomain.com" } } Do you have any info about this part?
# This should delete the session as token_expired=true and opts.renew_access_token_on_expiry=false
session.present=true, session.data.id_token=true, session.data.authenticated=true, opts.force_reauthorize=nil, opts.renew_access_token_on_expiry=false, try_to_renew=false, token_expired=true |
Sorry, I somehow overlooked the second part of your question. The session duration can be configured independently and you should probably make it match your token's expiration time. lua-resty-openidc does not offer a way to do that automatically. The user would be redirected to the OP if
in your case lua-resty-openidc has an active session and knows the user has authenticated at one point in time and it knows the token has expired. In this case the access is allowed, which seems a little unexpected. /cc @zandbelt |
About the expired access token: that is a common misunderstanding about OpenID Connect. The application session at the OpenID Connect RP is independent of the tokens that it receives. Those tokens are:
In case the access token expires during the lifetime of the session, it may be renewed if needed for calling APIs but it does not impact the application's session lifetime, by design. |
@zandbelt Thank you so much for clearing things up! I'll just play with I learnt so much about openid with this project. You are a wonderful community! 🎆 |
I have one last question about the workflow. 😅 Once the session is validated and the user authenticated, in which form do you forward the user’s infos to the end services? (in my case they're mostly nodejs web apps serving SPA frontends using React) As far as I understand, the encrypted cookie session is only used by lua-resty-openidc to carry the tokens infos and the session state, so reading from it in my end services would not be a good idea (and they would all need the session secret). Also I don't need to encrypt my user infos as there is nothing sensible in it, it's just the basics identity informations plus a set of roles. I was thinking about serializing the userinfo result and put it inside a http header like this : Or maybe I should make a second cookie to carry that information? What do you think? Do you have any recommendations about the “post-validation session” part? I know it's a little off topic but as you both have experience with this workflow I didn't find a better place to ask. Thanks for your help! |
please use the mailing list for this type of questions passing info to the backend is basically up to you; an example can be found in the README.md:
passing the info to the frontend i.e. SPAs is a different topic: you can use response headers for claims/tokens or create a separate endpoint to return that information |
Environment
Hello,
First I'd like to thank you for this very useful library which is a game changer for me in my architecture! 👏
I'm pretty new to Openid so I have a few questions about how
lua-resty-openidc
handles the Authorization flow so I can be sure I'm on the right tracks!The unclear point to me is the
redirect_uri
, I have seen no example of a location block definition of aredirect_uri
endpoint, is that normal? By reading the code I saw that callingrequire("resty.openidc").authenticate(opts)
in such endpoint would be enough tolua-resty-openidc
to take care of the rest (getting the tokens, making the session, and get the userinfo if the option is provided)?I already created my client on Keycloak (named "proxy") with a valid redirect uri (http://auth.mydomain.com/callback)
I intend to use
lua-resty-openidc
in conjonction with nginx to make an authentication proxy to selectively protect my apps in virtualhost blocks, here is a simplified conf that I'd like to set up (I'll probably extract the whole
access_by_lua_block
into its own module as it's always the same block) :I'll gladly add this example in the wiki once I'm sure I'm not making a big mistake somewhere. 😄
My second question is how can I control the session expiration set by
lua-resty-openidc
according to my token expiration?I'd expect the session to be deleted as soon as the access_token is expired, and only renewed if there is a refresh_token and the
renew_access_token_on_expiry
istrue
.I tried setting the
renew_access_token_on_expiry
tofalse
but my page was still accessible even if the session state is :Have a nice day!
The text was updated successfully, but these errors were encountered: