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

feat: security requirements override #4018

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

tofran
Copy link
Contributor

@tofran tofran commented Feb 19, 2025

Closes #4016
This started as a fix to the issue above, but after thorough consideration this needs a feature which I called security_override.

With security_override you can override OpenAPI's security requirements passed via security in any layer of your application (app, router, route).

Refer to the included docstrings for more information.

@tofran tofran requested review from a team as code owners February 19, 2025 20:53
@github-actions github-actions bot added area/openapi This PR involves changes to the OpenAPI schema area/private-api This PR involves changes to the privatized API size: small type/bug pr/external Triage Required 🏥 This requires triage labels Feb 19, 2025
Copy link

codecov bot commented Feb 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.35%. Comparing base (27a5b1d) to head (f8b366a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4018   +/-   ##
=======================================
  Coverage   98.35%   98.35%           
=======================================
  Files         347      347           
  Lines       15783    15786    +3     
  Branches     1745     1746    +1     
=======================================
+ Hits        15523    15526    +3     
  Misses        124      124           
  Partials      136      136           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tofran tofran changed the title fix: allow empty security requirements feat: allow empty security requirements Feb 24, 2025
Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/4018

…fran/litestar into fix-allow-empty-security-requirements
@provinzkraut
Copy link
Member

@tofran There seem to be some test failures. Can you address those?

@tofran
Copy link
Contributor Author

tofran commented Feb 25, 2025

@provinzkraut

Looks like linting is failing in the upstream. It started failing by updating the branch based on main.

tests/unit/test_openapi/test_security_schemes.py:48: error: X | Y syntax for unions requires Python 3.10  [syntax]
tests/unit/test_openapi/test_security_schemes.py:51: error: Untyped decorator makes function "route_security_not_specified" untyped  [misc]
tests/unit/test_openapi/test_security_schemes.py:54: error: Untyped decorator makes function "route_with_security" untyped  [misc]
tests/unit/test_openapi/test_security_schemes.py:57: error: Untyped decorator makes function "route_with_security_override" untyped  [misc]
tests/unit/test_openapi/test_security_schemes.py:60: error: Untyped decorator makes function "route_with_empty_security" untyped  [misc]
tests/unit/test_openapi/test_security_schemes.py:63: error: Untyped decorator makes function "route_with_empty_security_override" untyped 

Maybe I can make a separate PR to addrress this.

@tofran tofran changed the title feat: allow empty security requirements feat: security requirements override Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/controller area/openapi This PR involves changes to the OpenAPI schema area/private-api This PR involves changes to the privatized API area/router pr/external size: small Triage Required 🏥 This requires triage type/feat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: routes and routers cannot override OpenAPI security requirement
2 participants