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;);
 *     }
 * 
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进