Skip to content

Prepare for the release #15

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

Merged
merged 1 commit into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: check-toml

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.9.9
rev: v0.11.4
hooks:
- id: ruff
args:
Expand All @@ -15,6 +15,6 @@ repos:
- id: ruff-format

- repo: https://github.com/pdm-project/pdm
rev: 2.22.3
rev: 2.23.0
hooks:
- id: pdm-lock-check
2 changes: 1 addition & 1 deletion fastapi_oauth20/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
from .clients.oschina import OSChinaOAuth20 as OSChinaOAuth20
from .integrations.fastapi import FastAPIOAuth20 as FastAPIOAuth20

__version__ = '0.0.1a2'
__version__ = '0.0.1'
15 changes: 8 additions & 7 deletions fastapi_oauth20/integrations/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@ class FastAPIOAuth20:
def __init__(
self,
client: OAuth20Base,
*,
redirect_uri: str | None = None,
oauth2_callback_route_name: str | None = None,
redirect_route_name: str | None = None,
):
"""
OAuth2 authorization callback dependency injection

:param client: A client base on OAuth20Base.
:param redirect_uri: OAuth2 callback full URL.
:param oauth2_callback_route_name: OAuth2 callback route name, as defined by the route decorator 'name' parameter.
:param redirect_route_name: OAuth2 callback route name, as defined by the route decorator 'name' parameter.
"""
assert (redirect_uri is None and oauth2_callback_route_name is not None) or (
redirect_uri is not None and oauth2_callback_route_name is None
assert (redirect_uri is None and redirect_route_name is not None) or (
redirect_uri is not None and redirect_route_name is None
), 'FastAPIOAuth20 redirect_uri and oauth2_callback_route_name cannot be defined at the same time.'
self.client = client
self.redirect_uri = redirect_uri
self.oauth2_callback_route_name = oauth2_callback_route_name
self.redirect_route_name = redirect_route_name

async def __call__(
self,
Expand All @@ -59,8 +60,8 @@ async def __call__(
detail=error if error is not None else None,
)

if self.oauth2_callback_route_name:
redirect_url = str(request.url_for(self.oauth2_callback_route_name))
if self.redirect_route_name:
redirect_url = str(request.url_for(self.redirect_route_name))
else:
redirect_url = self.redirect_uri

Expand Down
29 changes: 1 addition & 28 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ dev = [
"respx>=0.22.0",
]
lint = [
"ruff>=0.9.9",
"pre-commit>=4.1.0",
]

Expand Down