-
Notifications
You must be signed in to change notification settings - Fork 2
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
Blazor OpenID Connect API Token Refresh - Forty Years of Code #42
Comments
We do actually have the issue with users logging in and out as they please with persistent login. So currently, we are running in to the problem that you referred to last in this article. Could you give any hints as to how you implemented the "forced" login/refresh of the tokens when a user reappears on the site after e.g. days? I expect we need some additional logic in the OnGet() function in _HostAuthModel.cs. Thanks! |
@HrDahl Right, add a new handler (specific to refresh, not in https://mcguirev10.com/2018/01/12/persistent-login-with-identityserver.html It's basically the same as long as you route Blazor through pages with |
Thanks for your Blog. Ive some questions about that particular code. |
90% finished, I don't get the point of creating tutorial and not finish it. 'Stale cookies' section has 'tokenResponse' in the code, assuming that when the time for refreshing the token comes, we call the controller which handles refreshing the cookies. |
@MV10 I tried to follow your advice on dealing with stale cookies, but probably did not understand exactly what you meant. |
@anddrzejb You can implement an access token refresh via IdentityModel.AspNetCore, see Id token should be handled with a silent renew as stated here (but didn't solved this myself yet): IdentityModel/IdentityModel.AspNetCore#124 |
@ViRuSTriNiTy I was already using IdentityModel.AspNetCore, but had to temporarily abandon it, because couldn't figure out how to force it to provide role claim through ClientCretentials flow. It is included in the access_token when I obtain it using I tried to follow your suggestion for access token (for starters). There is a lot to unpack for someone like me who is just starting with IdentityServer. Anyway, It seems to me that you are injecting into
Soo...what did I miss? |
@anddrzejb I'm sorry, I pointed you in the wrong direction as my comments in the given links are already deprecated. I removed the
Here is my implementation of
You need to init the user token store by passing the tokens in
My
Finally the
Hope this helps. |
@ViRuSTriNiTy please correct me if I am wrong, but from what I see here, you basically abandoned the solution proposed by the tutorial on refreshing the tokens using Also, I was surprised you suggested using |
@anddrzejb Yeah, my bad, i've read your question not thoroughly enough, instead of "stale cookies" I did pick up "stale tokens". Just forget what I wrote then ^^ |
Thank you for this amazing blog. I got it working using Azure AD, but I have to set "GetClaimsFromUserInfoEndpoint" to false. Otherwise, after a successful login the event "OnRemoteFailure" is fired. I don't know what's wrong there. |
@MV10 Thank you for your great writeup and sample code. Writing a Blazor Server app was all fun and games until I had to implement OIDC with AWS Cognito and your articles have helped me a lot. |
Unfortunately I'm not currently working with either technology and I lack the time to do any follow-up work. I still think they're both great tech and the right direction, but sometimes you go where the paychecks are... |
@MV10 ,Great article and learned a lot about ValidateAuthenticationStateAsync . |
@tmurali I've never heard it said that OIDC was meant to improve scalability (up? out?) -- if asked, I'd say its primary value is standardizing auth flows and providing a separation of concerns. The use of cache definitely contributes to your app's memory profile and needs to be considered along with everything else that goes into profiling the type and number of servers needed by a production system. However, when I was working with this tech, I found the overhead of Blazor itself to have the largest impact on our server scalability assessments. Unfortunately I'm not actively using any of this today thanks to arbitrary decisions by management. |
Thanks again for a prompt response. What I meant by scaling issue is , using cached data we are tying a user to a particular server in a load balanced environment. With OAuth and openID and JWT reference token we are not tied to a server just palm of the token validation to Identity server. But as you mentioned in all your three article feels like Security for Blazor server app is left as a after thought from MS. Hope they will add bit more support in .net6. And sorry to hear you are not using this tech stack anymore. Honestly without this guidance would have struggled with our implementation. |
@tmurali Server Side Blazor + SignalR ties the user to a specific server, too... |
I found this blog post very helpful, but also struggled for a long time with the stale cookies issue. I have a solution to the stale cookies issue that seems to work for us. I've documented it here in case it is useful to others: https://stackoverflow.com/questions/72868249 I would welcome any constructive feedback. Or upvotes! :) |
Blazor OpenID Connect API Token Refresh - Forty Years of Code
Correctly refreshing OIDC access tokens for Blazor server-side apps
https://mcguirev10.com/2019/12/17/blazor-openid-connect-api-token-refresh.html
The text was updated successfully, but these errors were encountered: