Skip to content

docs(OIDC): Document OIDC trust relationships and token exchange - #8045

Open
khvn26 wants to merge 6 commits into
mainfrom
feat/trust-relationships-docs
Open

docs(OIDC): Document OIDC trust relationships and token exchange#8045
khvn26 wants to merge 6 commits into
mainfrom
feat/trust-relationships-docs

Conversation

@khvn26

@khvn26 khvn26 commented Jul 19, 2026

Copy link
Copy Markdown
Member

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Closes #8040

In this PR, we add documentation for OIDC trust relationships.

We document trust relationships on the Admin API authentication page, and update the API Keys tab references to API Access. We also add the two new environment variables (TRUST_RELATIONSHIP_ACCESS_TOKEN_LIFETIME_SECONDS, OIDC_TOKEN_EXCHANGE_THROTTLE_RATE) to the self-hosting reference.

We also enhance the generated GitHub Actions workflow snippet to pass api-url to Flagsmith/setup-cli when the instance is not SaaS, as the base URL without /api/v1 — the shape the CLI expects.

Finally, we add an optional Workflow filename field to the GitHub trust relationship form so people can further narrow the claim if they need to.

The main piece can be previewed here: https://docs-git-feat-trust-relationships-docs-flagsmith.vercel.app/integrating-with-flagsmith/flagsmith-api-overview/admin-api/authentication#oidc-trust-relationships

How did you test this code?

Verified locally. Unit tests cover the workflow_ref pattern round-trip and GitHub form editability.

@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 18, 2026 9:22pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ignored Ignored Preview Aug 18, 2026 9:22pm
flagsmith-frontend-staging Ignored Ignored Preview Aug 18, 2026 9:22pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The changes expand authentication documentation for API Access, OIDC trust relationships, token exchange, expiry, revocation, and related environment variables. Integration and code-reference documentation now directs users to API Access for token and API key creation. Workflow setup now handles non-default API URLs. GitHub trust relationships now support optional workflow filenames and validated workflow references.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: 🟠 High · up to 18916

The change can broaden OIDC token-exchange permissions when a workflow filename contains wildcard syntax, allowing more workflows than intended to obtain access. It may also generate an incorrect API URL for some SaaS projects, causing setup failures; these issues should be addressed before merging.


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

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the docs Documentation updates label Jul 19, 2026
@khvn26 khvn26 changed the title docs: Document OIDC trust relationships and token exchange docs(OIDC): Document OIDC trust relationships and token exchange Jul 19, 2026
@khvn26
khvn26 force-pushed the feat/trust-relationships-docs branch from e1096f6 to 6ed63d3 Compare July 19, 2026 16:54
@khvn26
khvn26 force-pushed the feat/trust-relationships-docs branch from 6ed63d3 to 5b4d50d Compare July 19, 2026 17:00
@khvn26
khvn26 force-pushed the feat/trust-relationships-docs branch from 5b4d50d to 34a7c6f Compare July 19, 2026 17:08
@khvn26
khvn26 force-pushed the feat/trust-relationships-docs branch from 34a7c6f to 5a77e8b Compare July 19, 2026 17:23
@khvn26
khvn26 force-pushed the feat/trust-relationships-docs branch from 5a77e8b to 4a2ee03 Compare July 19, 2026 17:34
@khvn26
khvn26 force-pushed the feat/trust-relationships-docs branch from 4a2ee03 to 402c403 Compare July 20, 2026 10:19
@khvn26
khvn26 force-pushed the feat/trust-relationships-docs branch from 402c403 to c6ab4fe Compare July 20, 2026 10:23
@khvn26
khvn26 force-pushed the feat/trust-relationships-docs branch from c6ab4fe to 0c6bb29 Compare July 20, 2026 10:38
The generated GitHub Actions snippet assumed the CLI's default API URL,
so on self-hosted and staging instances the workflow silently targeted
SaaS. Pass api-url to Flagsmith/setup-cli whenever the dashboard's API
is not the SaaS default, as the base URL without /api/v1 — the shape
the CLI expects and appends to itself.

