首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何为ADFS在春季安全性中设置RequestedAuthenticationContext?

如何为ADFS在春季安全性中设置RequestedAuthenticationContext?
EN

Stack Overflow用户
提问于 2021-10-06 11:58:16
回答 1查看 411关注 0票数 0

我用urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport工具对其进行了测试,发现我需要身份验证类型:表单和令牌请求: SAML (SAML2.0),但我不知道如何配置spring安全性,以便在SAML请求中将RequestedAuthenticationContext发送为而不是urn:oasis:names:tc:SAML:2.0:ac:classes:Kerberos

因此,与之相反:

  • 身份验证类型:Windows集成身份验证
  • 令牌请求:SAML(SAML2.0)
  • 请求IdP: GET https://ospa.company.com/adfs/ls/IdpInitiatedSignOn?LoginToRP=urn:microsoft:adfs:claimsxray& RequestedAuthenticationContext=urn:oasis:names:tc:SAML:2.0:ac:classes:Kerberos
  • 来自IdP:的响应
代码语言:javascript
运行
复制
<samlp:Response ID="..."
                Version="2.0"
                IssueInstant="..."
                Destination="https://adfshelp.microsoft.com/ClaimsXray/TokenResponse"
                Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified"
                xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
    ...
        <AuthnStatement AuthnInstant="..." SessionIndex="...">
            <AuthnContext>

     <AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Kerberos</AuthnContextClassRef>

            </AuthnContext>
        </AuthnStatement>
    </Assertion>
</samlp:Response>

我需要这个:

  • 身份验证类型:窗体
  • 令牌请求:SAML(SAML2.0)
  • 请求IdP: GET https://ospa.company.com/adfs/ls/IdpInitiatedSignOn?LoginToRP=urn:microsoft:adfs:claimsxray& RequestedAuthenticationContext=urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport
  • 来自IdP:的响应
代码语言:javascript
运行
复制
<samlp:Response ID="..."
                Version="2.0"
                IssueInstant="..."
                Destination="https://adfshelp.microsoft.com/ClaimsXray/TokenResponse"
                Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified"
                xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
    ...
        <AuthnStatement AuthnInstant="..." SessionIndex="...">
            <AuthnContext>

     <AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</AuthnContextClassRef>

            </AuthnContext>
        </AuthnStatement>
    </Assertion>
</samlp:Response>

更新:我们使用spring 2.5.5

EN

回答 1

Stack Overflow用户

发布于 2021-10-13 18:21:23

你需要的是一个AuthenticationEntryPointAuthenticationEntryPoint是在需要身份验证时告诉Security在何处重定向的方法。

由于只需要在需要身份验证时重定向,所以可以使用LoginUrlAuthenticationEntryPoint,如下所示:

代码语言:javascript
运行
复制
@Bean
SecurityFilterChain app(HttpSecurity http) throws Exception {
    String url = "https://ospa.company.com/adfs/ls/IdpInitiatedSignOn? LoginToRP=urn:microsoft:adfs:claimsxray& RequestedAuthenticationContext=urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport";

    AuthenticationEntryPoint entryPoint = 
            new LoginUrlAuthenticationEntryPoint(url);

    http
        .authorizeHttpRequests((authorize) -> authorize
            .anyRequest().authenticated()
        )
        .saml2Login(withDefaults())
        .exceptionHandling((exceptions) -> exceptions
            .authenticationEntryPoint(entryPoint)
        );
    
    return http.build();
}

也请确保您的使用IdP的相应元数据配置应用程序

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69465308

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档