-
Notifications
You must be signed in to change notification settings - Fork 2
update to fully disable auth #10
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the authentication mechanism to allow for disabling auth via the config.yaml file. The changes include:
- Modifying the security scheme initialization to conditionally disable auto error handling based on configuration.
- Adjusting the verify_auth dependency to manually raise an error when credentials are absent and auth is enabled.
# Create two security schemes: | ||
# 1. When auth is enabled: Required bearer token | ||
# 2. When auth is disabled: Optional bearer token | ||
security = HTTPBearer(auto_error=not get_settings().auth_disabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initializing the HTTPBearer instance at module import using get_settings() may capture stale configuration if the settings are updated at runtime. Consider instantiating HTTPBearer within a dependency function or another runtime context to ensure it uses the latest configuration.
security = HTTPBearer(auto_error=not get_settings().auth_disabled) | |
def get_security() -> HTTPBearer: | |
""" | |
Dynamically create an HTTPBearer instance based on the current configuration. | |
""" | |
return HTTPBearer(auto_error=not get_settings().auth_disabled) |
Copilot uses AI. Check for mistakes.
Oh, I didn't see this before I started fixing it myself today. |
Ok cool, will try it out. |
Ok, didn't get so far.
What does this mean? Sorry for the complete naivety, I've not worked with JWT's much at all, and have always struggled to get bearer tokens to work. I tried setting
And I'm also not sure what I do if authorization is not disabled? Like where am I supposed to get the token to then make the subsequent requests? thanks! |
I guess I should add more documentation around this. For your attempt, you were not meant to change secret_key. Keep it as is and just use the long cryptic string as Bearer token. That should work. "Authentication enabled" pretty much doesn't work right now as we didn't decide on an auth mechanism yet, so there's no endpoint for it yet. We could use OIDC or a custom HTTP Basic based implementation... |
Hey, not sure if this is the right approach, it's just what cursor gave to me. But if I just set the config.yaml file to 'auth_disabled: true' then it still was requiring auth. The readme said
you can disable authentication by editing the app/core/auth.py
, but I wasn't sure what to do to disable there. So perhaps this just could be a readme fix to explain how to disable the authentication there. But this seemed to work, and uses the config yaml file to disable it.