Yas*_*sir 22 c# azure azure-active-directory
我在Azure Active Directory网站配置回复URL中指定了两个URL.一个在我运行本地代码时重定向到我的localhost环境,一个在我运行prod网站时重定向到我的Azure托管网站.但Azure Active目录似乎忽略了该设置.它只使用一个或另一个URL,但不能同时使用两者.我看到了描述问题的链接和可能的解决方案,但它对我不起作用.链接是:
http://samritchie.net/2013/07/17/azure-ad-single-sign-on-with-multiple-environments-reply-urls/
如何设置Azure Active Directory以重定向到适当的环境?
ast*_*kov 24
您没有提供有关您的实施的详细信息,但这是针对任何情况的解决方案.
您可能正在使用WIF配置 - 这完全是您的web.cofing中的配置,或者您可能正在使用OWIN,其中配置位于Config.Auth.cs文件中.无论哪种方式,Azure AD的STS将仅使用默认回复URI,无论呼叫来自何处.您必须显式设置ReplyUrl以指示Azure AD将用户返回到其中一个已注册的回复URL.
WIF解决方案
使用WIF时,您的Web配置包含以下部分:
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="true" />
<wsFederation passiveRedirectEnabled="true"
issuer="https://login.windows.net/yourtenant.com/wsfed"
realm="https://yourtenant.com/WebSingleTenant"
requireHttps="true" />
</federationConfiguration>
</system.identityModel.services>
Run Code Online (Sandbox Code Playgroud)
这有点不完整!您可以reply向wsFederation标记添加一个指示Azure AD以获取新的回复URL:
<wsFederation passiveRedirectEnabled="true"
issuer="https://login.windows.net/yourtenant.com/wsfed"
realm="https://yourtenant.com/WebSingleTenant"
reply="http://any_registered_url/"
requireHttps="true" />
Run Code Online (Sandbox Code Playgroud)
请注意,此处您只能使用已注册的回复网址.
要修改回复属性,您可以安全地使用web.config转换,就像对所有其他特定于部署的应用程序设置和连接字符串一样.
OWIN解决方案
当您使用OWIN时,您将拥有Startup.Auth.cs文件,或者您的身份验证配置将直接进入您的Startup.cs文件.它看起来像下面这样:
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.
AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri
});
}
Run Code Online (Sandbox Code Playgroud)
请注意OpenIdConnect身份验证的配置设置.您可以添加RedirectUri属性以指示将用户重定向到的位置:
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
RedirectUri = "any_registered_redirect_uri"
});
Run Code Online (Sandbox Code Playgroud)
您可以将RedirectUri分配给Web.Config文件中的设置,您也可以使用Web.Config转换处理该设置.
| 归档时间: |
|
| 查看次数: |
9759 次 |
| 最近记录: |