How to provide custom security configuration for oauth2 with spring-boot 1.3.0.RC1

前端 未结 2 1094
旧巷少年郎
旧巷少年郎 2021-01-27 11:12

With spring-cloud Angel.SR3 release I followed example in https://github.com/spring-cloud-samples/sso and things work fine with spring-boot 1.2.6.RELEASE.

However with

2条回答
  •  鱼传尺愫
    2021-01-27 11:48

    You just have to use org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter and carefully use this annotation org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso

    I've written carefully because its behaviour depends on where you add it. As stated in the javadoc:

    Enable OAuth2 Single Sign On (SSO). If there is an existing WebSecurityConfigurerAdapter provided by the user and annotated with @EnableOAuth2Sso, it is enhanced by adding an authentication filter and an authentication entry point. If the user only has @EnableOAuth2Sso but not on a WebSecurityConfigurerAdapter then one is added with all paths secured and with an order that puts it ahead of the default HTTP Basic security chain in Spring Boot.

    Hope that helps!

提交回复
热议问题