diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 399b012..74d33f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: @@ -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 diff --git a/fastapi_oauth20/__init__.py b/fastapi_oauth20/__init__.py index 9b246ac..d1ea7b6 100644 --- a/fastapi_oauth20/__init__.py +++ b/fastapi_oauth20/__init__.py @@ -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' diff --git a/fastapi_oauth20/integrations/fastapi.py b/fastapi_oauth20/integrations/fastapi.py index 4e23e57..630431b 100644 --- a/fastapi_oauth20/integrations/fastapi.py +++ b/fastapi_oauth20/integrations/fastapi.py @@ -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, @@ -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 diff --git a/pdm.lock b/pdm.lock index 55d1f4b..f3b38ab 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev", "lint"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:7ea94b4a905c3ab9894b7e3c242aacc6227cf36ad2f36b916a863dcba8159b5e" +content_hash = "sha256:c5e746d41a9dd3a70635241016b6916a1326e08ef609cdc4bb03c2a9140cdea6" [[metadata.targets]] requires_python = ">=3.10" @@ -451,33 +451,6 @@ files = [ {file = "respx-0.22.0.tar.gz", hash = "sha256:3c8924caa2a50bd71aefc07aa812f2466ff489f1848c96e954a5362d17095d91"}, ] -[[package]] -name = "ruff" -version = "0.9.10" -requires_python = ">=3.7" -summary = "An extremely fast Python linter and code formatter, written in Rust." -groups = ["lint"] -files = [ - {file = "ruff-0.9.10-py3-none-linux_armv6l.whl", hash = "sha256:eb4d25532cfd9fe461acc83498361ec2e2252795b4f40b17e80692814329e42d"}, - {file = "ruff-0.9.10-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:188a6638dab1aa9bb6228a7302387b2c9954e455fb25d6b4470cb0641d16759d"}, - {file = "ruff-0.9.10-py3-none-macosx_11_0_arm64.whl", hash = "sha256:5284dcac6b9dbc2fcb71fdfc26a217b2ca4ede6ccd57476f52a587451ebe450d"}, - {file = "ruff-0.9.10-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:47678f39fa2a3da62724851107f438c8229a3470f533894b5568a39b40029c0c"}, - {file = "ruff-0.9.10-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:99713a6e2766b7a17147b309e8c915b32b07a25c9efd12ada79f217c9c778b3e"}, - {file = "ruff-0.9.10-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:524ee184d92f7c7304aa568e2db20f50c32d1d0caa235d8ddf10497566ea1a12"}, - {file = "ruff-0.9.10-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:df92aeac30af821f9acf819fc01b4afc3dfb829d2782884f8739fb52a8119a16"}, - {file = "ruff-0.9.10-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:de42e4edc296f520bb84954eb992a07a0ec5a02fecb834498415908469854a52"}, - {file = "ruff-0.9.10-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d257f95b65806104b6b1ffca0ea53f4ef98454036df65b1eda3693534813ecd1"}, - {file = "ruff-0.9.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b60dec7201c0b10d6d11be00e8f2dbb6f40ef1828ee75ed739923799513db24c"}, - {file = "ruff-0.9.10-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:d838b60007da7a39c046fcdd317293d10b845001f38bcb55ba766c3875b01e43"}, - {file = "ruff-0.9.10-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:ccaf903108b899beb8e09a63ffae5869057ab649c1e9231c05ae354ebc62066c"}, - {file = "ruff-0.9.10-py3-none-musllinux_1_2_i686.whl", hash = "sha256:f9567d135265d46e59d62dc60c0bfad10e9a6822e231f5b24032dba5a55be6b5"}, - {file = "ruff-0.9.10-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:5f202f0d93738c28a89f8ed9eaba01b7be339e5d8d642c994347eaa81c6d75b8"}, - {file = "ruff-0.9.10-py3-none-win32.whl", hash = "sha256:bfb834e87c916521ce46b1788fbb8484966e5113c02df216680102e9eb960029"}, - {file = "ruff-0.9.10-py3-none-win_amd64.whl", hash = "sha256:f2160eeef3031bf4b17df74e307d4c5fb689a6f3a26a2de3f7ef4044e3c484f1"}, - {file = "ruff-0.9.10-py3-none-win_arm64.whl", hash = "sha256:5fd804c0327a5e5ea26615550e706942f348b197d5475ff34c19733aee4b2e69"}, - {file = "ruff-0.9.10.tar.gz", hash = "sha256:9bacb735d7bada9cfb0f2c227d3658fc443d90a727b47f206fb33f52f3c0eac7"}, -] - [[package]] name = "sniffio" version = "1.3.1" diff --git a/pyproject.toml b/pyproject.toml index 7425dfb..7da49b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,6 @@ dev = [ "respx>=0.22.0", ] lint = [ - "ruff>=0.9.9", "pre-commit>=4.1.0", ]