Skip to content

Commit

Permalink
v0.6.0
Browse files Browse the repository at this point in the history
auth with Bearer token
  • Loading branch information
SCHWMAX committed Nov 11, 2024
1 parent fece223 commit 3417540
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
sha$${{ github.sha }}
sha$${{ env.SHORT_COMMIT }}
date$${{ env.CURRENT_DATE }}
v0.5.2
v0.6.0
- name: Login to Docker Hub
uses: docker/login-action@v3
Expand Down
8 changes: 4 additions & 4 deletions utils_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
ACCESS_TOKENS = [ACCESS_TOKENS] if isinstance(ACCESS_TOKENS, str) else ACCESS_TOKENS

# Create a security scheme for checking access tokens
security_scheme = HTTPBearer()
auth_scheme = HTTPBearer()

# Function to check access tokens
async def check_access_token(token: Optional[str] = None):
if (len(ACCESS_TOKENS) > 0) and (token not in ACCESS_TOKENS):
async def check_access_token(token: Optional[str] = Depends(auth_scheme)):
if (len(ACCESS_TOKENS) > 0) and (token.credentials not in ACCESS_TOKENS):
raise HTTPException(status_code=401, detail="Invalid access token")


AccessToken: Optional[str] = Depends(check_access_token)
AccessToken: Optional[str] = Depends(check_access_token) if len(ACCESS_TOKENS) > 0 else None


def default_fastapi_setup(
Expand Down

0 comments on commit 3417540

Please sign in to comment.