Spring Security 中的 @EnableGlobalAuthentication 注解是干啥的,起什么作用的

Spring Security 中的 @EnableGlobalAuthentication 注解是干啥的,起什么作用的

Spring Security 4.2.0.RELEASE

阅读 5.2k
2 个回答

类似3的<sec:global-method-security pre-post-annotations="enabled"/>。权限控制...

The {@link EnableGlobalAuthentication} annotation signals that the
annotated class can * be used to configure a global instance of
{@link AuthenticationManagerBuilder}

被这个注解修饰的类,可以用来构建一个全局的AuthenticationManagerBuilder
例子:

 * public class MyGlobalAuthenticationConfiguration {
 *
 *     &#064;Autowired
 *     public void configureGlobal(AuthenticationManagerBuilder auth) {
 *         auth.inMemoryAuthentication().withUser(&quot;user&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;)
 *                 .and().withUser(&quot;admin&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;, &quot;ADMIN&quot;);
 *     }
 *