Skip to content

Commit

Permalink
concord-server: handle request without cookies (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
brig authored Feb 25, 2025
1 parent 2d03dc7 commit 5244577
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Stream;

/**
Expand Down Expand Up @@ -84,12 +86,14 @@ protected void forgetIdentity(Subject subject) {
}

// delete the "remember me" cookie only if it is present
HttpServletRequest request = WebUtils.getHttpRequest(subject);
var request = WebUtils.getHttpRequest(subject);
var rememberMeCookieName = getCookie().getName();
if (Stream.of(request.getCookies())
.anyMatch(cookie -> cookie.getName().equals(rememberMeCookieName))) {
super.forgetIdentity(subject);
}

Optional.ofNullable(request.getCookies()).stream()
.flatMap(Arrays::stream)
.filter(cookie -> cookie.getName().equals(rememberMeCookieName))
.findFirst()
.ifPresent(cookie -> super.forgetIdentity(subject));
}

private static class PrincipalCollectionSerializer implements Serializer<PrincipalCollection> {
Expand Down

0 comments on commit 5244577

Please sign in to comment.