From 05c74ca131add20dbcf23dc109e63c21b3e2be29 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Wed, 24 Feb 2021 18:11:57 +0800
Subject: [PATCH] Merge branch 'whole_new_trc20' into whole_new
---
src/main/java/com/xcong/excoin/configurations/security/WebSecurityConfig.java | 158 ++++++++++++++++++++++++++++------------------------
1 files changed, 86 insertions(+), 72 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/configurations/security/WebSecurityConfig.java b/src/main/java/com/xcong/excoin/configurations/security/WebSecurityConfig.java
index 868cb65..2b1a72e 100644
--- a/src/main/java/com/xcong/excoin/configurations/security/WebSecurityConfig.java
+++ b/src/main/java/com/xcong/excoin/configurations/security/WebSecurityConfig.java
@@ -1,72 +1,86 @@
-package com.xcong.excoin.configurations.security;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpMethod;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.security.web.AuthenticationEntryPoint;
-import org.springframework.security.web.access.AccessDeniedHandler;
-
-import javax.annotation.Resource;
-
-/**
- * @author wzy
- * @date 2020-05-11
- **/
-@Slf4j
-@Configuration
-@EnableWebSecurity
-@EnableGlobalMethodSecurity(prePostEnabled = true)
-public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
-
- @Resource
- private UserDetailsService userDetailsService;
-
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.httpBasic().and().
- cors().and().csrf().disable()
- .exceptionHandling().authenticationEntryPoint(authenticationEntryPoint())
- .and()
- .authorizeRequests()
- .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
- .antMatchers("/login").permitAll()
- .antMatchers("/swagger**/**").permitAll()
- .antMatchers("/webjars/**").permitAll()
- .antMatchers("/v2/**").permitAll()
- .anyRequest().authenticated()
- .and().apply(securityConfiguereAdapter());
- }
-
- @Override
- protected void configure(AuthenticationManagerBuilder auth) throws Exception {
- auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
- }
-
- @Bean
- public PasswordEncoder passwordEncoder() {
- return new BCryptPasswordEncoder();
- }
-
- @Bean
- public AccessDeniedHandler accessDeniedHandler() {
- return new CustomAccessDeniedHandler();
- }
-
- @Bean
- public AuthenticationEntryPoint authenticationEntryPoint() {
- return new CustomAuthenticationEntryPoint();
- }
-
- public TokenConfigurer securityConfiguereAdapter() {
- return new TokenConfigurer();
- }
-}
+package com.xcong.excoin.configurations.security;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpMethod;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.web.AuthenticationEntryPoint;
+import org.springframework.security.web.access.AccessDeniedHandler;
+
+import javax.annotation.Resource;
+
+/**
+ * @author wzy
+ * @date 2020-05-11
+ **/
+@Slf4j
+@Configuration
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(prePostEnabled = true)
+public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
+
+ @Resource
+ private UserDetailsService userDetailsService;
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.httpBasic().and().
+ cors().and().csrf().disable()
+ .exceptionHandling().authenticationEntryPoint(authenticationEntryPoint())
+ .and()
+ .authorizeRequests()
+ .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
+ .antMatchers("/login").permitAll()
+ .antMatchers("/register").permitAll()
+ .antMatchers("/swagger**/**").permitAll()
+ .antMatchers("/webjars/**").permitAll()
+ .antMatchers("/v2/**").permitAll()
+ .antMatchers("/api/symbols/**").permitAll()
+ .antMatchers("/common/**").permitAll()
+ .antMatchers("/api/exchange/**").permitAll()
+ .antMatchers("/api/member/getMemberAccountInfo").permitAll()
+ .antMatchers("/api/member/memberForgetPwd").permitAll()
+ .antMatchers("/api/member/memberCoinInfoList").permitAll()
+ .antMatchers("/api/member/getPcVersionInfo").permitAll()
+ .antMatchers("/api/member/getAppVersionInfo").permitAll()
+ .antMatchers("/api/orderCoin/searchSymbolResultList").permitAll()
+ .antMatchers("/api/orderCoin/findCollect").permitAll()
+ .antMatchers("/api/orderCoin/findCollect").permitAll()
+ .antMatchers("/api/documentary/getFollowTraderProfitInfo").permitAll()
+ .antMatchers("/api/helpCenter/**").permitAll()
+ .anyRequest().authenticated()
+ .and().apply(securityConfiguereAdapter());
+ }
+
+ @Override
+ protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+ auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
+ }
+
+ @Bean
+ public PasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+ @Bean
+ public AccessDeniedHandler accessDeniedHandler() {
+ return new CustomAccessDeniedHandler();
+ }
+
+ @Bean
+ public AuthenticationEntryPoint authenticationEntryPoint() {
+ return new CustomAuthenticationEntryPoint();
+ }
+
+ public TokenConfigurer securityConfiguereAdapter() {
+ return new TokenConfigurer();
+ }
+}
--
Gitblit v1.9.1