apexauthlib 0.1.2__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {apexauthlib-0.1.2 → apexauthlib-0.1.4}/PKG-INFO +2 -2
- {apexauthlib-0.1.2 → apexauthlib-0.1.4}/apexauthlib/entities/auth.py +6 -0
- {apexauthlib-0.1.2 → apexauthlib-0.1.4}/apexauthlib/fastapi/auth.py +22 -1
- {apexauthlib-0.1.2 → apexauthlib-0.1.4}/apexauthlib/integration/api.py +24 -0
- {apexauthlib-0.1.2 → apexauthlib-0.1.4}/pyproject.toml +2 -2
- {apexauthlib-0.1.2 → apexauthlib-0.1.4}/LICENSE +0 -0
- {apexauthlib-0.1.2 → apexauthlib-0.1.4}/README.md +0 -0
- {apexauthlib-0.1.2 → apexauthlib-0.1.4}/apexauthlib/__init__.py +0 -0
- {apexauthlib-0.1.2 → apexauthlib-0.1.4}/apexauthlib/entities/__init__.py +0 -0
- {apexauthlib-0.1.2 → apexauthlib-0.1.4}/apexauthlib/fastapi/__init__.py +0 -0
- {apexauthlib-0.1.2 → apexauthlib-0.1.4}/apexauthlib/integration/__init__.py +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: apexauthlib
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: Apex authorization library for services
|
|
5
5
|
Author: Apex Dev
|
|
6
6
|
Author-email: dev@apex.ge
|
|
7
|
-
Requires-Python: >=3.
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.12
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.13
|
|
@@ -7,10 +7,11 @@ from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
|
|
|
7
7
|
from starlette import status
|
|
8
8
|
|
|
9
9
|
from apexauthlib.entities import User
|
|
10
|
-
from apexauthlib.integration.api import AuthApiProvider
|
|
10
|
+
from apexauthlib.integration.api import AuthApiProvider, AuthCodeApi
|
|
11
11
|
|
|
12
12
|
auth_api = APIRouter(tags=["Auth"])
|
|
13
13
|
AuthApiProviderDependable = Annotated[AuthApiProvider[Any], inject("auth")]
|
|
14
|
+
AuthCodeApiDependable = Annotated[AuthCodeApi, inject("auth_code")]
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
def oauth2() -> OAuth2PasswordBearer:
|
|
@@ -90,3 +91,23 @@ def login(
|
|
|
90
91
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
91
92
|
detail="Incorrect username or password",
|
|
92
93
|
)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@auth_api.post(
|
|
97
|
+
"/login/code",
|
|
98
|
+
status_code=200,
|
|
99
|
+
response_model=TokenResponse,
|
|
100
|
+
)
|
|
101
|
+
def login_code(
|
|
102
|
+
code: str,
|
|
103
|
+
auth_code: AuthCodeApiDependable,
|
|
104
|
+
) -> TokenResponse:
|
|
105
|
+
try:
|
|
106
|
+
return TokenResponse(
|
|
107
|
+
access_token=auth_code.token_for(code),
|
|
108
|
+
)
|
|
109
|
+
except Exception:
|
|
110
|
+
raise HTTPException(
|
|
111
|
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
112
|
+
detail="Incorrect username or password",
|
|
113
|
+
)
|
|
@@ -71,3 +71,27 @@ class AuthApi(Generic[ItemT]):
|
|
|
71
71
|
)
|
|
72
72
|
|
|
73
73
|
return self.formatter.load(JsonDict(result["data"]["metadata"]["metadata"]))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@dataclass
|
|
77
|
+
class AuthCodeApi:
|
|
78
|
+
http: FluentHttp
|
|
79
|
+
client_id: str
|
|
80
|
+
client_secret: str
|
|
81
|
+
|
|
82
|
+
def token_for(self, code: str) -> str:
|
|
83
|
+
data = {
|
|
84
|
+
"code": code,
|
|
85
|
+
"client_id": self.client_id,
|
|
86
|
+
"client_secret": self.client_secret,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return str(
|
|
90
|
+
(
|
|
91
|
+
self.http.with_data(JsonDict(data))
|
|
92
|
+
.post()
|
|
93
|
+
.on_endpoint("/auth/oauth/token")
|
|
94
|
+
.on_failure(raises=RuntimeError)
|
|
95
|
+
.json()
|
|
96
|
+
)["access_token"]
|
|
97
|
+
)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "apexauthlib"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.4"
|
|
4
4
|
description = "Apex authorization library for services"
|
|
5
5
|
authors = [{ name = "Apex Dev", email = "dev@apex.ge" }]
|
|
6
6
|
readme = "README.md"
|
|
7
|
-
requires-python = ">=3.
|
|
7
|
+
requires-python = ">=3.11"
|
|
8
8
|
|
|
9
9
|
[tool.poetry.dependencies]
|
|
10
10
|
python = "^3.12"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|