gpt4 book ai didi

spring - 在spring security中如何基于header进行多重认证

转载 作者:行者123 更新时间:2023-12-04 12:55:51 25 4
gpt4 key购买 nike

我有一个与 SAML 身份验证集成的 spring 应用程序。但是现在我想将我的 api 公开给我使用基于 token 的身份验证的其他应用程序和第三方系统。那么,如何根据 header 检查选择哪种身份验证机制。如果标题有 X-Apikey作为 header ,则需要应用基于 header 的身份验证,其中必须通过调用 rest api 结果(身份验证和授权服务器)来检查 token 。如果 token 没有 X-Apikey header 然后需要执行 SAML 身份验证。如何使用已经集成的 SAML 应用程序实现这一目标。

最佳答案

  • 您可以使用在
  • 中添加的 CustomFilter
    @Override
    protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests()
    ...
    .addFilter(customBeforeAuthenticationFilter, CustomBeforeAuthenticationFilter.class)
    ...
    }

    更多详情: https://www.marcobehler.com/guides/spring-security

    2)替代方法是在您的安全过滤器中添加一个“AuthenticationManagerResolver”,然后您可以检查 header 并决定使用的身份验证
    这是一个指南: https://www.baeldung.com/spring-security-authenticationmanagerresolver

    关于spring - 在spring security中如何基于header进行多重认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67765049/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com