OWIN OpenIdConnect middleware - set RedirectUri dynamically

偶尔善良 提交于 2019-12-09 17:01:02

问题


Is there any way how can I set RedirectUri property for OpenIdConnectMessage based on a Request scope, not Application scope?

My app is serving multiple domains (myapp.com, myapp.fr, ..) and based on domain, it determine default language for the content. I need that the user is taken back to the same domain after login thru IdP so I need to find a way how RedirectUri is set per request scope rather than app scope as done by configuring middleware options in startup.cs .


回答1:


This can be done via Notification event RedirectToIdentityProvider . Something like this:

 Notifications = new OpenIdConnectAuthenticationNotifications
                 {
                     RedirectToIdentityProvider = async n =>
                     {
                         n.ProtocolMessage.RedirectUri = n.OwinContext.Request.Uri.Host;
                         n.ProtocolMessage.PostLogoutRedirectUri = n.OwinContext.Request.Uri.Host;
                     },
                     //other notification events...
                 }

`



来源:https://stackoverflow.com/questions/30645178/owin-openidconnect-middleware-set-redirecturi-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!