首页 > 解决方案 > ADFS 单点登录不适用于会话状态模式“UserUri”

问题描述

我们的 asp.net 网站在 ADFS SSO 上运行良好,因为我们将会话状态 cookie 设置从“使用 Cookie”更改为“使用 URI”。进行此更改后,以下代码中的 fam.IsSignInResponse(request) 始终为 false,因此它递归地重定向回 ADFS 登录屏幕。

public List<ClaimEntity> GetClaims()
        {
            logger.Info("Started executing GetClaims()");
            List<ClaimEntity> claims = new List<ClaimEntity>();
            // sam is configured in web.config
            var sam = FederatedAuthentication.SessionAuthenticationModule;
            logger.Info("Declaring sam");
            // fam is not
            var fam = new WSFederationAuthenticationModule();
            logger.Info("Declaring fam");
            //fam.FederationConfiguration = FederatedAuthentication.FederationConfiguration;
            fam.ServiceConfiguration = FederatedAuthentication.ServiceConfiguration;
            logger.Info("Assigning ServiceConfiguration to fam");
            var request = thisContext.Request;

            // is this the response from the STS
            if (!fam.IsSignInResponse(request))
            {
                // no
                logger.Info("fam.IsSignInResponse => No");
                // the STS
                fam.Issuer = _IssuerSTSSpec.Issuer;
                logger.Info("IssuerUrl= " + _IssuerSTSSpec.Issuer);
                // the return address
                fam.Realm = thisContext.Request.Url.AbsoluteUri;
                logger.Info("Assigning fam.Realm= " + thisContext.Request.Url.AbsoluteUri);
                logger.Info("Creating SignInRequest...");
                var req = fam.CreateSignInRequest(string.Empty, null, false);                
                logger.Info("Redirecting to the issuer...");
                logger.Info("Request to STS: "+ req.WriteQueryString().ToString());
                // go to STS
                thisContext.Response.Redirect(req.WriteQueryString());

            }
            else
            {
                // yes  
        -----------
        -----------

            }
            logger.Info("Returning the claims");
            return claims;
        }

ADFS 集成应用程序是否不支持“使用 URI”会话 cookie 模式或我的代码需要进行任何更改?

标签: asp.netsingle-sign-onadfsclaims-based-identity

解决方案


如果您添加“使用URI”的示例代码将有助于更好地理解。真的有必要使用这种方法吗?使用 cookie 将保持 URL 干净并且更易于管理。如果它已经为您工作,您可以使用它,除非确实需要使用 URI


推荐阅读