在Spring Boot OAuth2授权服务器中使用Active Directory身份验证

蒂姆·韦伯斯特

我正在尝试使用Spring Boot和OAuth2建立概念验证。我已经建立了一些项目,与此处概述的项目非常相似:

https://spring.io/guides/tutorials/spring-boot-oauth2/

并在这里:https : //spring.io/guides/tutorials/spring-security-and-angular-js/

与我的主要区别是我遗漏了所有AngularJS的东西。

我有以下服务:

  • 授权服务器
  • 资源服务器(作为受保护的OAuth2客户端)
  • UI服务器(作为受保护的OAuth2客户端)

我想要发生的一切是这样的:

  1. 点击UI服务器
  2. 重定向到身份验证服务器并提示输入凭据
  3. 然后,UI服务器将从资源服务器中获取一些文本并显示它们

我可以使用auth服务器上的Basic身份验证来正常工作。但是,我希望能够用Active Directory中的基本身份验证代替基本身份验证。

我还有其他几个可以进行AD身份验证的Spring Boot项目,它可以工作,但是,每当我尝试将其放入其中时,都会出错。我认为这与身份验证服务器端点周围的安全性有关,但我不确定。

另外,我不清楚在生产环境中应通过哪种协议(OAuth2 v。Basic)保护哪些端点?文档建议某些端点应使用Basic保护。所有“ OAuth2客户端”都应以某种方式在其请求中包括这些凭据吗?

这是我的身份验证服务器应用程序(添加了用于Active Directory的位):

@EnableResourceServer
@EnableAuthorizationServer
@SpringBootApplication
@RestController
public class AuthServerLdapApplication {

public static void main(String[] args) {
    SpringApplication.run(AuthServerLdapApplication.class, args);
}

@RequestMapping("/user")
public Principal user(Principal user) {
    return user;
}

@Order(ManagementServerProperties.ACCESS_OVERRIDE_ORDER)
@Configuration
protected static class ActiveDirectoryConfig extends WebSecurityConfigurerAdapter {

    @Value("${activedirectory.url}")
    private String activeDirectoryUrl;

    @Value("${activedirectory.domain}")
    private String getActiveDirectoryDomain;

    @Autowired private AuthenticationManager authenticationManager;

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        ActiveDirectoryLdapAuthenticationProvider provider = new ActiveDirectoryLdapAuthenticationProvider(getActiveDirectoryDomain,
                activeDirectoryUrl);
        provider.setConvertSubErrorCodesToExceptions(true);
        provider.setUseAuthenticationRequestCredentials(true);

        auth.authenticationProvider(provider);
        auth.parentAuthenticationManager(authenticationManager);
    }
}

}

基本上,然后发生的是,当我按下UI服务器时得到了以下信息:

<oauth>
  <error_description>
    Full authentication is required to access this resource
  </error_description>
  <error>unauthorized</error>
</oauth>

如果我对授权服务器执行此操作:

curl -v http://localhost:9004/uaa/login
*   Trying ::1...
* Connected to localhost (::1) port 9004 (#0)
> GET /uaa/login HTTP/1.1
> Host: localhost:9004
> User-Agent: curl/7.44.0
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Server: Apache-Coyote/1.1
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Cache-Control: no-store
< Pragma: no-cache
< WWW-Authenticate: Bearer realm="null", error="unauthorized",    error_description="Full authentication is required to access this resource"
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Tue, 01 Dec 2015 12:38:53 GMT
<
{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}* Connection #0 to host localhost left intact

看起来登录端点现在需要一个承载令牌?我不确定现在如何进行...

任何帮助/建议将不胜感激...

戴夫·瑟

@EnableResourceServer但您尚未为要保护的资源提供任何规则,因此它正在尝试保护所有内容。您需要添加@Bean类型,ResourceServerConfigurerAdapter并设置请求匹配项(以及您想要的其他任何规则)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在 Spring Boot 中使用预定义的令牌绕过 Oauth2 身份验证?

来自分类Dev

Spring boot、Security、OAuth2:是否可以使用自定义 AuthorizationCodeResourceDetails?身份验证服务器需要重定向 url 中的特定参数

来自分类Dev

使用Spring Boot进行OAuth2身份验证后无法正确重定向

来自分类Dev

Spring Boot OAuth2拆分授权服务器和资源服务器

来自分类Dev

获得身份验证以在Tomcat上使用Spring Boot

来自分类Dev

Spring Boot 2 + OAuth2:配置令牌的身份验证代码交换

来自分类Dev

使用 spring-boot-starter-oauth2-client 检索 OAuth2 3-legged 身份验证的访问令牌

来自分类Dev

具有 Active Directory 身份验证的 Spring SwitchUserFilter

来自分类Dev

在XwsSecurityInterceptor中使用SpringPlainTextPasswordValidationCallbackHandler时使用Spring Security身份验证失败的Spring Boot

来自分类Dev

如何在Flyway中使用Spring Boot / Spring Security的JDBC身份验证

来自分类Dev

使用Spring Boot 2和Spring Security 5进行多重身份验证

来自分类Dev

Spring Boot 1.3 + OAuth:身份验证请求失败:BadCredentialsException:无法获取访问令牌

来自分类Dev

在令牌验证期间,在 spring security oauth2 中从资源服务器发送到身份验证服务器的确切内容

来自分类Dev

找不到Spring Boot 2 + Microsoft AD身份验证+ userPassword属性

来自分类常见问题

如何使用Spring Boot Web身份验证和Postman测试API?

来自分类Dev

使用spring-boot对相同URL进行身份验证的方式有所不同

来自分类Dev

如何使用Spring Boot安全性实现身份验证?

来自分类Dev

无法使用 Spring Boot REST API 设置基本身份验证

来自分类Dev

如何使用JDBC实现水平扩展Spring-boot OAuth2服务器

来自分类Dev

在iOS中使用NSURLSessions对服务器API进行oAuth2身份验证

来自分类Dev

Javascript WebApp 的 Spring Security Oauth2 身份验证

来自分类Dev

Vaadin和Spring,通过LDAP针对Active Directory进行身份验证

来自分类Dev

Java Spring Security-基于应用程序角色的Active Directory用户身份验证

来自分类Dev

如何使用Spring Boot使用OAuth1.0和自定义标头对API进行身份验证

来自分类Dev

在Spring Boot中配置JDBC身份验证

来自分类Dev

Spring Boot-身份验证为空

来自分类Dev

Spring OAuth2和AngularJS应用程序中的身份验证/授权

来自分类Dev

在负载均衡器后面运行的多个 Spring Boot App 实例是否应该使用 Spring CAS 用户身份验证?

来自分类Dev

与API密钥身份验证集成后,无法在Spring Boot 2.3.4中使用allowAll()来允许访问Swagger UI

Related 相关文章

  1. 1

    如何在 Spring Boot 中使用预定义的令牌绕过 Oauth2 身份验证?

  2. 2

    Spring boot、Security、OAuth2:是否可以使用自定义 AuthorizationCodeResourceDetails?身份验证服务器需要重定向 url 中的特定参数

  3. 3

    使用Spring Boot进行OAuth2身份验证后无法正确重定向

  4. 4

    Spring Boot OAuth2拆分授权服务器和资源服务器

  5. 5

    获得身份验证以在Tomcat上使用Spring Boot

  6. 6

    Spring Boot 2 + OAuth2:配置令牌的身份验证代码交换

  7. 7

    使用 spring-boot-starter-oauth2-client 检索 OAuth2 3-legged 身份验证的访问令牌

  8. 8

    具有 Active Directory 身份验证的 Spring SwitchUserFilter

  9. 9

    在XwsSecurityInterceptor中使用SpringPlainTextPasswordValidationCallbackHandler时使用Spring Security身份验证失败的Spring Boot

  10. 10

    如何在Flyway中使用Spring Boot / Spring Security的JDBC身份验证

  11. 11

    使用Spring Boot 2和Spring Security 5进行多重身份验证

  12. 12

    Spring Boot 1.3 + OAuth:身份验证请求失败:BadCredentialsException:无法获取访问令牌

  13. 13

    在令牌验证期间,在 spring security oauth2 中从资源服务器发送到身份验证服务器的确切内容

  14. 14

    找不到Spring Boot 2 + Microsoft AD身份验证+ userPassword属性

  15. 15

    如何使用Spring Boot Web身份验证和Postman测试API?

  16. 16

    使用spring-boot对相同URL进行身份验证的方式有所不同

  17. 17

    如何使用Spring Boot安全性实现身份验证?

  18. 18

    无法使用 Spring Boot REST API 设置基本身份验证

  19. 19

    如何使用JDBC实现水平扩展Spring-boot OAuth2服务器

  20. 20

    在iOS中使用NSURLSessions对服务器API进行oAuth2身份验证

  21. 21

    Javascript WebApp 的 Spring Security Oauth2 身份验证

  22. 22

    Vaadin和Spring,通过LDAP针对Active Directory进行身份验证

  23. 23

    Java Spring Security-基于应用程序角色的Active Directory用户身份验证

  24. 24

    如何使用Spring Boot使用OAuth1.0和自定义标头对API进行身份验证

  25. 25

    在Spring Boot中配置JDBC身份验证

  26. 26

    Spring Boot-身份验证为空

  27. 27

    Spring OAuth2和AngularJS应用程序中的身份验证/授权

  28. 28

    在负载均衡器后面运行的多个 Spring Boot App 实例是否应该使用 Spring CAS 用户身份验证?

  29. 29

    与API密钥身份验证集成后,无法在Spring Boot 2.3.4中使用allowAll()来允许访问Swagger UI

热门标签

归档