beep boop
@github-actions github-actions Bot added the front-end Issue related to the React Front End Dashboard label Aug 18, 2026
@github-actions github-actions Bot added docs Documentation updates and removed docs Documentation updates labels Aug 18, 2026
@khvn26
khvn26 marked this pull request as ready for review August 18, 2026 18:10
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-8045 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-8045 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-8045 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-8045 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8045 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-8045 Finished ✅ Results

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8a41b488-39d6-4b1f-9d75-2309918a14a8

📥 Commits

Reviewing files that changed from the base of the PR and between b7676e4 and f3b5de9.

📒 Files selected for processing (6)
  • docs/docs/deployment-self-hosting/core-configuration/environment-variables.md
  • docs/docs/integrating-with-flagsmith/flagsmith-api-overview/admin-api/authentication.md
  • docs/docs/managing-flags/code-references.md
  • docs/docs/third-party-integrations/backstage.md
  • docs/docs/third-party-integrations/ci-cd/terraform.md
  • frontend/web/components/pages/organisation-settings/tabs/trust-relationships/WorkflowSetupSnippet/WorkflowSetupSnippet.tsx

Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review.

Comment on lines +12 to +16
export const getNonDefaultApiUrl = (): string | undefined => {
// Project.api can be relative, e.g. /api/v1/
const resolved = new Request(Project.api).url
const baseUrl = resolved.replace(/\/api\/v1\/?$/, '')
return baseUrl === SAAS_API_URL ? undefined : baseUrl

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 8 '\bProject\.api\b|\bUtils\.isSaas\b|api\.flagsmith\.com' frontend/common frontend/web

Repository: Flagsmith/flagsmith

Length of output: 50376


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- target file ---'
cat -n frontend/web/components/pages/organisation-settings/tabs/trust-relationships/WorkflowSetupSnippet/WorkflowSetupSnippet.tsx

printf '%s\n' '--- constants and resolver references ---'
rg -n -C 12 'isCustomFlagsmithUrl|getSDKUrl|getFlagsmithSDKUrl|SAAS_API_URL|api\.flagsmith\.com|isSaas|Project\.api' \
  frontend/common/constants.ts frontend/common frontend/web/components/pages/organisation-settings/tabs/trust-relationships \
  | head -n 500

printf '%s\n' '--- targeted tests and package scripts ---'
rg -n -C 5 'WorkflowSetupSnippet|getNonDefaultApiUrl|isCustomFlagsmithUrl' frontend --glob '*test*' --glob '*spec*' --glob 'package.json'

Repository: Flagsmith/flagsmith

Length of output: 44420


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import re

target = Path("frontend/web/components/pages/organisation-settings/tabs/trust-relationships/WorkflowSetupSnippet/WorkflowSetupSnippet.tsx")
constants = Path("frontend/common/constants.ts")

def show(path, start, end):
    lines = path.read_text().splitlines()
    print(f"--- {path}:{start}-{end} ---")
    for number in range(start, min(end, len(lines)) + 1):
        print(f"{number:4}: {lines[number-1]}")

show(target, 1, 120)
show(constants, 1, 180)

print("--- exact Project.api assignments ---")
for path in Path("frontend").rglob("*"):
    if path.is_file() and path.suffix in {".js", ".jsx", ".ts", ".tsx"}:
        text = path.read_text(errors="ignore")
        if re.search(r"\bProject\.api\s*=", text):
            print(path)
            for i, line in enumerate(text.splitlines(), 1):
                if re.search(r"\bProject\.api\s*=", line):
                    print(f"{i:4}: {line}")
PY

Repository: Flagsmith/flagsmith

Length of output: 12651


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path

for path in Path("frontend").rglob("*"):
    if not path.is_file() or path.suffix not in {".js", ".jsx", ".ts", ".tsx"}:
        continue
    text = path.read_text(errors="ignore")
    if "Project.api" in text or "Project = " in text:
        for i, line in enumerate(text.splitlines(), 1):
            if "Project.api" in line or "Project =" in line:
                print(f"{path}:{i}:{line}")
PY

Repository: Flagsmith/flagsmith

Length of output: 16344


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- Project.api definitions ---'
for file in frontend/env/project_*.js; do
  printf '%s\n' "--- $file ---"
  cat -n "$file"
done

printf '%s\n' '--- Utils.isSaas implementation and usages ---'
rg -n -C 12 'isSaas\s*[:=]|\bisSaas\s*\(' frontend/common/utils frontend/common frontend/env frontend/web \
  | head -n 300

printf '%s\n' '--- exact API URL normalisation patterns ---'
rg -n -C 8 'new Request\(Project\.api\)|getFlagsmithSDKUrl\(\)|isCustomFlagsmithUrl\(\)' \
  frontend/web/components/pages/organisation-settings frontend/common/constants.ts frontend/common/utils \
  | head -n 300

Repository: Flagsmith/flagsmith

Length of output: 33050


🏁 Script executed:

#!/bin/bash
set -euo pipefail

node - <<'JS'
const pageOrigin = 'https://app.flagsmith.com'
const saasApiHost = 'https://api.flagsmith.com'
const apiValues = [
  '/api/v1/',
  'https://api.flagsmith.com/api/v1/',
  'https://selfhosted.example/api/v1/',
]

for (const projectApi of apiValues) {
  const resolved = new URL(projectApi, pageOrigin).href
  const baseUrl = resolved.replace(/\/api\/v1\/?$/, '')
  const currentResult = baseUrl === saasApiHost ? undefined : baseUrl
  const existingResolverResult =
    true || new URL(projectApi, pageOrigin).host === 'api.flagsmith.com'
      ? 'https://edge.api.flagsmith.com/api/v1/'
      : resolved

  console.log(JSON.stringify({
    projectApi,
    resolved,
    baseUrl,
    currentResult,
    existingResolverResult,
    shouldOmitForSaas: true,
  }))
}
JS

Repository: Flagsmith/flagsmith

Length of output: 905


Preserve the existing default SaaS detection.

When Utils.isSaas() is true, omit api-url even when Project.api is /api/v1/. The current check adds the web application's origin instead. Reuse the existing logic in frontend/common/constants.ts.

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-16 — run #19525 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  35.7 seconds
commit  1891631
info  🔄 Run: #19525 (attempt 1)

🗂️ Previous results
✅ oss · depot-ubuntu-latest-16 — run #19525 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  45.6 seconds
commit  1891631
info  🔄 Run: #19525 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19525 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  12.2 seconds
commit  1891631
info  🔄 Run: #19525 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #19525 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  39.5 seconds
commit  1891631
info  🔄 Run: #19525 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #19524 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  1 minute
commit  f3b5de9
info  🔄 Run: #19524 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #19524 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  43.3 seconds
commit  f3b5de9
info  🔄 Run: #19524 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19524 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  37.3 seconds
commit  f3b5de9
info  🔄 Run: #19524 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #19524 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  44.6 seconds
commit  f3b5de9
info  🔄 Run: #19524 (attempt 1)

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 49a3f0fb-062d-4e31-bd67-15b24d2245fb

📥 Commits

Reviewing files that changed from the base of the PR and between f3b5de9 and 1891631.

📒 Files selected for processing (5)
  • docs/docs/integrating-with-flagsmith/flagsmith-api-overview/admin-api/authentication.md
  • frontend/web/components/pages/organisation-settings/tabs/trust-relationships/GithubTrustRelationshipForm/GithubTrustRelationshipForm.tsx
  • frontend/web/components/pages/organisation-settings/tabs/trust-relationships/WorkflowSetupSnippet/WorkflowSetupSnippet.tsx
  • frontend/web/components/pages/organisation-settings/tabs/trust-relationships/__tests__/isGithubFormEditable.test.ts
  • frontend/web/components/pages/organisation-settings/tabs/trust-relationships/github.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment on lines +16 to +17
export const githubWorkflowRefPattern = (filename: string): string =>
`*/.github/workflows/${filename}@*`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Reject wildcard syntax in workflow filenames.

Line 17 inserts filename directly into a wildcard claim rule. If the value is *, the saved rule permits every workflow under .github/workflows/, not one workflow file. This can widen token-exchange access despite the form field describing a single filename.

Accept only literal workflow filenames, or escape all claim-matcher metacharacters before creating the pattern. Add cases for *, ?, brackets, path separators, and @.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation updates front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trust Relationships (OIDC)

3 participants