多个域的 IdentitySever3 重定向 Url
IdentitySever3 Redirect Url for multiple domains
给定
一个 ASP IIS 中的 MVC 网站。该站点使用带有隐式流的身份服务器对用户进行身份验证。
有多个域名分配给它。所以网站是从不同的域调用的。
例如
- foo.com
- foo.de
- foo.fr
问题
现在,当我配置我的网站时,我必须设置重定向 url 但这取决于用户来自哪里。但是由于此配置是在应用程序启动时完成的,因此我无法根据传入的请求做出改变。
推荐的方法是什么?
public static void Configure(IAppBuilder app)
{
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "oidc",
Authority = ConfigurationManager.AppSettings["authority"],
ClientId = "BlsFrontend",
RedirectUri = "http://foo.de", //how to get this dynamically?
ResponseType = "id_token token",
SignInAsAuthenticationType = "Cookies",
Scope = "openid profile",
我正在考虑的一件事是使用 RedirectToIdentityProvider
通知并在请求中采用重定向。我测试了它,它适用于我的情况,但这会是一种 valid/good 方法吗?
RedirectToIdentityProvider = n =>
{
if (!string.IsNullOrWhiteSpace(n.ProtocolMessage.RedirectUri))
{
n.ProtocolMessage.RedirectUri = n.Request.Scheme + "://" + n.Request.Host.ToString(); //How to make it clean !?
}
}
我post这是解决方案,因为我没有找到任何其他解决问题的方法,其他一些人也使用了这个解决方案
解决方案是在我们被重定向到身份服务器之前根据请求设置重定向 url。为此,我使用 RedirectToIdentityProvider 通知
RedirectToIdentityProvider = n =>
{
if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.Authentication &&
!string.IsNullOrWhiteSpace(n.ProtocolMessage.RedirectUri))
{
n.ProtocolMessage.RedirectUri = n.Request.Scheme + "://" + n.Request.Host.ToString(); //How to make it clean !?
}
}
给定
一个 ASP IIS 中的 MVC 网站。该站点使用带有隐式流的身份服务器对用户进行身份验证。
有多个域名分配给它。所以网站是从不同的域调用的。
例如
- foo.com
- foo.de
- foo.fr
问题
现在,当我配置我的网站时,我必须设置重定向 url 但这取决于用户来自哪里。但是由于此配置是在应用程序启动时完成的,因此我无法根据传入的请求做出改变。
推荐的方法是什么?
public static void Configure(IAppBuilder app)
{
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "oidc",
Authority = ConfigurationManager.AppSettings["authority"],
ClientId = "BlsFrontend",
RedirectUri = "http://foo.de", //how to get this dynamically?
ResponseType = "id_token token",
SignInAsAuthenticationType = "Cookies",
Scope = "openid profile",
我正在考虑的一件事是使用 RedirectToIdentityProvider
通知并在请求中采用重定向。我测试了它,它适用于我的情况,但这会是一种 valid/good 方法吗?
RedirectToIdentityProvider = n =>
{
if (!string.IsNullOrWhiteSpace(n.ProtocolMessage.RedirectUri))
{
n.ProtocolMessage.RedirectUri = n.Request.Scheme + "://" + n.Request.Host.ToString(); //How to make it clean !?
}
}
我post这是解决方案,因为我没有找到任何其他解决问题的方法,其他一些人也使用了这个解决方案
解决方案是在我们被重定向到身份服务器之前根据请求设置重定向 url。为此,我使用 RedirectToIdentityProvider 通知
RedirectToIdentityProvider = n =>
{
if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.Authentication &&
!string.IsNullOrWhiteSpace(n.ProtocolMessage.RedirectUri))
{
n.ProtocolMessage.RedirectUri = n.Request.Scheme + "://" + n.Request.Host.ToString(); //How to make it clean !?
}
}