mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-15 03:04:27 +08:00
* Fix #36: fix token url in auto doc * Define OAuth scheme in authentication base with default /users/login tokenUrl * Allow to override it through contructor argument of auth class * Fix test coverage of BaseAuthentication
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
from typing import Callable
|
||||
|
||||
from fastapi import HTTPException
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
from starlette import status
|
||||
from starlette.responses import Response
|
||||
|
||||
@ -15,8 +16,20 @@ class BaseAuthentication:
|
||||
Base adapter for generating and decoding authentication tokens.
|
||||
|
||||
Provides dependency injectors to get current active/superuser user.
|
||||
|
||||
:param scheme: Optional authentication scheme for OpenAPI.
|
||||
Defaults to `OAuth2PasswordBearer(tokenUrl="/users/login")`.
|
||||
Override it if your login route lives somewhere else.
|
||||
"""
|
||||
|
||||
scheme: OAuth2PasswordBearer
|
||||
|
||||
def __init__(self, scheme: OAuth2PasswordBearer = None):
|
||||
if scheme is None:
|
||||
self.scheme = OAuth2PasswordBearer(tokenUrl="/users/login")
|
||||
else:
|
||||
self.scheme = scheme
|
||||
|
||||
async def get_login_response(self, user: BaseUserDB, response: Response):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
Reference in New Issue
Block a user