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

With multiple @Security() decorators, all secMethods run #1728

Open
3 of 4 tasks
douglasg14b opened this issue Dec 9, 2024 · 0 comments
Open
3 of 4 tasks

With multiple @Security() decorators, all secMethods run #1728

douglasg14b opened this issue Dec 9, 2024 · 0 comments

Comments

@douglasg14b
Copy link

douglasg14b commented Dec 9, 2024

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

When there are multiple @Security() decorators in use in an OR configuration, it's expected that these will operate in a early-break pattern. Where once one is accepted, we break early.

Additionally, a way to filter security methods by say the Authentication header type (ie. Bearer, Basic ...etc) could prevent floods of rejection metrics as each auth type is evaluated.

@Security('tsoa_auth', ['write:pets', 'read:pets'])
@Security('api_key')
@Get('OauthOrAPIkey')
public async GetWithOrSecurity(@Request() request: express.Request): Promise<any> {
}

Current Behavior

Each security method is ran, resulting in rejections that are not actually rejections.

Possible Solution

  1. Break early in OR scenarios, and don't execute additional security options
  2. Allow a filter to be applied, or provided, to the decorator for control over when each security method is ran
@douglasg14b douglasg14b changed the title With multiple @Security() decorators, all secMethods run With multiple @Security() decorators, all secMethods run Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant