Skip to content

Unable to determine OAuth flow in ScopeRepositoryInterface #1486

@sgoranov

Description

@sgoranov

The current ScopeRepositoryInterface does not expose any context about the OAuth2 grant/flow (e.g., authorization_code, client_credentials, refresh_token) when resolving or validating scopes.

namespace League\OAuth2\Server\Repositories;

interface ScopeRepositoryInterface extends RepositoryInterface
{
    public function getScopeEntityByIdentifier($identifier);
}

This makes it impossible to:

  • Restrict or validate scopes per flow
  • Return different scope entities depending on the flow

Suggestion

It could be beneficial to extend getScopeEntityByIdentifier() to accept additional context parameters, such as:

  • $grantType or $flow: (e.g. "client_credentials", "authorization_code")
  • Optionally, client or user context (if applicable)

This enhancement would enable more granular and secure scope validation.

Example Issue

In Client Credentials Flow, there is no end-user authentication - only the client itself is authenticated.
For security and compliance reasons, the openid scope must not be allowed in this flow. However, with the current interface, it’s not possible to reject openid only for client_credentials.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions