Skip to content

Add selection-based tenant resolver and tenant selection page flow with single-tenant auto-select - #46

Merged
einari merged 4 commits into
mainfrom
copilot/add-tenant-resolver-selection-screen
May 26, 2026
Merged

Add selection-based tenant resolver and tenant selection page flow with single-tenant auto-select#46
einari merged 4 commits into
mainfrom
copilot/add-tenant-resolver-selection-screen

Conversation

Copilot AI commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a selection-based tenant resolver with an overridable tenant selection page flow, and now auto-selects the tenant when the endpoint returns exactly one option.

Added

  • New Selection tenant resolution strategy and typed SelectionOptions with configurable TenantsEndpoint
  • New TenantSelectionMiddleware that:
    • fetches selectable tenants from the configured endpoint
    • writes .cratis-tenants for page rendering
    • serves select-tenant.html when no tenant is selected
    • handles /.cratis/select-tenant?tenantId=...&returnUrl=... and writes .cratis-tenant
    • auto-selects and persists tenant when exactly one tenant is returned, skipping selector UI
  • New built-in overridable page: select-tenant.html
  • New docs page: Documentation/configuration/tenant-selection.md
  • New specs for selection strategy and tenant-selection middleware behavior, including single-tenant auto-select

Changed

  • Extended well-known constants:
    • cookie names (.cratis-tenants, .cratis-tenant)
    • page name (select-tenant.html)
    • path (/.cratis/select-tenant)
  • Registered selection strategy in tenancy DI and options binding
  • Updated tenant resolver to support Selection as direct tenant-id resolution
  • Updated configuration docs/toc to include tenant selection and page override guidance
  • Updated tenant-selection docs flow to describe single-tenant auto-selection behavior

Fixed

  • Prevented open-redirect risk in tenant selection callback by enforcing local relative return URLs before redirecting

Removed

  • None

Security

  • Hardened tenant selection redirect path handling to reject non-local return targets

Deprecated

  • None
{
  "Cratis": {
    "AuthProxy": {
      "TenantResolutions": [
        {
          "Strategy": "Selection",
          "Options": {
            "TenantsEndpoint": "https://platform.example.com/api/tenants/selectable"
          }
        }
      ]
    }
  }
}

Copilot AI linked an issue May 26, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add tenant resolver based on selection screen Add selection-based tenant resolver and tenant selection page flow May 26, 2026
Copilot finished work on behalf of einari May 26, 2026 04:24
Copilot AI requested a review from einari May 26, 2026 04:24
@einari

einari commented May 26, 2026

Copy link
Copy Markdown
Collaborator

@copilot if there is only one tenant in the list, use that and don’t show selector

Copilot AI commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot if there is only one tenant in the list, use that and don’t show selector

Implemented in f5e73a3. When tenant selection returns exactly one tenant, AuthProxy now sets .cratis-tenant and redirects back to the original URL instead of showing select-tenant.html. Added spec coverage for this behavior.

Copilot AI changed the title Add selection-based tenant resolver and tenant selection page flow Add selection-based tenant resolver and tenant selection page flow with single-tenant auto-select May 26, 2026
Copilot finished work on behalf of einari May 26, 2026 05:28
@einari einari added the minor label May 26, 2026
@einari
einari marked this pull request as ready for review May 26, 2026 11:50
@einari
einari merged commit 9ada512 into main May 26, 2026
@einari
einari deleted the copilot/add-tenant-resolver-selection-screen branch May 26, 2026 11:50
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.

Selection tenant resolver

2 participants