Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False Positive for OIDC scopes in oas3-operation-security-defined #2566

Open
arosenb2 opened this issue Dec 19, 2023 · 1 comment
Open

False Positive for OIDC scopes in oas3-operation-security-defined #2566

arosenb2 opened this issue Dec 19, 2023 · 1 comment
Labels
OpenAPI Issues related to the OpenAPI ruleset t/bug Something isn't working

Comments

@arosenb2
Copy link

Describe the bug
When using a security schema of type openIdConnect, scopes are being checked for being defined in the flows, but per the OpenAPI Specification, when using openIdConnect, flows is not a valid property (it should only be used with OAuth2). Therefore, the check for isScopeDefined is invalid for openIdConnect.

To Reproduce

  1. Define an operation and apply a security schema of type openIdConnect.
  2. Include a valid scope from the well-known OIDC configuration as part of the security schema reference in the operation.
  3. Observe that oas3-operation-security-defined triggered, listing "the-scope-you-included" must be listed among scopes..

Expected behavior
Either OIDC provided scopes should be skipped as part of the isScopeDefined function when the security schema is of type openIdConnect. Additionally, checking for isScopeDefined could be considered a separate rule from oas3-operation-security-defined so it can be selectively ignored (suggested name: oas3-operationsecurity-scopes-defined).

Environment:

  • Library version: 6.11.0

Additional context
OpenAPI Specification - Security Schema Object,
Reference code in the ruleset

@strowk
Copy link

strowk commented Mar 5, 2024

Docs specifically say here :

Unlike OAuth 2.0, you do not need to list the available scopes in securitySchemes

I guess disabling it like this is the only option to avoid this for now:

extends: ["spectral:oas"]
overrides:
  - rules:
      # This rule is misfiring for OIDC
      # https://github.com/stoplightio/spectral/issues/2566
      oas3-operation-security-defined: "off"
    files:
      - "**/*.yaml"

@mnaumanali94 mnaumanali94 added t/bug Something isn't working OpenAPI Issues related to the OpenAPI ruleset labels May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OpenAPI Issues related to the OpenAPI ruleset t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants