簡體   English   中英

更改OWIN RedirectToIdentityProvider通知中的ReturnUrl

[英]Changing ReturnUrl in OWIN RedirectToIdentityProvider notification

當前,我們在產品中重寫WSFederationAuthenticationModule.RedirectToIdentityProvider ,以更改身份驗證后將用戶代理重定向到的returnUrl。

現在我們處於采用OWIN(Katana)中間件而不是HttpModules的過程中。 WsFederationAuthenticationOptionsRedirectToIdentityProvider通知中,我看到WCtx參數現在包含一個WsFedOwinState參數,該參數已使用DPAPI加密。

如何實現RedirectToIdentityProvider操作來更改返回URL? 我是否需要解密WsFedOwinState參數以添加returnUrl查詢參數,還是有其他方法?

在RedirectToIdentityProvider中,您將有權訪問WsFederationMessage。

將Wreply屬性設置為所需的值。

注意:默認情況下使用MachineKey,而不使用DPAPI保護wctx。

就我而言,我更改了SecurityTokenValidated的返回URL,並使從ADFS的重定向始終轉到相同的URL

 public void ConfigureAuth(IAppBuilder app)
{
    app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType);

    app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType });

    app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
    {
        Wtrealm = realm,
        MetadataAddress = adfsMetadata,
        Notifications = new WsFederationAuthenticationNotifications
        {
            SecurityTokenValidated = nx =>
            {
                nx.AuthenticationTicket.Properties.RedirectUri = "/RedirectionGoesHere.aspx";
                return Task.FromResult(0);
            }
        }
    });
    // This makes any middleware defined above this line run before the Authorization rule is applied in web.config
    app.UseStageMarker(PipelineStage.Authenticate);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM