Skip to content

Commit

Permalink
refactor: stomp ApiStompController to stash a more general auth value
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonk000 committed May 7, 2024
1 parent b5f7c42 commit 0bc00fb
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.eclipse.jifa.server.domain.dto.AnalysisApiRequest;
import org.eclipse.jifa.server.domain.dto.AnalysisApiStompResponseMessage;
import org.eclipse.jifa.server.domain.exception.ElasticWorkerNotReadyException;
import org.eclipse.jifa.server.domain.security.JifaAuthenticationToken;
import org.eclipse.jifa.server.enums.Role;
import org.eclipse.jifa.server.service.AnalysisApiService;
import org.eclipse.jifa.server.util.ControllerUtil;
Expand All @@ -31,6 +30,7 @@
import org.springframework.messaging.simp.stomp.StompHeaders;
import org.springframework.messaging.support.MessageHeaderAccessor;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
Expand Down Expand Up @@ -63,8 +63,8 @@ public AnalysisApiStompController(AnalysisApiService apiService) {
Message<byte[]> message) {
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
assert accessor != null;
JifaAuthenticationToken token = (JifaAuthenticationToken) accessor.getUser();
SecurityContextHolder.getContext().setAuthentication(token != null ? token : ANONYMOUS);
Authentication auth = (Authentication) accessor.getUser();
SecurityContextHolder.getContext().setAuthentication(auth != null ? auth : ANONYMOUS);

try {
MimeType mimeType = ControllerUtil.checkMimeTypeForStompMessage(contentType);
Expand Down

0 comments on commit 0bc00fb

Please sign in to comment.