修改配置,增加笔记

pull/383/head
Nick 2020-03-30 09:32:34 +08:00
parent 121304adbd
commit cb63b30f37
7 changed files with 27 additions and 8 deletions

View File

@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
/**
* PointcutAdviceAspect
* @author Zheng Jie
* @date 2018-11-24
*/
@ -51,6 +52,11 @@ public class LogAspect {
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
Object result;
currentTime.set(System.currentTimeMillis());
/**
* AOPAround-->Before--->Around--->After
* 使joinPoint.proceed()使,BeforeAfter
* proceed()使
*/
result = joinPoint.proceed();
Log log = new Log("INFO",System.currentTimeMillis() - currentTime.get());
currentTime.remove();

View File

@ -91,7 +91,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.and()
.authorizeRequests()
// 静态资源等等
// 静态资源等等对GET请求的静态资源放行
.antMatchers(
HttpMethod.GET,
"/*.html",
@ -112,7 +112,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/druid/**").permitAll()
// 放行OPTIONS请求
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
// 自定义匿名访问所有url放行 允许匿名和带权限以及登录用户访问
/**
* 1 访url 访
* 2 Java antMatchers(String... antPatterns)
* String[] antPatterns
* 3 T[] toArray(T[] a)Object[],
*/
.antMatchers(anonymousUrls.toArray(new String[0])).permitAll()
// 所有请求都需要认证
.anyRequest().authenticated()

View File

@ -96,7 +96,9 @@ public class AuthController {
}
UsernamePasswordAuthenticationToken authenticationToken =
new UsernamePasswordAuthenticationToken(authUser.getUsername(), password);
/**
* token
*/
Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
SecurityContextHolder.getContext().setAuthentication(authentication);
// 生成令牌

View File

@ -16,7 +16,10 @@ public class JwtAccessDeniedHandler implements AccessDeniedHandler {
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException {
//当用户在没有授权的情况下访问受保护的REST资源时将调用此方法发送403 Forbidden响应
/**
* 访
* 访REST403 Forbidden
*/
response.sendError(HttpServletResponse.SC_FORBIDDEN, accessDeniedException.getMessage());
}
}

View File

@ -19,7 +19,10 @@ public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
public void commence(HttpServletRequest request,
HttpServletResponse response,
AuthenticationException authException) throws IOException {
// 当用户尝试访问安全的REST资源而不提供任何凭据时将调用此方法发送401 响应
/**
* URL访
* 访REST401
*/
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException==null?"Unauthorized":authException.getMessage());
}
}

View File

@ -65,8 +65,8 @@ swagger:
# 文件存储路径
file:
path: C:\eladmin\file\
avatar: C:\eladmin\avatar\
path: D:\eladmin\file\
avatar: D:\eladmin\avatar\
# 文件大小 /M
maxSize: 100
avatarMaxSize: 5

View File

@ -25,7 +25,7 @@ spring:
database: 0
host: 127.0.0.1
port: 6379
password:
password: 1234
#连接超时时间
timeout: 5000