Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support local auth #593

Merged
merged 4 commits into from
Dec 17, 2024
Merged

feat: support local auth #593

merged 4 commits into from
Dec 17, 2024

Conversation

RaoHai
Copy link
Contributor

@RaoHai RaoHai commented Dec 17, 2024

  • 支持通过环境变量跳过 auth0 登录。本地模拟登录

Copy link

vercel bot commented Dec 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
petercat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2024 10:09am

Copy link

Walkthrough

This pull request introduces support for local authentication by allowing the system to bypass Auth0 login through environment variables. It implements a local login simulation, providing an alternative authentication method when Auth0 is disabled.

Changes

Files Summary
server/.env.example, server/.env.local.example Added environment variables for local authentication configuration and option to skip Auth0 authorization.
server/auth/clients/__init__.py Introduced logic to select between Auth0 and local authentication clients based on environment variable.
server/auth/clients/auth0.py Implemented Auth0Client class for handling Auth0 authentication processes.
server/auth/clients/base.py Defined BaseAuthClient abstract class with methods for authentication processes.
server/auth/clients/local.py Implemented LocalClient class for handling local authentication processes.
server/auth/get_oauth_token.py Removed redundant OAuth token fetching logic.
server/auth/get_user_info.py Refactored to use get_auth_client for fetching user access tokens.
server/auth/rate_limit.py Updated rate limit verification to use user ID and authentication client.
server/auth/router.py Refactored authentication routes to use dependency injection for authentication clients.

}
async with httpx.AsyncClient() as client:
response = await client.post(url, data=data, headers=headers)
return response.json()['access_token']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure to handle potential exceptions when accessing response.json()['access_token'] to avoid runtime errors in case of unexpected response formats or errors.

Copy link
Contributor

@xingwanying xingwanying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@RaoHai RaoHai merged commit c0876b8 into main Dec 17, 2024
3 of 4 checks passed
@RaoHai RaoHai deleted the feat/support-locally-auth branch December 17, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants