-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into refactor/#555
- Loading branch information
Showing
67 changed files
with
1,133 additions
and
570 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
33 changes: 33 additions & 0 deletions
33
backend/src/main/java/shook/shook/auth/config/LocalAuthConfig.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package shook.shook.auth.config; | ||
|
||
import java.util.List; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
import shook.shook.auth.ui.argumentresolver.AuthArgumentResolver; | ||
import shook.shook.auth.ui.interceptor.LocalInterceptor; | ||
|
||
@Profile("local") | ||
@Configuration | ||
public class LocalAuthConfig implements WebMvcConfigurer { | ||
|
||
private final AuthArgumentResolver authArgumentResolver; | ||
private final LocalInterceptor localInterceptor; | ||
|
||
public LocalAuthConfig(final AuthArgumentResolver authArgumentResolver, final LocalInterceptor localInterceptor) { | ||
this.authArgumentResolver = authArgumentResolver; | ||
this.localInterceptor = localInterceptor; | ||
} | ||
|
||
@Override | ||
public void addInterceptors(final InterceptorRegistry registry) { | ||
registry.addInterceptor(localInterceptor); | ||
} | ||
|
||
@Override | ||
public void addArgumentResolvers(final List<HandlerMethodArgumentResolver> resolvers) { | ||
resolvers.add(authArgumentResolver); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
backend/src/main/java/shook/shook/auth/ui/interceptor/LocalInterceptor.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package shook.shook.auth.ui.interceptor; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
import shook.shook.auth.ui.AuthContext; | ||
|
||
@Profile("local") | ||
@Component | ||
public class LocalInterceptor implements HandlerInterceptor { | ||
|
||
private final AuthContext authContext; | ||
|
||
public LocalInterceptor(final AuthContext authContext) { | ||
this.authContext = authContext; | ||
} | ||
|
||
@Override | ||
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) | ||
throws Exception { | ||
final long memberId = Long.parseLong(request.getHeader("Authorization")); | ||
authContext.setAuthenticatedMember(memberId); | ||
|
||
return true; | ||
} | ||
} |
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
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
Oops, something went wrong.