Skip to content

Commit

Permalink
Get allowed origins from cors property
Browse files Browse the repository at this point in the history
  • Loading branch information
iyourshaw committed Feb 16, 2024
1 parent 07f72fc commit 771776d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
package us.dot.its.jpo.ode.api.auth;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

//import org.keycloak.adapters.KeycloakDeploymentBuilder;
//import org.keycloak.adapters.rotation.AdapterTokenVerifier;
//import org.keycloak.adapters.springboot.KeycloakSpringBootProperties;
//import org.keycloak.common.VerificationException;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.ServerHttpRequest;
Expand All @@ -20,13 +13,12 @@
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.HandshakeInterceptor;

import lombok.RequiredArgsConstructor;
import java.util.List;
import java.util.Map;

@RequiredArgsConstructor
public class StompHandshakeInterceptor implements HandshakeInterceptor {

//private final KeycloakSpringBootProperties configuration;

private final OAuth2TokenValidator<Jwt> defaultTokenValidator;
private final JwtDecoder jwtDecoder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

import lombok.RequiredArgsConstructor;
import us.dot.its.jpo.ode.api.ConflictMonitorApiProperties;
import us.dot.its.jpo.ode.api.auth.StompHandshakeInterceptor;

@Configuration
Expand All @@ -21,6 +22,7 @@ public class StompConfig implements WebSocketMessageBrokerConfigurer {

private final OAuth2TokenValidator<Jwt> defaultTokenValidator;
private final JwtDecoder jwtDecoder;
private final ConflictMonitorApiProperties properties;

@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
Expand All @@ -32,6 +34,6 @@ public void configureMessageBroker(MessageBrokerRegistry config) {
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/stomp")
.addInterceptors(new StompHandshakeInterceptor(defaultTokenValidator, jwtDecoder))
.setAllowedOrigins("*");
.setAllowedOrigins(properties.getCors());
}
}

0 comments on commit 771776d

Please sign in to comment.