Skip to content

Bump and other fixes#161

Merged
eranco74 merged 1 commit intorh-ecosystem-edge:mainfrom
omertuc:bump
Aug 28, 2025
Merged

Bump and other fixes#161
eranco74 merged 1 commit intorh-ecosystem-edge:mainfrom
omertuc:bump

Conversation

@omertuc
Copy link
Member

@omertuc omertuc commented Aug 28, 2025

Summary by CodeRabbit

  • New Features

    • Added role-based access control via JWT role mapping and action-level permissions; health/metrics remain accessible for probes.
  • Chores

    • Updated base container image and exposed port 8080.
    • Mounted trusted CA bundle into the runtime for TLS compatibility.
    • Updated internal component reference to latest revision.
    • Models query helper now requires OCM_TOKEN and uses Bearer authentication.

@openshift-ci openshift-ci bot requested review from carbonin and keitwb August 28, 2025 07:54
@openshift-ci
Copy link

openshift-ci bot commented Aug 28, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: omertuc

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link

coderabbitai bot commented Aug 28, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Updates Containerfile base image digest and EXPOSE, mounts a CA bundle into the lightspeed-stack container, advances the lightspeed-stack submodule pointer, adds Authorization: Bearer ${OCM_TOKEN} to scripts/query.sh, and introduces JWT role_rules plus authorization access_rules in template.yaml.

Changes

Cohort / File(s) Summary
Container image update
Containerfile.assisted-chat
Bumped FROM image digest to sha256:f1ec2f3880b0...; updated digest comment; added EXPOSE 8080.
Pod volume mount
assisted-chat-pod.yaml
Added readOnly volumeMount mounting ca-bundle.pem from existing config volume into /etc/tls/ca-bundle.pem using subPath.
Submodule pointer
lightspeed-stack
Updated submodule commit reference from 3e2d883... to 691c83e....
Script authentication
scripts/query.sh
Added Authorization: Bearer ${OCM_TOKEN} header to the /v1/models curl call; now requires OCM_TOKEN to be set.
RBAC / JWT config
template.yaml
Added authentication.jwt_configuration.role_rules mapping to produce redhat_employee and an authorization block with access_rules (e.g., redhat_employee -> get_models, nobody restrictions, probes allowed for role *).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant C as Client (UI/Script)
  participant LS as Lightspeed Stack
  participant JWT as JWT Validator
  participant AuthZ as Authorization Engine

  U->>C: Request with JWT
  C->>LS: HTTP request + Authorization: Bearer <JWT>
  LS->>JWT: Validate token, extract claims
  JWT-->>LS: Claims (org_id, is_internal, realm roles)
  LS->>AuthZ: Apply role_rules → roles (e.g., redhat_employee)
  AuthZ-->>LS: Permit or deny per access_rules
  alt permitted
    LS-->>C: 200 OK + response
  else denied
    LS-->>C: 403 Forbidden
  end
Loading
sequenceDiagram
  autonumber
  participant Dev as Developer
  participant Script as scripts/query.sh
  participant API as /v1/models

  Dev->>Script: run get_available_models (OCM_TOKEN set)
  Script->>API: GET /v1/models with Authorization: Bearer ${OCM_TOKEN}
  alt valid token
    API-->>Script: 200 OK (models list)
  else missing/invalid token
    API-->>Script: 401/403 error
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • keitwb
  • carbonin
  • eranco74

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 776168b and fe45b11.

⛔ Files ignored due to path filters (1)
  • config/ca-bundle.pem is excluded by !**/*.pem
📒 Files selected for processing (5)
  • Containerfile.assisted-chat (1 hunks)
  • assisted-chat-pod.yaml (1 hunks)
  • lightspeed-stack (1 hunks)
  • scripts/query.sh (1 hunks)
  • template.yaml (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
Containerfile.assisted-chat (1)

7-7: EXPOSE port mismatch with deployment defaults.

Service defaults to 8090 in template.yaml; EXPOSE 8080 may confuse operators/tools. Align to 8090 (or expose both if needed).

Apply:

-EXPOSE 8080
+EXPOSE 8090
template.yaml (1)

178-192: Make authz intent explicit; remove confusing commented role block.

The currently uncommented actions are part of redhat_employee (good), but the surrounding comment implies they belong to role "*". Clarify to avoid regressions.

       authorization:
         access_rules:
           - role: redhat_employee
             actions:
-            - get_models
-          # Temporarily we only want redhat employees to be able to use the service,
-          # uncomment when we want to allow all authenticated users
-          # - role: "*"
-          #   actions:
-            - query
-            - streaming_query
-            - get_conversation
-            - list_conversations
-            - delete_conversation
-            - feedback
+            - get_models
+            - query
+            - streaming_query
+            - get_conversation
+            - list_conversations
+            - delete_conversation
+            - feedback
+          # To allow all authenticated users in the future, add:
+          # - role: "*"
+          #   actions: [get_models, query, streaming_query, get_conversation, list_conversations, delete_conversation, feedback]

Ensure LIGHTSPEED_SERVICE_AUTH_ENABLED is set to true in the target environment; otherwise these rules won’t be enforced.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f7705fc and 776168b.

⛔ Files ignored due to path filters (1)
  • config/ca-bundle.pem is excluded by !**/*.pem
