Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SINTEF-9012_SINDIT20 /src /sindit /api /authentication_endpoints.py
| from sindit.api.api import app | |
| from typing import Annotated | |
| from fastapi import Depends, HTTPException | |
| from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm | |
| from sindit.authentication.models import User, Token | |
| from sindit.initialize_kg_connectors import sindit_kg_connector | |
| from sindit.initialize_authentication import authService, workspaceService | |
| oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") | |
| async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]) -> User: | |
| return authService.verify_token(token) | |
| async def get_current_active_user( | |
| current_user: Annotated[User, Depends(get_current_user)], | |
| ): | |
| if current_user.disabled: | |
| raise HTTPException(status_code=400, detail="Inactive user") | |
| current_workspace = workspaceService.get_current_workspace(current_user) | |
| sindit_kg_connector.set_graph_uri(current_workspace.uri.strip()) | |
| return current_user | |
| async def login_for_access_token( | |
| form_data: Annotated[OAuth2PasswordRequestForm, Depends()], | |
| ) -> Token: | |
| access_token = authService.create_access_token( | |
| username=form_data.username, password=form_data.password | |
| ) | |
| return access_token | |
| async def read_users_me( | |
| current_user: Annotated[User, Depends(get_current_active_user)], | |
| ): | |
| return current_user | |
Xet Storage Details
- Size:
- 1.41 kB
- Xet hash:
- fe0c3ce3723eb74461f2eae977e6a2655ffcceb7a50b3f3016d2e91de3405506
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.