Skip to content

Conversation

cofob
Copy link
Contributor

@cofob cofob commented Jun 29, 2025

No description provided.

@cofob cofob requested a review from MikeWent June 30, 2025 12:08
name=name,
auth={"oidc_email": userinfo.get("email"), "oidc_sub": userinfo.get("sub")},
)
db.add(entity)
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@copilot fix this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MikeWent copilot fixed this

@cofob
Copy link
Contributor Author

cofob commented Jul 3, 2025

@copilot fix all requested changes

@cofob cofob requested a review from Copilot July 3, 2025 15:53
Copy link

@Copilot Copilot AI left a 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, but requests is not listed in pyproject.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 for json_extract but not imported in this module. Add from 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; use request.url_for("token.oidc_callback") or app.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 uses field(...) but there's no import for field; 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", ""))

Comment on lines +66 to +67
except Exception:
pass
Copy link
Preview

Copilot AI Jul 3, 2025

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.

Suggested change
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.

Copilot AI and others added 7 commits July 5, 2025 00:34
…-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>
Copy link

gitguardian bot commented Jul 22, 2025

⚠️ GitGuardian has uncovered 6 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
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
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. 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


🦉 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.

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.

3 participants