-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from JNU-econovation/BE
Be
- Loading branch information
Showing
4 changed files
with
91 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 58 additions & 58 deletions
116
BE/error/src/main/java/com/example/demo/auth/presentation/interceptor/AuthInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,58 @@ | ||
package com.example.demo.auth.presentation.interceptor; | ||
|
||
|
||
import com.example.demo.auth.application.model.token.TokenResolver; | ||
import com.example.demo.auth.application.support.TokenExtractor; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.web.cors.CorsUtils; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
|
||
public class AuthInterceptor implements HandlerInterceptor { | ||
private final TokenExtractor tokenExtractor; | ||
private final TokenResolver tokenResolver; | ||
|
||
public AuthInterceptor( | ||
@Qualifier("header") TokenExtractor tokenExtractor, TokenResolver tokenResolver) { | ||
this.tokenExtractor = tokenExtractor; | ||
this.tokenResolver = tokenResolver; | ||
} | ||
|
||
public static AuthInterceptorBuilder builder() { | ||
return new AuthInterceptorBuilder(); | ||
} | ||
|
||
@Override | ||
public boolean preHandle( | ||
HttpServletRequest request, HttpServletResponse response, Object handler) { | ||
if (CorsUtils.isPreFlightRequest(request)) { | ||
return true; | ||
} | ||
|
||
String token = tokenExtractor.extract(request); | ||
System.out.println("token :" + token); | ||
tokenResolver.getUserDataByAccessToken(token); | ||
return true; | ||
} | ||
|
||
public static class AuthInterceptorBuilder { | ||
|
||
private TokenExtractor tokenExtractor; | ||
private TokenResolver tokenResolver; | ||
|
||
public AuthInterceptorBuilder tokenExtractor(TokenExtractor tokenExtractor) { | ||
this.tokenExtractor = tokenExtractor; | ||
return this; | ||
} | ||
|
||
public AuthInterceptorBuilder tokenResolver(TokenResolver tokenResolver) { | ||
this.tokenResolver = tokenResolver; | ||
return this; | ||
} | ||
|
||
public AuthInterceptor build() { | ||
return new AuthInterceptor(tokenExtractor, tokenResolver); | ||
} | ||
} | ||
} | ||
//package com.example.demo.auth.presentation.interceptor; | ||
// | ||
// | ||
//import com.example.demo.auth.application.model.token.TokenResolver; | ||
//import com.example.demo.auth.application.support.TokenExtractor; | ||
//import jakarta.servlet.http.HttpServletRequest; | ||
//import jakarta.servlet.http.HttpServletResponse; | ||
//import org.springframework.beans.factory.annotation.Qualifier; | ||
//import org.springframework.web.cors.CorsUtils; | ||
//import org.springframework.web.servlet.HandlerInterceptor; | ||
// | ||
//public class AuthInterceptor implements HandlerInterceptor { | ||
// private final TokenExtractor tokenExtractor; | ||
// private final TokenResolver tokenResolver; | ||
// | ||
// public AuthInterceptor( | ||
// @Qualifier("header") TokenExtractor tokenExtractor, TokenResolver tokenResolver) { | ||
// this.tokenExtractor = tokenExtractor; | ||
// this.tokenResolver = tokenResolver; | ||
// } | ||
// | ||
// public static AuthInterceptorBuilder builder() { | ||
// return new AuthInterceptorBuilder(); | ||
// } | ||
// | ||
// @Override | ||
// public boolean preHandle( | ||
// HttpServletRequest request, HttpServletResponse response, Object handler) { | ||
// if (CorsUtils.isPreFlightRequest(request)) { | ||
// return true; | ||
// } | ||
// | ||
// String token = tokenExtractor.extract(request); | ||
// System.out.println("token :" + token); | ||
// tokenResolver.getUserDataByAccessToken(token); | ||
// return true; | ||
// } | ||
// | ||
// public static class AuthInterceptorBuilder { | ||
// | ||
// private TokenExtractor tokenExtractor; | ||
// private TokenResolver tokenResolver; | ||
// | ||
// public AuthInterceptorBuilder tokenExtractor(TokenExtractor tokenExtractor) { | ||
// this.tokenExtractor = tokenExtractor; | ||
// return this; | ||
// } | ||
// | ||
// public AuthInterceptorBuilder tokenResolver(TokenResolver tokenResolver) { | ||
// this.tokenResolver = tokenResolver; | ||
// return this; | ||
// } | ||
// | ||
// public AuthInterceptor build() { | ||
// return new AuthInterceptor(tokenExtractor, tokenResolver); | ||
// } | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters