Skip to content

Conversation

@jokabuyasina
Copy link

@jokabuyasina jokabuyasina commented Jan 7, 2026

Description

This PR adds comprehensive documentation and utility scripts for SSO setup, deployment, and testing.

This is PR #5 of 5 in the SSO feature split (documentation and utilities).

Summary by CodeRabbit

  • Documentation

    • Added comprehensive SSO setup guide with vendor-specific configurations (Okta, Azure AD, Google Workspace), domain management, and security best practices
    • Added production deployment guide covering prerequisites, environment configuration, monitoring, disaster recovery, and rollback procedures
    • Added local testing guide for SSO functionality with end-to-end testing steps and troubleshooting
  • Chores

    • Added helper scripts for SAML authentication configuration and SSO route validation

✏️ Tip: You can customize this high-level summary in your review settings.

Consolidates 12 incremental SSO migrations (20251224022658 through 20260106000000) into a single comprehensive migration.

Schema includes:
- Tables: org_saml_connections, saml_domain_mappings, sso_audit_logs
- Functions: check_org_sso_configured, lookup_sso_provider_*, auto_join_*
- Triggers: auto_join_sso_user_trigger, check_sso_domain_on_signup_trigger
- RLS policies for all tables
- Indexes for performance
- Single SSO per org constraint (UNIQUE org_id, entity_id)
- auto_join_enabled flag for controlling enrollment

This is PR #1 of the SSO feature split (schema foundation only).
No backend endpoints, no frontend, no tests included yet.

Related: feature/sso-saml-authentication
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2026

Warning

Rate limit exceeded

@jokabuyasina has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 6 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b04497b and 41ceff6.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (100)
  • .github/workflows/build_and_deploy.yml
  • .github/workflows/tests.yml
  • .gitsecret/paths/mapping.cfg
  • .opencode/worktree-session-state.json
  • .typos.toml
  • AGENTS.md
  • docs/MOCK_SSO_TESTING.md
  • docs/sso-production.md
  • docs/sso-setup.md
  • eslint.config.js
  • internal/AuthKey_8P7Y3V99PJ.p8.secret
  • internal/CICD.mobileprovision.secret
  • internal/Certificates.p12.secret
  • internal/Certificates_p12.p12.secret
  • internal/capgo-394818-68ad1517d330.json.secret
  • internal/cloudflare/.env.local.secret
  • internal/cloudflare/.env.preprod.secret
  • internal/cloudflare/.env.prod.secret
  • internal/forgr-key.jks.base64.secret
  • internal/forgr-key.jks.secret
  • internal/how-to-deploy.md.secret
  • internal/supabase/.env.local.secret
  • messages/de.json
  • messages/es.json
  • messages/fr.json
  • messages/hi.json
  • messages/id.json
  • messages/it.json
  • messages/ja.json
  • messages/ko.json
  • messages/pl.json
  • messages/pt-br.json
  • messages/ru.json
  • messages/tr.json
  • messages/vi.json
  • messages/zh-cn.json
  • package.json
  • restart-auth-with-saml-v2.sh
  • restart-auth-with-saml.sh
  • src/auto-imports.d.ts
  • src/components/WebhookDeliveryLog.vue
  • src/components/WebhookForm.vue
  • src/pages/app/[package].channel.[channel].devices.vue
  • src/pages/settings/organization/Webhooks.vue
  • src/services/posthog.ts
  • src/stores/organization.ts
  • src/stores/webhooks.ts
  • src/types/supabase.types.ts
  • supabase/functions/_backend/files/preview.ts
  • supabase/functions/_backend/private/accept_invitation.ts
  • supabase/functions/_backend/private/create_device.ts
  • supabase/functions/_backend/private/credits.ts
  • supabase/functions/_backend/private/delete_failed_version.ts
  • supabase/functions/_backend/private/download_link.ts
  • supabase/functions/_backend/private/invite_new_user_to_org.ts
  • supabase/functions/_backend/private/set_org_email.ts
  • supabase/functions/_backend/private/stripe_checkout.ts
  • supabase/functions/_backend/private/stripe_portal.ts
  • supabase/functions/_backend/private/upload_link.ts
  • supabase/functions/_backend/private/validate_password_compliance.ts
  • supabase/functions/_backend/public/app/delete.ts
  • supabase/functions/_backend/public/build/cancel.ts
  • supabase/functions/_backend/public/build/request.ts
  • supabase/functions/_backend/public/build/start.ts
  • supabase/functions/_backend/public/build/status.ts
  • supabase/functions/_backend/public/build/upload.ts
  • supabase/functions/_backend/public/organization/members/delete.ts
  • supabase/functions/_backend/public/organization/members/get.ts
  • supabase/functions/_backend/public/organization/post.ts
  • supabase/functions/_backend/public/statistics/index.ts
  • supabase/functions/_backend/public/webhooks/delete.ts
  • supabase/functions/_backend/public/webhooks/deliveries.ts
  • supabase/functions/_backend/public/webhooks/get.ts
  • supabase/functions/_backend/public/webhooks/post.ts
  • supabase/functions/_backend/public/webhooks/put.ts
  • supabase/functions/_backend/public/webhooks/test.ts
  • supabase/functions/_backend/triggers/logsnag_insights.ts
  • supabase/functions/_backend/utils/discord.ts
  • supabase/functions/_backend/utils/hono_middleware.ts
  • supabase/functions/_backend/utils/stripe.ts
  • supabase/functions/_backend/utils/stripe_event.ts
  • supabase/functions/_backend/utils/supabase.ts
  • supabase/functions/_backend/utils/supabase.types.ts
  • supabase/functions/_backend/utils/utils.ts
  • supabase/functions/_backend/utils/version.ts
  • supabase/functions/_backend/utils/webhook.ts
  • supabase/migrations/20260104120000_revoke_process_function_queue_public_access.sql
  • supabase/migrations/20260105150626_fix_is_allowed_capgkey_hashed_apikeys.sql
  • supabase/migrations/20260107000000_add_anon_role_to_webhooks_rls.sql
  • supabase/migrations/20260107210800_sso_saml_complete.sql
  • supabase/seed.sql
  • supabase/tests/07_auth_functions.sql
  • tests/app.test.ts
  • tests/cli-hashed-apikey.test.ts
  • tests/cli-sdk-utils.ts
  • tests/hashed-apikey-rls.test.ts
  • tests/private-error-cases.test.ts
  • tests/sso-management.test.ts
  • tests/test-utils.ts
  • verify-sso-routes.sh
📝 Walkthrough

Walkthrough

Introduces comprehensive SSO documentation and operational tooling for Okta SAML integration. Adds setup guides, production deployment procedures, mock testing workflows, and helper scripts for managing SAML-enabled authentication containers and verifying route registrations.

Changes

Cohort / File(s) Summary
SSO Documentation
docs/sso-setup.md, docs/sso-production.md, docs/MOCK_SSO_TESTING.md
Comprehensive guides covering vendor-specific setup (Okta, Azure AD, Google Workspace), domain management, production deployment with monitoring/backup procedures, disaster recovery, compliance frameworks, and local mock testing workflows for SAML integration.
Auth Container Restart Scripts
restart-auth-with-saml.sh, restart-auth-with-saml-v2.sh
Bash scripts to restart authentication containers with SAML enabled, handling base64 encoding of certificates/keys and extensive GOTRUE environment configuration including JWT, MFA, rate limits, and SAML-specific settings.
SSO Route Verification
verify-sso-routes.sh
Validation script that inspects TypeScript files for SSO route registrations and outputs expected private routes (configure, update, remove, status, test).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 SSO springs forth with care and thought,
Setup guides and scripts we've brought—
Mock testing hops through SAML flows,
While Docker restarts as the auth dance goes!
From dev to prod, the paths now glow. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Feature/sso 05 docs' is vague and doesn't clearly convey what the PR accomplishes; it relies on PR numbering and branch naming rather than describing the actual changes. Use a more descriptive title like 'Add comprehensive SSO documentation and utility scripts' to clearly communicate the primary change at a glance.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The PR description provides a clear summary of the changes (comprehensive documentation and utility scripts for SSO) and correctly identifies it as PR #5 of a split feature series, meeting the template's summary requirement.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link
Contributor

@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

🤖 Fix all issues with AI agents
In @restart-auth-with-saml-v2.sh:
- Line 28: Add a clear DEVELOPMENT-ONLY banner and shebang at the top (e.g.,
"#!/bin/bash" and a prominent warning comment) and replace the hardcoded
GOTRUE_DB_DATABASE_URL and GOTRUE_JWT_SECRET values by sourcing them from
environment variables with safe development-only fallbacks; specifically, change
the inline literal
"GOTRUE_DB_DATABASE_URL=postgresql://supabase_auth_admin:postgres@..." and the
placeholder JWT secret to use "${GOTRUE_DB_DATABASE_URL:-<dev-default>}" and
"${GOTRUE_JWT_SECRET:-<dev-default>}" patterns, and ensure you include "set -e"
to fail fast—document that the defaults are for local/dev only and must not be
used in production.
- Around line 8-14: The temp base64 files /tmp/saml-key-b64.txt and
/tmp/saml-cert-b64.txt leak sensitive keys; remove them by either avoiding
intermediate files (populate SAML_KEY_B64 and SAML_CERT_B64 directly via command
substitution from /tmp/saml-key-pkcs1.pem and /tmp/saml-cert.pem) or, if you
must keep the files, register a cleanup trap (e.g., trap on EXIT) to rm -f those
two temp files; update the script around the SAML_KEY_B64 and SAML_CERT_B64
assignments to implement one of these fixes and ensure no temporary base64 files
persist after the script exits.
🧹 Nitpick comments (8)
docs/MOCK_SSO_TESTING.md (1)

47-47: Consider adding blank lines around tables for markdown compliance.

Static analysis flagged missing blank lines around tables. While this doesn't affect functionality, adding blank lines improves markdown portability across different renderers.

📝 Proposed markdown formatting fix

For line 47 (before the table in Test Scenarios):

 ### Test 1: First-Time SSO User
+

Email: [email protected]


Similar adjustments for line 98 and other table locations.
</details>


Also applies to: 98-98

</blockquote></details>
<details>
<summary>docs/sso-production.md (1)</summary><blockquote>

`520-522`: **Consider formatting bare URLs as markdown links.**

Bare URLs in the Common Resources section could be formatted as proper markdown links for better portability.



<details>
<summary>📝 Proposed formatting</summary>

```diff
-- **Capgo Dashboard**: https://capgo.app
-- **Support Email**: [email protected]
-- **Status Page**: https://status.capgo.app
+- **Capgo Dashboard**: [https://capgo.app](https://capgo.app)
+- **Support Email**: [[email protected]](mailto:[email protected])
+- **Status Page**: [https://status.capgo.app](https://status.capgo.app)
verify-sso-routes.sh (1)

1-17: Consider adding error handling and output validation.

The script could be more robust by:

  1. Checking if target files exist before grepping
  2. Validating that all expected routes were found
  3. Exiting with appropriate status codes for CI/CD integration
♻️ Enhanced version with error handling
 #!/bin/bash
+set -e
+
 # Verify SSO routes are correctly registered
+EXIT_CODE=0
+
+check_routes() {
+  local file=$1
+  local label=$2
+  
+  echo "Checking $label routes..."
+  if [ ! -f "$file" ]; then
+    echo "ERROR: File not found: $file"
+    EXIT_CODE=1
+    return
+  fi
+  
+  grep -n "route('/sso/" "$file" || {
+    echo "WARNING: No SSO routes found in $file"
+    EXIT_CODE=1
+  }
+  echo ""
+}
 
-echo "Checking Supabase function routes..."
-grep -n "route('/sso/" supabase/functions/private/index.ts
-
-echo ""
-echo "Checking Cloudflare worker routes..."
-grep -n "route('/sso/" cloudflare_workers/api/index.ts
+check_routes "supabase/functions/private/index.ts" "Supabase function"
+check_routes "cloudflare_workers/api/index.ts" "Cloudflare worker"
 
-echo ""
 echo "Expected routes:"
 echo "  /private/sso/configure (POST)"
 echo "  /private/sso/update (PUT)"
 echo "  /private/sso/remove (DELETE)"
 echo "  /private/sso/status (GET)"
 echo "  /private/sso/test (POST)"
+
+exit $EXIT_CODE
docs/sso-setup.md (2)

93-93: Consider hyphenating "Sign on URL" for consistency.

Static analysis suggests using "Sign-on URL" (with hyphen) for grammatical consistency, as this is a compound modifier.

-- **Sign on URL**: `https://capgo.app/login`
+- **Sign-on URL**: `https://capgo.app/login`

520-522: Consider formatting bare URLs as markdown links.

Same formatting suggestion as in sso-production.md for better markdown portability.

📝 Proposed formatting
-- **Capgo Dashboard**: https://capgo.app
-- **Support Email**: [email protected]
-- **Status Page**: https://status.capgo.app
+- **Capgo Dashboard**: [https://capgo.app](https://capgo.app)
+- **Support Email**: [[email protected]](mailto:[email protected])
+- **Status Page**: [https://status.capgo.app](https://status.capgo.app)
restart-auth-with-saml.sh (1)

9-10: Consider validating source file existence before encoding.

The script assumes SAML key files exist in /tmp before base64 encoding. Adding validation would provide clearer error messages if files are missing.

♻️ Add file existence checks
+# Validate SAML key files exist
+if [ ! -f /tmp/saml-key-pkcs1.pem ]; then
+  echo "ERROR: /tmp/saml-key-pkcs1.pem not found"
+  echo "Generate SAML keys first: openssl genrsa -out /tmp/saml-key-pkcs1.pem 2048"
+  exit 1
+fi
+
+if [ ! -f /tmp/saml-cert.pem ]; then
+  echo "ERROR: /tmp/saml-cert.pem not found"
+  echo "Generate certificate first: openssl req -new -x509 -key /tmp/saml-key-pkcs1.pem -out /tmp/saml-cert.pem -days 365"
+  exit 1
+fi
+
 # Create base64 encoded keys in files (single line)
 cat /tmp/saml-key-pkcs1.pem | base64 | tr -d '\n' > /tmp/saml-key-b64.txt
 cat /tmp/saml-cert.pem | base64 | tr -d '\n' > /tmp/saml-cert-b64.txt
restart-auth-with-saml-v2.sh (2)

1-6: Consider validating required files before proceeding.

The cleanup logic is sound, but the script assumes SAML PEM files exist in /tmp. Consider adding validation before processing:

# Validate required files exist
for file in /tmp/saml-key-pkcs1.pem /tmp/saml-cert.pem; do
  if [[ ! -f "$file" ]]; then
    echo "❌ Required file not found: $file"
    exit 1
  fi
done

This will provide clearer error messages if prerequisites are missing.


91-97: Use more robust container verification.

The grep approach can match partial container names. Use Docker's native filtering for more precise verification:

♻️ Proposed refactor
-if docker ps | grep -q supabase_auth_capgo-app; then
+if docker ps --filter "name=^/supabase_auth_capgo-app$" --format '{{.Names}}' | grep -q .; then
   echo "✅ Auth container running with SAML enabled!"
   docker logs supabase_auth_capgo-app 2>&1 | tail -5
 else
   echo "❌ Auth container failed to start"
   docker logs supabase_auth_capgo-app 2>&1 | tail -10
   exit 1
 fi

Alternatively, use docker inspect:

if docker inspect supabase_auth_capgo-app --format '{{.State.Running}}' 2>/dev/null | grep -q true; then
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70bc57d and b04497b.

📒 Files selected for processing (8)
  • docs/MOCK_SSO_TESTING.md
  • docs/sso-production.md
  • docs/sso-setup.md
  • restart-auth-with-saml-v2.sh
  • restart-auth-with-saml.sh
  • src/types/supabase.types.ts
  • supabase/functions/_backend/utils/supabase.types.ts
  • verify-sso-routes.sh
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-12-23T02:53:12.055Z
Learnt from: CR
Repo: Cap-go/capgo PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-23T02:53:12.055Z
Learning: Test accounts available after `supabase db reset`: `testcapgo.app` / `testtest` (demo user) and `admincapgo.app` / `adminadmin` (admin user)

Applied to files:

  • docs/sso-setup.md
📚 Learning: 2025-12-27T03:51:23.575Z
Learnt from: CR
Repo: Cap-go/capgo PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T03:51:23.575Z
Learning: Investigate failing Supabase tests by reviewing Docker container logs and relevant service logs before retrying

Applied to files:

  • restart-auth-with-saml-v2.sh
📚 Learning: 2025-12-23T02:53:12.055Z
Learnt from: CR
Repo: Cap-go/capgo PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-23T02:53:12.055Z
Learning: Applies to supabase/functions/_backend/**/*.{ts,js} : Backend code must be placed in `supabase/functions/_backend/` as shared code deployed to Cloudflare Workers (API/Plugin/Files workers), Supabase Edge Functions, and other platforms

Applied to files:

  • verify-sso-routes.sh
🪛 Gitleaks (8.30.0)
docs/sso-production.md

[high] 24-24: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 27-27: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 LanguageTool
docs/sso-setup.md

[grammar] ~93-~93: Use a hyphen to join words.
Context: ...pabase.co/auth/v1/sso/saml/acs- **Sign on URL**:https://capgo.app/login` ###...

(QB_NEW_EN_HYPHEN)

🪛 markdownlint-cli2 (0.18.1)
docs/sso-setup.md

47-47: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


98-98: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


520-520: Bare URL used

(MD034, no-bare-urls)


521-521: Bare URL used

(MD034, no-bare-urls)


522-522: Bare URL used

(MD034, no-bare-urls)

docs/MOCK_SSO_TESTING.md

47-47: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


98-98: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)

docs/sso-production.md

47-47: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


98-98: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


520-520: Bare URL used

(MD034, no-bare-urls)


521-521: Bare URL used

(MD034, no-bare-urls)


522-522: Bare URL used

(MD034, no-bare-urls)

🔇 Additional comments (8)
docs/MOCK_SSO_TESTING.md (1)

1-210: LGTM! Comprehensive mock SSO testing guide.

The documentation provides excellent coverage of the mock SSO testing workflow, including prerequisites, step-by-step testing procedures, multiple test scenarios, debugging guidance, and a clear comparison between production and mock flows. The structure is logical and the content is thorough.

docs/sso-production.md (2)

1-574: LGTM! Excellent production deployment guide.

This is a comprehensive and well-structured production deployment guide covering all critical aspects: prerequisites, security configuration, monitoring, disaster recovery, cost management, compliance, and rollback procedures. The inclusion of concrete examples, SQL queries, and checklists makes this highly actionable.


24-24: Note: Example JWT tokens are appropriate for documentation.

Static analysis flagged these as potential secrets, but they are clearly example/placeholder values for documentation purposes (the "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." pattern is a standard JWT header). This is the correct way to document environment variable configuration.

Also applies to: 27-27

docs/sso-setup.md (1)

1-534: LGTM! Comprehensive and well-organized SSO setup guide.

This documentation provides excellent coverage of SSO setup across multiple identity providers (Okta, Azure AD, Google Workspace), domain management, security best practices, troubleshooting, monitoring, and API reference. The step-by-step instructions with specific configuration details make this highly valuable for implementation.

restart-auth-with-saml.sh (1)

1-83: LGTM! Well-structured local development script.

This script effectively restarts the authentication container with SAML enabled for local testing. The use of set -e for error handling, graceful cleanup of existing containers, and comprehensive environment configuration is appropriate for a development utility.

The hardcoded secrets (JWT token, database credentials) are appropriate for local development and align with Supabase's local development defaults.

verify-sso-routes.sh (1)

5-9: The target file paths are valid, but the script searches for non-existent SSO routes.

Both supabase/functions/private/index.ts and cloudflare_workers/api/index.ts exist and correctly follow the project's architecture by importing from supabase/functions/_backend/. However, the SSO routes listed in the expected routes (e.g., /private/sso/configure, /private/sso/update, /private/sso/remove, /private/sso/status, /private/sso/test) are not currently implemented in the codebase. This script will always return no matches unless these routes are added to the backend code.

restart-auth-with-saml-v2.sh (2)

86-86: The pinned version v2.184.0 is actually newer than the latest documented GoTRUE release (v2.182.1 as of Nov 5, 2025), and no known security vulnerabilities or CVEs were found for this version. SAML 2.0 support is confirmed in GoTRUE. The version choice appears sound unless this is a pre-release build; verify the release channel with the team if needed.

Likely an incorrect or invalid review comment.


81-83: GoTRUE doesn't support file-based SAML key configuration; remove the suggested alternative.

GoTRUE only accepts base64-encoded SAML keys via GOTRUE_SAML_PRIVATE_KEY and GOTRUE_SAML_SIGNING_CERT environment variables—the _FILE suffix pattern is not supported. Since this is a local development/testing script, using environment variables with base64-encoded keys is the correct and documented approach. For production deployments, use Docker secrets or Kubernetes secrets management to securely populate these environment variables rather than file-based paths.

Likely an incorrect or invalid review comment.

Comment on lines +8 to +14
# Create base64 single-line encoded keys
cat /tmp/saml-key-pkcs1.pem | base64 | tr -d '\n' > /tmp/saml-key-b64.txt
cat /tmp/saml-cert.pem | base64 | tr -d '\n' > /tmp/saml-cert-b64.txt

# Read into variables
SAML_KEY_B64=$(cat /tmp/saml-key-b64.txt)
SAML_CERT_B64=$(cat /tmp/saml-cert-b64.txt)
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Clean up temporary base64 files.

The temporary files /tmp/saml-key-b64.txt and /tmp/saml-cert-b64.txt containing sensitive SAML credentials are never removed, creating a security exposure.

♻️ Proposed refactor to eliminate intermediate files
-# Create base64 single-line encoded keys
-cat /tmp/saml-key-pkcs1.pem | base64 | tr -d '\n' > /tmp/saml-key-b64.txt
-cat /tmp/saml-cert.pem | base64 | tr -d '\n' > /tmp/saml-cert-b64.txt
-
-# Read into variables
-SAML_KEY_B64=$(cat /tmp/saml-key-b64.txt)
-SAML_CERT_B64=$(cat /tmp/saml-cert-b64.txt)
+# Create base64 single-line encoded keys directly
+SAML_KEY_B64=$(cat /tmp/saml-key-pkcs1.pem | base64 | tr -d '\n')
+SAML_CERT_B64=$(cat /tmp/saml-cert.pem | base64 | tr -d '\n')

Alternatively, if you retain the intermediate files, add cleanup:

trap 'rm -f /tmp/saml-key-b64.txt /tmp/saml-cert-b64.txt' EXIT
🤖 Prompt for AI Agents
In @restart-auth-with-saml-v2.sh around lines 8 - 14, The temp base64 files
/tmp/saml-key-b64.txt and /tmp/saml-cert-b64.txt leak sensitive keys; remove
them by either avoiding intermediate files (populate SAML_KEY_B64 and
SAML_CERT_B64 directly via command substitution from /tmp/saml-key-pkcs1.pem and
/tmp/saml-cert.pem) or, if you must keep the files, register a cleanup trap
(e.g., trap on EXIT) to rm -f those two temp files; update the script around the
SAML_KEY_B64 and SAML_CERT_B64 assignments to implement one of these fixes and
ensure no temporary base64 files persist after the script exits.

-e GOTRUE_API_HOST=0.0.0.0 \
-e GOTRUE_API_PORT=9999 \
-e GOTRUE_DB_DRIVER=postgres \
-e "GOTRUE_DB_DATABASE_URL=postgresql://supabase_auth_admin:postgres@supabase_db_capgo-app:5432/postgres" \
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Hardcoded credentials present a security risk.

The script contains hardcoded database credentials (supabase_auth_admin:postgres) and a placeholder JWT secret. While the localhost URLs suggest this is for development/testing, these credentials should be:

  1. Clearly documented as development-only in comments
  2. Sourced from environment variables or a secure configuration file for any non-local use
  3. Never used in production environments

Consider adding a prominent comment at the top of the script:

#!/bin/bash
# ⚠️  DEVELOPMENT/TESTING ONLY - Contains hardcoded credentials
# DO NOT use in production environments
set -e

Also applies to: 36-36

🤖 Prompt for AI Agents
In @restart-auth-with-saml-v2.sh at line 28, Add a clear DEVELOPMENT-ONLY banner
and shebang at the top (e.g., "#!/bin/bash" and a prominent warning comment) and
replace the hardcoded GOTRUE_DB_DATABASE_URL and GOTRUE_JWT_SECRET values by
sourcing them from environment variables with safe development-only fallbacks;
specifically, change the inline literal
"GOTRUE_DB_DATABASE_URL=postgresql://supabase_auth_admin:postgres@..." and the
placeholder JWT secret to use "${GOTRUE_DB_DATABASE_URL:-<dev-default>}" and
"${GOTRUE_JWT_SECRET:-<dev-default>}" patterns, and ensure you include "set -e"
to fail fast—document that the defaults are for local/dev only and must not be
used in production.

jokabuyasina and others added 27 commits January 7, 2026 22:42
…undefined

fix(migrations): remove redundant revoke on get_customer_counts for service_role
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* fix: make is_allowed_capgkey support hashed API keys

Update is_allowed_capgkey and get_user_id functions to support both plain-text and hashed API keys using find_apikey_by_value(). Add expiration checks to prevent expired keys from passing validation. Add comprehensive tests for hashed key validation.

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

Co-Authored-By: Claude Haiku 4.5 <[email protected]>

* refactor: use find_apikey_by_value RPC in checkKey

Refactor checkKey function to use the find_apikey_by_value SQL function instead of duplicating the hashing logic in JavaScript. This ensures consistent key lookup behavior between SQL functions and TypeScript code.

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

Co-Authored-By: Claude Haiku 4.5 <[email protected]>

* refactor: remove isSafeAlphanumeric check from checkKey

Remove the isSafeAlphanumeric validation as it's no longer needed for security. The RPC call to find_apikey_by_value uses parameterized queries, which prevents SQL injection regardless of input characters.

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

Co-Authored-By: Claude Haiku 4.5 <[email protected]>

* refactor: remove isSafeAlphanumeric function

Remove the isSafeAlphanumeric validation function as it's no longer needed. Both Supabase RPC calls and Drizzle ORM use parameterized queries which prevent SQL injection regardless of input characters.

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

Co-Authored-By: Claude Haiku 4.5 <[email protected]>

* refactor: use find_apikey_by_value in checkKeyPg

Refactor checkKeyPg to use the find_apikey_by_value SQL function instead of manually hashing and querying. This ensures consistent key lookup behavior between all code paths.

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

Co-Authored-By: Claude Haiku 4.5 <[email protected]>

* perf: optimize find_apikey_by_value to use single query

Replace sequential two-query approach with a single query using OR.
This reduces database round-trips and allows PostgreSQL to potentially
use index union optimization.

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

Co-Authored-By: Claude Haiku 4.5 <[email protected]>

* refactor: merge find_apikey_by_value optimization into main migration

Consolidate the find_apikey_by_value query optimization (single query
with OR instead of two sequential queries) into the original migration
file for cleaner PR history.

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

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* fix: add index signature to FindApikeyByValueResult type

Drizzle's execute method requires the generic type to satisfy
Record<string, unknown>, so added intersection with index signature.

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

Co-Authored-By: Claude Opus 4.5 <[email protected]>

---------

Co-authored-by: Claude Haiku 4.5 <[email protected]>
- Introduced new keys for allowing and helping with bundle previews in Japanese, Korean, Polish, Brazilian Portuguese, Russian, Turkish, Vietnamese, and Simplified Chinese.
- Added error messages for changing preview settings across all supported languages.
- Included success messages for changing preview settings in all relevant languages.
- Updated device names and other related strings to enhance user experience in the respective languages.
…oints

- Updated password compliance validation to use authenticated Supabase client.
- Refactored app deletion logic to utilize API key-based access for data queries.
- Modified build request handling to enforce RLS with API key authentication.
- Enhanced organization member management to ensure proper access control.
- Streamlined webhook operations to leverage API key authentication for data access.
- Improved statistics retrieval to support authenticated access based on user roles.
- Adjusted tests to ensure proper error handling and access control scenarios.
Add comprehensive test coverage for CLI operations using hashed API keys.
Tests verify that all core SDK operations (upload, list, channel management)
work correctly with hashed API keys stored as SHA-256 hashes in the database.

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

Co-authored-by: Claude Haiku 4.5 <[email protected]>
* security: remove passwords from all logs

Ensure passwords are never logged to Cloudflare, Supabase, or Discord by:
- Removing password field from cloudlog calls in accept_invitation and validate_password_compliance
- Sanitizing Discord alerts to completely remove password field and partially redact other sensitive fields

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <[email protected]>

* fix: move password redaction after validation to handle null body

Address PR feedback - if a client sends JSON null, destructuring before
validation throws TypeError (500) instead of returning 400. Move cloudlog
calls after safeParse validation to ensure body is valid before destructuring.

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <[email protected]>

* chore: remove deno.lock from commit

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <[email protected]>

---------

Co-authored-by: Claude Haiku 4.5 <[email protected]>
- Add Webhook type alias to webhooks store and Vue components
- Fix apikey.key null check in build/start.ts
The generateEncryptionKeysSDK() function was modifying the project's
capacitor.config.ts without cleanup. The SDK asynchronously writes the
public key to the config during key generation, which was leaving the
test environment dirty. Now we back up and restore the config in a
finally block to ensure clean state regardless of test outcome.

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

Co-authored-by: Claude Haiku 4.5 <[email protected]>
This adds a dynamic link to the Supabase dashboard for each Stripe customer, allowing easy navigation from Stripe to the customer's org record in Supabase. The link is parameterized with the SUPABASE_URL environment variable and supports both production and local Supabase instances.

🤖 Generated with Claude Code

Co-authored-by: Claude Haiku 4.5 <[email protected]>
- Refactored webhook GET, POST, and PUT functions to utilize the capgkey from the context instead of the API key for authenticated client access.
- Added new RLS policies to support anon role for webhooks and webhook deliveries, allowing API key-based authentication.
- Updated seed data to include dedicated users and API keys for testing, ensuring isolation between tests.
- Enhanced tests for CLI hashed API keys and RLS to prevent interference with other tests, using dedicated test data.
riderx and others added 8 commits January 7, 2026 23:49
Add comprehensive SSO documentation and helper scripts:

- SSO setup guide with configuration steps

- Production deployment guide

- Mock SSO testing guide

- Auth restart scripts for testing

- Route verification script

This is PR #5 of SSO split (docs and utilities).
Replace v_domain IS NULL OR v_domain = empty string checks with idiomatic NULLIF(v_domain, empty string) IS NULL pattern in:
- check_org_has_sso_for_domain
- lookup_sso_provider_by_domain
- lookup_sso_provider_for_email
- auto_join_user_to_orgs_by_email

This avoids direct empty string comparisons and treats empty strings as NULL
- Restore src/types/supabase.types.ts from bcb1d02
- Copy types to supabase/functions/_backend/utils/supabase.types.ts
- Fix Organization type inference with explicit GetOrgsV7 extraction
- Add type annotations to fix implicit any errors in organization.ts
- Fix globalThis.Deno typing in sso-management.test.ts
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 9, 2026

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.

5 participants