📒 Files selected for processing (5)
  • Containerfile.assisted-chat (1 hunks)
  • assisted-chat-pod.yaml (1 hunks)
  • lightspeed-stack (1 hunks)
  • scripts/query.sh (1 hunks)
  • template.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Red Hat Konflux / assisted-chat-saas-main-on-pull-request
🔇 Additional comments (3)
lightspeed-stack (1)

1-1: Submodule bump to 691c83e: review auth changes & CI submodules

  • Changed files in lightspeed-stack: src/auth/jwk_token.py, src/authorization/resolvers.py — inspect for any breaking JWT/config/authz shifts.
  • Ensure your CI’s checkout step fetches submodules (e.g. GitHub Actions’ actions/checkout with submodules: true or equivalent) so the lightspeed-stack update is pulled in.
template.yaml (1)

168-176: Use JSON boolean true for is_internal; equals is the correct operator.

models/config.py defines JsonPathOperator = {"equals","contains","in"} and JwtRolesResolver uses direct equality (==) for EQUALS — a quoted "true" (string) will not match a JSON boolean claim.

Location: template.yaml (lines 168-176)

-            - jsonpath: "$.is_internal"
-              operator: "equals"
-              value: "true"
+            - jsonpath: "$.is_internal"
+              operator: "equals"
+              value: true
               roles: ["redhat_employee"]

Confirm JWT claim types: is_internal must be a JSON boolean; org_id claim type must match the elements in the in list (string vs number).

assisted-chat-pod.yaml (1)

41-44: LGTM—fixes local dev trust store mount.

Ensure ./config/ca-bundle.pem exists on the host; with subPath, missing file will fail container start.

Would you like a preflight script that checks presence/permissions of ./config/ca-bundle.pem before oc apply?

Comment on lines 29 to 31
get_available_models() {
curl --silent --show-error -X 'GET' "${BASE_URL}/v1/models" -H 'accept: application/json'
curl --silent --show-error -X 'GET' "${BASE_URL}/v1/models" -H 'accept: application/json' -H "Authorization: Bearer ${OCM_TOKEN}"
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Harden token handling and HTTP error checks for models call.

With set -u, ${OCM_TOKEN} unbound will abort; also no status handling here unlike other calls.

Apply:

 get_available_models() {
-    curl --silent --show-error -X 'GET' "${BASE_URL}/v1/models" -H 'accept: application/json' -H "Authorization: Bearer ${OCM_TOKEN}"
+    # Ensure token present (and fetch if not)
+    if [[ -z "${OCM_TOKEN:-}" ]]; then
+        if ! get_ocm_token; then
+            echo "Failed to get OCM token for models"
+            return 1
+        fi
+    fi
+    tmpfile=$(mktemp)
+    status=$(curl --silent --show-error --output "$tmpfile" --write-out "%{http_code}" \
+        -H 'accept: application/json' \
+        -H "Authorization: Bearer ${OCM_TOKEN}" \
+        "${BASE_URL}/v1/models")
+    body=$(cat "$tmpfile"); rm "$tmpfile"
+    if ! good_http_response "$status"; then
+        echo "Error: Failed to fetch models (HTTP $status)"
+        echo "Response: $body"
+        return 1
+    fi
+    echo "$body"
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
get_available_models() {
curl --silent --show-error -X 'GET' "${BASE_URL}/v1/models" -H 'accept: application/json'
curl --silent --show-error -X 'GET' "${BASE_URL}/v1/models" -H 'accept: application/json' -H "Authorization: Bearer ${OCM_TOKEN}"
}
get_available_models() {
# Ensure token present (and fetch if not)
if [[ -z "${OCM_TOKEN:-}" ]]; then
if ! get_ocm_token; then
echo "Failed to get OCM token for models"
return 1
fi
fi
tmpfile=$(mktemp)
status=$(curl --silent --show-error --output "$tmpfile" --write-out "%{http_code}" \
-H 'accept: application/json' \
-H "Authorization: Bearer ${OCM_TOKEN}" \
"${BASE_URL}/v1/models")
body=$(cat "$tmpfile"); rm "$tmpfile"
if ! good_http_response "$status"; then
echo "Error: Failed to fetch models (HTTP $status)"
echo "Response: $body"
return 1
fi
echo "$body"
}

- Bump lsc to dev-20250828-691c83e
- Fix annoying local dev /etc/tls/ca-bundle.pem issue
- Fix query.sh to use OCM token for model listing
- Bring back authz - taken from rh-ecosystem-edge#160
@eranco74 eranco74 merged commit 5bf47af into rh-ecosystem-edge:main Aug 28, 2025
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants