Difference between registerGlobal(), configure(), configureGlobal(),configureGlobalSecurity in Spring security

后端 未结 2 1949
难免孤独
难免孤独 2020-12-12 16:46

I have below three code snippets all doing the same thing: creating in-memory authentication. So how it impacts defining it in different method names?

  1. register
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 17:53

    For the difference between: registerGlobal(AuthenticationManagerBuilder auth) and configureGlobal(AuthenticationManagerBuilder auth)

    The name of the configureGlobal method is not important. However, it is important to only configure AuthenticationManagerBuilder in a class annotated with either @EnableWebSecurity, @EnableWebMvcSecurity, @EnableGlobalMethodSecurity, or @EnableGlobalAuthentication. Doing otherwise has unpredictable results.

    Source:
    Chapter "Creating your Spring Security configuration" from the "Hello Spring Security Java Config" guide.


    protected void configure(AuthenticationManagerBuilder auth) is a method that is likely provided by WebSecurityConfigurer (and its interface WebSecurityConfigurer) - I would say that is just a more type save approach, but does not differ in its result.

提交回复
热议问题