-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Polish Spring Security Samples #5052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -2185,17 +2184,15 @@ to the home page at "/" and keep the default for everything else: | |||
|
|||
[source,java,indent=0] | |||
---- | |||
@Configuration | |||
@EnableWebSecurity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will switch off all of Boot's web security configuration as SpringBootWebSecurityConfiguration
is @ConditionalOnMissingBean(WebSecurityConfiguration.class)
. Doesn't that mean that "and keep the default for everything else" is no longer true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already not true because this WebSecurityConfigurerAdapter
will be invoked (rather than the ones configure by Spring Boot) regardless of if @EnableWebSecurity
.
Admittedly, it does give you slightly different results since the ignored patterns are no longer used. However, the intent is to address:
The name of the configureGlobal method is not important. However, it is important to only configure AuthenticationManagerBuilder in a class annotated with either @EnableWebSecurity, @EnableGlobalMethodSecurity, or @EnableGlobalAuthentication. Doing otherwise has unpredictable results.
The reason for this is because we need to ensure any classes that are configuring AuthenticationManagerBuilder
are instantiated before we build the AuthenticationManager
. In practice, this is done using EnableGlobalAuthenticationAutowiredConfigurer
which eagerly initializes beans that are annotated (or meta-annotated) with @EnableGlobalAuthentication
.
These instructions are likely a big part of the reason users experience ordering issues with Spring Security and Spring Boot.
@rwinch Any thoughts on my comments? |
@rwinch ping |
We're going to revisit security entirely in 2.0. |
Fixes gh-2589