Skip to content

Commit

Permalink
fix: #202 fix logout process
Browse files Browse the repository at this point in the history
  • Loading branch information
KartVen committed Dec 22, 2024
1 parent 58cb25c commit 373e411
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected void doFilterInternal(
@NonNull FilterChain filterChain
) throws ServletException, IOException {
extractBearer(request)
.flatMapTry(jwtProvider::parseToken)
.flatMap(jwtProvider::parseToken)
.map(this::toUserPrincipal)
.onFailure(th -> log.debug("Authenticate failure", th))
.onSuccess(user -> authenticate(request, user));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public Deserialize(UUID bearerId, Long id, String username, Integer state, Set<S
@Setter
@NoArgsConstructor
public abstract static class Properties {
private String secretKey = "";
private String secretKey;
private Integer bearerExpirationMin = 15;
private Integer delegationExpirationMin = 60;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

@Component
@Slf4j
public class LogoutGatewayFilterFactory extends AbstractGatewayFilterFactory<Object> {
public class LogoutRelayGatewayFilterFactory extends AbstractGatewayFilterFactory<Object> {

public LogoutGatewayFilterFactory() {
public LogoutRelayGatewayFilterFactory() {
super(Object.class);
}

@Override
public GatewayFilter apply(Object config) {
return new LogoutGatewayFilter();
return new LogoutRelayFilter();
}

@Getter
Expand All @@ -41,10 +41,7 @@ public static class Config {
}

@RequiredArgsConstructor
private static final class LogoutGatewayFilter implements GatewayFilter, Ordered {
private static final String ACCESS_TOKEN_COOKIE = "AUTH_CONTEXT";
private static final String REFRESH_TOKEN_COOKIE = "AUTH_PERSIST";

private static final class LogoutRelayFilter implements GatewayFilter, Ordered {
@Override
public int getOrder() {
return NettyWriteResponseFilter.WRITE_RESPONSE_FILTER_ORDER;
Expand All @@ -67,7 +64,8 @@ private void modifyHeaders(ServerHttpResponse response) {
}
response.getHeaders().addAll(
HttpHeaders.SET_COOKIE,
List.of(createExpiredCookie(ACCESS_TOKEN_COOKIE).toString(), createExpiredCookie(REFRESH_TOKEN_COOKIE).toString())
List.of(createExpiredCookie(AuthCookies.ACCESS_TOKEN).toString(),
createExpiredCookie(AuthCookies.REFRESH_TOKEN).toString())
);
}

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion kodemy-api-gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spring:
predicates:
- Path=/api/auth/logout
filters:
- Logout
- LogoutRelay

- id: oauth2_auth
uri: ${service.baseUrl.auth}
Expand Down
2 changes: 1 addition & 1 deletion kodemy-auth/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ service:
app:
security:
jwt:
bearer-expiration-min: 2
bearer-expiration-min: 60
oauth2:
baseUrl:
front: http://localhost:3000
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
Expand Down Expand Up @@ -65,6 +66,7 @@ public JwtAuthorizationFilter jwtAuthorizationFilter(JwtProvider jwtProvider) {
}

@Component
@NoArgsConstructor
@ConfigurationProperties(prefix = "app.security.jwt")
public static class JwtProperties extends JwtProvider.Properties {
}
Expand Down
5 changes: 0 additions & 5 deletions kodemy-backend/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ service:
baseUrl:
auth: http://localhost:8080

app:
security:
jwt:
bearer-expiration-min: 60

eureka:
client:
enabled: false

0 comments on commit 373e411

Please sign in to comment.