@EnableAuthorizationServer 注解的导入路径是什么

Ric*_*ick 1 java spring oauth spring-security

我正在尝试理解 Spring 授权服务器。

\n

遵循各种教程和原始文档,几乎是配置依赖项 \xe2\x80\x93 后的第一步

\n
dependencies {\n    implementation 'org.springframework.boot:spring-boot-starter-webflux'\n    implementation 'org.springframework.boot:spring-boot-starter-security'\n    implementation 'org.springframework.security:spring-security-oauth2-authorization-server:0.2.1'\n//  other db/test stuff\n}\n
Run Code Online (Sandbox Code Playgroud)\n

@EnableAuthorizationServer\xe2\x80\x93 是为主类添加注解。

\n

除了我的 IDE (NetBeans) 没有从导入中得知它指的是什么。

\n

那么:导入路径应该用于什么@EnableAuthorizationServer?(而且,从逻辑上讲,是否还需要一些其他依赖项才能识别它?)

\n

Mar*_*gio 5

在新的 Spring 授权服务器中,您不需要@EnableAuthorizationServer. 该注释来自旧spring-security-oauth模块,已弃用

关键是SecurityFilterChain,它应该具有更高的优先级,如下所示:

@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception {
    OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http);
    return http.formLogin(Customizer.withDefaults()).build();
}
Run Code Online (Sandbox Code Playgroud)

我建议您查看官方存储库中的示例。