#1066·Ocelot

Switching between a scope's matching strategies

Author: papugamichalCreated Nov 28, 2019Updated Jan 7, 2026
LabelsfeatureproposalAuthenticationAuthorizationAutumn'26
Old description outdated after January 2, 2025

Expected Behavior / New Feature

Allowed Scopes documentation says:

If you add scopes to AllowedScopes Ocelot will get all the user claims (from the token) of the type scope and make sure that the user has all of the scopes in the list.

This is a way to restrict access to a Route on a per scope basis.

ScopesAuthoriser.Authorize method: https://github.com/ThreeMammals/Ocelot/blob/35dbc9d633dc49fe8b5a1f6589ff9e2ec72bf07c/src/Ocelot/Authorization/ScopesAuthorizer.cs#L33

Example:

Token contains Scope: "A" Defined route AllowedScopes: "A", "B"

Ocelot should reject request to be fair with documentation.

Actual Behavior / Motivation for New Feature

Example

Token contains Scope: "A". Defined route AllowedScopes: "A", "B"

Ocelot allow to pass request, even when token do not contains all required scopes!

Change proposal

Change: var matchesScopes = routeAllowedScopes.Intersect(userScopes).ToList(); To: var matchesScopes = routeAllowedScopes.All(e => userScopes.Contains(e));

Or, change misleading information in documentation.

New Feature

To be written...