Skip to content

ServicePrincipalAuthenticationFilter does not bypass CORS preflight (OPTIONS) requests #6162

Closed

Description

@alaguna95

Bug Report

Describe the Bug

This is the same underlying problem as #5968: ServicePrincipalAuthenticationFilter should bypass authentication for OPTIONS requests, just like JwtValidatorFilter already does.

ServicePrincipalAuthenticationFilter requires the claims request property to be present:

public void filter(ContainerRequestContext containerRequestContext) {
var claims = containerRequestContext.getProperty(REQUEST_PROPERTY_CLAIMS);
if (claims instanceof ClaimToken claimToken) {
var subject = claimToken.getStringClaim(SUBJECT);
var scope = claimToken.getStringClaim(SCOPE);

...whereas JwtValidatorFilter already has an explicit OPTIONS bypass:

@Override
public void filter(ContainerRequestContext requestContext) {
// OPTIONS requests don't have credentials - do not authenticate
if (!OPTIONS.equalsIgnoreCase(requestContext.getMethod())) {
var authHeader = requestContext.getHeaderString("Authorization");
if (authHeader == null || !authHeader.startsWith("Bearer ")) {

Expected Behavior

OPTIONS requests should bypass authentication in AuthenticationRequestFilter, so that CORS preflight requests succeed with a 2xx response.

Observed Behavior

A CORS preflight request receives a 401, which browsers report as:

Access to fetch at '...' from origin '...' has been blocked by CORS
policy: Response to preflight request doesn't pass access control
check: It does not have HTTP ok status.

Steps to Reproduce

  1. Enable the Management API OAuth2 authentication extension (edc.iam.oauth2.issuer, edc.iam.oauth2.jwks.url) together with CORS (edc.web.rest.cors.enabled=true).
  2. Send a CORS preflight request:
    curl -i 'http://localhost:8192/management/v5/participants/participant1/contractnegotiations/request' \
      -X OPTIONS \
      -H 'Origin: http://localhost:4201' \
      -H 'Access-Control-Request-Method: POST' \
      -H 'Access-Control-Request-Headers: authorization,content-type'
    

Response:
HTTP/1.1 401 Unauthorized
Access-Control-Allow-Origin: http://localhost:4201
Access-Control-Allow-Headers: Origin,Content-Type,Accept,Authorization,X-Api-Key
Access-Control-Allow-Methods: GET,POST,PUT,PATCH,DELETE,OPTIONS
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 0

Context Information

Used version: 1.0.0-RC4
OS: Linux

Possible Implementation

@Override
public void filter(ContainerRequestContext containerRequestContext) {
    if ("OPTIONS".equalsIgnoreCase(containerRequestContext.getMethod())) {
        return;
    }

    var claims = containerRequestContext.getProperty(REQUEST_PROPERTY_CLAIMS);
    // ... rest of the existing logic unchanged
}

Activity

  1. github-actions commented on Oct 26, 2026

    @github-actions
    Contributor

    Thanks for your contribution 🔥 We will take a look asap 🚀

  2. alaguna95 commented on Oct 27, 2026

    @alaguna95
    Author

    thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageall new issues awaiting classification

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions