Skip to content

Commit 40b6d59

Browse files
authored
第十五篇 : Spring Boot Security 整合 OAuth2 设计安全API接口服务
1 parent 8e0f1ff commit 40b6d59

1 file changed

Lines changed: 2 additions & 19 deletions

File tree

springboot-security-oauth2/src/main/java/com/gf/config/AuthorizationServerConfiguration.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,9 @@ public TokenStore tokenStore() {
6363

6464
@Override
6565
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
66-
/**
67-
* 配置oauth2服务跨域
68-
*/
69-
CorsConfigurationSource source = new CorsConfigurationSource() {
70-
@Override
71-
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
72-
CorsConfiguration corsConfiguration = new CorsConfiguration();
73-
corsConfiguration.addAllowedHeader("*");
74-
corsConfiguration.addAllowedOrigin(request.getHeader( HttpHeaders.ORIGIN));
75-
corsConfiguration.addAllowedMethod("*");
76-
corsConfiguration.setAllowCredentials(true);
77-
corsConfiguration.setMaxAge(3600L);
78-
return corsConfiguration;
79-
}
80-
};
81-
82-
security.tokenKeyAccess("permitAll()")
66+
security.tokenKeyAccess("permitAll()")
8367
.checkTokenAccess("permitAll()")
84-
.allowFormAuthenticationForClients()
85-
.addTokenEndpointAuthenticationFilter(new CorsFilter(source));
68+
.allowFormAuthenticationForClients();
8669
}
8770

8871
@Override

0 commit comments

Comments
 (0)