-
Notifications
You must be signed in to change notification settings - Fork 0
Working OIDC auth #12
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
base: main
Are you sure you want to change the base?
Conversation
api/app/routes/oidc.py
Outdated
name=name, | ||
auth={"oidc_email": userinfo.get("email"), "oidc_sub": userinfo.get("sub")}, | ||
) | ||
db.add(entity) |
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.
this should use entity_service.create
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.
@copilot fix this
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.
@MikeWent copilot fixed this
@copilot fix all requested changes |
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 adds OpenID Connect (OIDC) authentication support to both the Flask UI and FastAPI backend, including a UI login link, proxy endpoints, dedicated API routes, configuration options, and documentation updates.
- Added an OIDC login button and proxy endpoints in the Flask auth controller
- Integrated Authlib-based OIDC routes in the FastAPI backend and registered a new router
- Updated environment examples, dependencies, and documentation for OIDC setup
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
ui/app/templates/auth/login.jinja2 | UI template: added “Login with OpenID Connect” button |
ui/app/controllers/auth.py | Flask auth controller: proxy to OIDC backend and cookie strip |
secrets.env.example | Included OIDC environment variables |
pyproject.toml | Added authlib dependency |
api/app/services/entity.py | New get_by_oidc_email method for entity lookup |
api/app/routes/token.py | Extended token endpoints for OIDC login and callback |
api/app/routes/oidc.py | New standalone OIDC authentication routes |
api/app/config.py | Config class extended with OIDC settings |
api/app/app.py | Registered OIDC router and session middleware |
README.md | Documented OIDC setup steps |
Comments suppressed due to low confidence (5)
api/app/routes/oidc.py:1
- New OIDC routes have been introduced but no tests were added. Consider adding unit or integration tests for the login and callback endpoints to verify correct behavior.
"""OIDC (OpenID Connect) authentication endpoints"""
pyproject.toml:8
- The Flask auth controller now imports
requests
, butrequests
is not listed inpyproject.toml
dependencies. Add e.g."requests>=2.28.0"
to ensure the package installs correctly.
"authlib>=1.6.0",
api/app/services/entity.py:68
func
is used forjson_extract
but not imported in this module. Addfrom sqlalchemy import func
to avoid a NameError at runtime.
.filter(func.json_extract(self.model.auth, "$.oidc_email") == email)
api/app/routes/token.py:41
request.url_for("oidc_callback")
may not resolve correctly because this endpoint is in the token router; userequest.url_for("token.oidc_callback")
orapp.url_path_for
with the correct router name.
redirect_uri = config.oidc_redirect_uri or str(request.url_for("oidc_callback"))
api/app/config.py:29
- The
Config
class usesfield(...)
but there's no import forfield
; add the correct import (from dataclasses import field
or the Pydantic equivalent) to avoid NameError.
oidc_client_id: str | None = field(default=getenv("REFINANCE_OIDC_CLIENT_ID", ""))
except Exception: | ||
pass |
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.
[nitpick] Catching the base Exception
is too broad and may hide unexpected errors; narrow this to specific exceptions (e.g., NotFoundError
) to improve error handling.
except Exception: | |
pass | |
except KeyError: # Replace with the specific exception(s) raised by get_by_name | |
# Log the error for visibility | |
print(f"Entity not found for email: {email}") # Replace with proper logging if available |
Copilot uses AI. Check for mistakes.
…-b17b-c18321367fa6 Replace direct DB operations with EntityService.create in OIDC callback
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
---|---|---|---|---|---|
18717092 | Triggered | Generic Password | b8967ac | authelia/config/users_database.yml | View secret |
18717093 | Triggered | Generic High Entropy Secret | b8967ac | authelia/config/configuration.yml | View secret |
18287481 | Triggered | Generic Password | 6aea789 | docker-compose.prod.yml | View secret |
18717094 | Triggered | Generic Password | b8967ac | authelia/config/users_database.yml | View secret |
18717095 | Triggered | Generic Private Key | b8967ac | authelia/config/configuration.yml | View secret |
18717096 | Triggered | Generic Private Key | b8967ac | authelia/https-localhost-proxy/certs/localhost.key | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
No description provided.