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

Bug: AbstractSecurityConfig sets security for all paths, even those excluded #3013

Open
1 of 4 tasks
tuukkamustonen opened this issue Jan 22, 2024 · 0 comments
Open
1 of 4 tasks
Labels
area/openapi This PR involves changes to the OpenAPI schema Bug 🐛 This is something that is not working as expected Help Wanted 🆘 This is good for people to work on

Comments

@tuukkamustonen
Copy link
Contributor

tuukkamustonen commented Jan 22, 2024

Description

The AbstractSecurityConfig adds OpenAPI securityScheme and security entries to the generated spec, but it does so at the root level of the spec, instead of per endpoint.

That is fine, as long as you apply the logic for all endpoints. But it also allows you to exclude certain paths from processing, and yet the security spec will apply for those endpoints, too. That is because it gets defined at the root level of the OpenAPI spec, instead of per path.

A local security will overwrite the global one, but if there's an endpoint without authentication, the security should not be added to the root of the spec as there won't be a local security declaration.


Related thing is that the AbstractAuthenticationMiddleware does not add security or securityScheme to the OpenAPI spec at all. You would kinda expect that it does, similar to FastAPI's SecurityBase inheritors (e.g. https://fastapi.tiangolo.com/tutorial/security/simple-oauth2). You have to separately provide security= in decorators/routers. But that's another thing, I guess.

MCVE

N/A at this point but ping if unclear and I'll add.

Litestar Version

2.4.5

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@tuukkamustonen tuukkamustonen added the Bug 🐛 This is something that is not working as expected label Jan 22, 2024
@tuukkamustonen tuukkamustonen changed the title Bug: AbstractSecurityConfig sets security for all paths, even those excluded Bug: AbstractSecurityMiddleware sets security for all paths, even those excluded Mar 14, 2024
@tuukkamustonen tuukkamustonen changed the title Bug: AbstractSecurityMiddleware sets security for all paths, even those excluded Bug: AbstractAuthenticationMiddleware sets security for all paths, even those excluded Mar 14, 2024
@tuukkamustonen tuukkamustonen changed the title Bug: AbstractAuthenticationMiddleware sets security for all paths, even those excluded Bug: AbstractSecurityConfig sets security for all paths, even those excluded Mar 14, 2024
@peterschutt peterschutt added Help Wanted 🆘 This is good for people to work on area/openapi This PR involves changes to the OpenAPI schema labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/openapi This PR involves changes to the OpenAPI schema Bug 🐛 This is something that is not working as expected Help Wanted 🆘 This is good for people to work on
Projects
None yet
Development

No branches or pull requests

2 participants