-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jwt #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are changes from previous HW, please provide only JWT HW implementation
auth -> auth | ||
.requestMatchers( | ||
"/auth/**", | ||
"/api/auth/register", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"/api/auth/register", |
return userService.register(requestDto); | ||
} | ||
|
||
@PostMapping("/login") | ||
public UserLoginResponseDto login(UserLoginRequestDto requestDto) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public UserLoginResponseDto login(UserLoginRequestDto requestDto) { | |
public UserLoginResponseDto login(@RequestBody @Valid UserLoginRequestDto requestDto) { |
String path = request.getRequestURI(); | ||
if ( | ||
path.startsWith("/api/auth") | ||
|| path.startsWith("/api/swagger-ui") | ||
|| path.startsWith("/api/v3/api-docs")) { | ||
filterChain.doFilter(request, response); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String path = request.getRequestURI(); | |
if ( | |
path.startsWith("/api/auth") | |
|| path.startsWith("/api/swagger-ui") | |
|| path.startsWith("/api/v3/api-docs")) { | |
filterChain.doFilter(request, response); | |
return; | |
} |
} | ||
|
||
private String getToken(HttpServletRequest request) { | ||
String bearerToken = request.getHeader("Authorization"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String bearerToken = request.getHeader("Authorization"); | |
String bearerToken = request.getHeader(HttpHeaders.AUTHORIZATION); |
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith("Bearer ")) { | ||
return bearerToken.substring(7); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith("Bearer ")) { | |
return bearerToken.substring(7); | |
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith(TOKEN_HEADER)) { | |
return bearerToken.substring(TOKEN_HEADER.length()); |
create constant TOKEN_HEADER = "Bearer "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one comment
@@ -31,4 +35,9 @@ public UserResponseDto register(@RequestBody @Valid UserRegistrationRequestDto r | |||
|
|||
return userService.register(requestDto); | |||
} | |||
|
|||
@PostMapping("/login") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add swagger annotation
No description provided.