Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/com/somemore/auth/jwt/domain/EncodedToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

public record EncodedToken(String value) {

private final static String UNINITIALIZED = "UNINITIALIZED";

public boolean isUninitialized() {
return value == null
|| value.isEmpty()
|| value.equals("UNINITIALIZED");
|| value.equals(UNINITIALIZED);
}

public EncodedToken removePrefix(String prefix) {
Expand All @@ -14,4 +16,8 @@ public EncodedToken removePrefix(String prefix) {
}
return this;
}

public static EncodedToken createUninitialized() {
return new EncodedToken(UNINITIALIZED);
}
}
18 changes: 9 additions & 9 deletions src/main/java/com/somemore/auth/jwt/filter/JwtAuthFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public class JwtAuthFilter extends OncePerRequestFilter {

@Override
protected boolean shouldNotFilter(HttpServletRequest request) {
EncodedToken accessToken = getAccessToken(request);
String path = request.getRequestURI();

return accessToken == null
|| accessToken.isUninitialized()
|| path.equals("/api/center/sign-in");
try {
EncodedToken accessToken = getAccessToken(request);
return accessToken == null || accessToken.isUninitialized();
} catch (JwtException e) {
return true;
}
}

@Override
Expand Down Expand Up @@ -75,7 +75,7 @@ private EncodedToken getAccessToken(HttpServletRequest request) {
private static EncodedToken findAccessTokenFromHeader(HttpServletRequest request) {
String authorizationHeader = request.getHeader("Authorization");
if (authorizationHeader == null || authorizationHeader.isEmpty()) {
return new EncodedToken("UNINITIALIZED");
return EncodedToken.createUninitialized();
}

return new EncodedToken(authorizationHeader);
Expand All @@ -84,7 +84,7 @@ private static EncodedToken findAccessTokenFromHeader(HttpServletRequest request
private EncodedToken findAccessTokenFromCookie(HttpServletRequest request) {
Cookie[] cookies = request.getCookies();
if (cookies == null) {
return new EncodedToken("UNINITIALIZED");
return EncodedToken.createUninitialized();
}

return Arrays.stream(cookies)
Expand All @@ -93,7 +93,7 @@ private EncodedToken findAccessTokenFromCookie(HttpServletRequest request) {
.map(Cookie::getValue)
.findFirst()
.map(EncodedToken::new)
.orElse(new EncodedToken("UNINITIALIZED"));
.orElse(EncodedToken.createUninitialized());
}

private JwtAuthenticationToken createAuthenticationToken(Claims claims,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public List<Long> findNotCompletedIdsByCenterId(UUID centerId) {
@Override
public List<RecruitBoard> findAllByIds(List<Long> ids) {
BooleanExpression exp = recruitBoard.id.in(ids)
.and(isNotCompleted());
.and(isNotDeleted());

return queryFactory
.selectFrom(recruitBoard)
Expand Down
Loading