Skip to content
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

Merged
merged 7 commits into from
Sep 24, 2024
Merged

Jwt #11

merged 7 commits into from
Sep 24, 2024

Conversation

ChabVlad
Copy link
Owner

No description provided.

Copy link

@Elena-Bruyako Elena-Bruyako left a 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",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"/api/auth/register",

return userService.register(requestDto);
}

@PostMapping("/login")
public UserLoginResponseDto login(UserLoginRequestDto requestDto) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public UserLoginResponseDto login(UserLoginRequestDto requestDto) {
public UserLoginResponseDto login(@RequestBody @Valid UserLoginRequestDto requestDto) {

Comment on lines 30 to 37
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;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String bearerToken = request.getHeader("Authorization");
String bearerToken = request.getHeader(HttpHeaders.AUTHORIZATION);

Comment on lines 53 to 54
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith("Bearer ")) {
return bearerToken.substring(7);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 "

Copy link

@Elena-Bruyako Elena-Bruyako left a 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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add swagger annotation

@ChabVlad ChabVlad merged commit 11c8a55 into main Sep 24, 2024
2 checks passed
@ChabVlad ChabVlad deleted the jwt branch September 24, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants