Teu*_*y R 9 java spring spring-security spring-boot
这些类之间有什么区别?我知道WebSecurityConfigurerAdapter用于自定义我们应用程序中的“安全性”。
我做了什么:
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
CustomUserDetailsService customUserDetailsService;
@Autowired
private JwtAuthenticationEntryPoint unauthorizedHandler;
Run Code Online (Sandbox Code Playgroud)
但是我不明白AuthorizationServerConfigurerAdapter的含义。
我读了几篇文章,但听不懂。
Mat*_* Ke 16
首先是一件事。OAuth 2是一个授权框架。它允许应用程序(客户端)代表资源所有者(用户)获得对HTTP服务的有限访问。OAuth 2不是身份验证协议。
AuthorizationServerConfigurerAdapter用于配置OAuth授权服务器的工作方式。
以下是一些可以配置的方面:
WebSecurityConfigurerAdapter用于配置OAuth授权服务器的安全性。
换句话说,用户必须如何进行身份验证才能授予客户端对其资源的访问权限。
可以是:
(我故意省略了一些细节,以使答案尽可能简单。)
具有内存中令牌存储的示例授权服务器配置:
@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.tokenStore(tokenStore());
}
@Bean
public TokenStore tokenStore() {
return new InMemoryTokenStore();
}
...
}
Run Code Online (Sandbox Code Playgroud)
使用表单登录的示例安全配置:
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/login").permitAll()
.antMatchers("/oauth/authorize").authenticated()
.and()
.formLogin();
}
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3496 次 |
| 最近记录: |