]> git.ipfire.org Git - pbs.git/commitdiff
API: Automatically set a default value for the auth token type
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 16 Jun 2025 16:57:05 +0000 (16:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 16 Jun 2025 16:57:05 +0000 (16:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/api/auth.py

index 3bd8eb59ba1679e1e3eff3f7803f4b4c639026d0..0cc0dfef6f708723cf4f85ac87b531974d25d0d6 100644 (file)
@@ -44,7 +44,7 @@ REFRESH_TOKEN_EXPIRY_TIME = datetime.timedelta(days=7)
 
 class AuthResponse(pydantic.BaseModel):
        # Token Type
-       type: str
+       type: str = "Bearer"
 
        # Access Token
        access_token: str
@@ -103,8 +103,4 @@ async def auth_user(credentials: fastapi.security.OAuth2PasswordRequestForm =
                type="refresh", expires_after=REFRESH_TOKEN_EXPIRY_TIME)
 
        # Send the response
-       return AuthResponse(
-               type          = "Bearer",
-               access_token  = access_token,
-               refresh_token = refresh_token,
-       )
+       return AuthResponse(access_token=access_token, refresh_token=refresh_token)