Skip to content

Commit

Permalink
chore: do not check audience for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Grodien committed Jun 17, 2024
1 parent abee059 commit 0e77d87
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class ApplicationConfiguration {
private final OAuth2ResourceServerProperties.Jwt properties;

// The audience is important because the JWT token is accepted only if the aud claim in the JWT token received by the server is the same as the client ID of the server.
@Value("${spring.security.oauth2.resourceserver.jwt.audience}")
String audience;
//@Value("${spring.security.oauth2.resourceserver.jwt.audience}")
String audience = null;

public ApplicationConfiguration(OAuth2ResourceServerProperties properties) {
this.properties = properties.getJwt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
}
)
// Disable csrf for now as it makes unauthenticated requests return 401/403
.csrf(AbstractHttpConfigurer::disable);
/*.oauth2ResourceServer((oauth2) ->
.csrf(AbstractHttpConfigurer::disable)
.oauth2ResourceServer((oauth2) ->
oauth2.jwt(withDefaults())
);*/
);
return http.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class CustomClaimController {
@GetMapping("requestToken")
String tokenRequest(Authentication authentication, String ru, String train, String role) {

String userId = (String) ((Jwt) authentication.getPrincipal()).getClaims().get("sub");
String userId = authentication.getName();
log.info("Received token request for {} with ru={} train={} role={}", userId, ru, train, role);

tokenClaimDataMap.put(userId, new Claims(ru, train, role));
Expand Down
2 changes: 1 addition & 1 deletion playground-backend/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spring:
jwt:
jwk-set-uri: https://login.microsoftonline.com/2cda5d11-f0ac-46b3-967d-af1b2e1bd01a/discovery/v2.0/keys
issuer-uri: https://login.microsoftonline.com/2cda5d11-f0ac-46b3-967d-af1b2e1bd01a/v2.0
audience: ${CLIENT_ID}
#audience: ${CLIENT_ID}

profiles:
active: ${STAGE:local}
Expand Down

0 comments on commit 0e77d87

Please sign in to comment.