Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Support multiple authorized parties in token validation#28

Open
mscc-sascha wants to merge 3 commits intoHawxy:mainfrom
mscc-sascha:main
Open

Support multiple authorized parties in token validation#28
mscc-sascha wants to merge 3 commits intoHawxy:mainfrom
mscc-sascha:main

Conversation

@mscc-sascha
Copy link

Description

Even when AuthorizedParty could be set to null or String.Empty, token validation always failed if multiple domains need to be supported as an authorized party.

Changes:

  • Support multiple authorized parties by implementing AuthorizedParties in ClerkAuthenticationOptions as an Array of Strings
  • Validate the if the claim value azp matches one of the supported authorized party

Sample

appsettings.json:

{
  "ClerkAuth": {
      "CLERK_JWT_AUDIENCE": ["http://localhost:5173", "http://api.dev.sample.com"], // <-- Add an array here
      "CLERK_JWT_ISSUER": "<your-clerk-issuer>",
      "CLERK_JWT_PUBLIC_KEY": "<your-public-key>",
      "CLERK_API_KEY": "<your-api-key>"
    }
}
// Adding Authentication
builder.Services.AddAuthentication(ClerkAuthenticationDefaults.AuthenticationScheme)
    .AddClerkAuthentication(x =>
    {
        x.Authority = builder.Configuration["ClerkAuth:CLERK_JWT_ISSUER"];
        x.AuthorizedParties = builder.Configuration.GetSection("ClerkAuth:CLERK_JWT_AUDIENCE").Get<List<string>>();
    });

@Hawxy
Copy link
Owner

Hawxy commented Dec 14, 2025

This is a breaking change, could you obsolete the original rather than removing it entirely?

@mscc-sascha
Copy link
Author

@Hawxy good catch, implemented the change!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants