Repository navigation
Add the Cognito tenant registration endpoint and allow /subscriptions as exchange target - #686
Merged
Merged
Conversation
… as exchange target Aviate registers the tenants it creates in Kill Bill in Kaui, and opens the subscription form, through the /getting_started/* endpoints of the managed overlay. Provide both natively so that the overlay can be removed once Aviate uses the Cognito endpoints. * POST /sso/cognito/tenants (alias /sso/aviate/tenants): registers a Kill Bill tenant in kaui_tenants and allows the user on it. Same Cognito token + Kill Bill login (basic or bearer) as the exchange, but no session for the browser and no tenant required. Kaui checks with Kill Bill that tenantKey/tenantSecret are valid for kbTenantId before storing the secret. 201 created, 200 already registered (the user is allowed on it), 400, 401, 403, 409. * /subscriptions (and its sub-paths) is an allowed target of the exchange, to keep landing on /subscriptions/new?account_id=...&product_category=BASE. * The common part of the two controllers (CSRF rule, error handling) is in Kaui::SsoCognito::BaseController. The existing exchange and session_expired behavior is unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #685 (Kaui side of the Aviate getting started migration; Aviate side: killbill/aviate#1288).
Why
Aviate registers the tenants it creates in Kill Bill in Kaui, and opens the subscription form, through the
/getting_started/*endpoints of themanagedoverlay. Kaui provides both natively here, so the overlay can be removed once Aviate uses the Cognito endpoints. The overlay itself is untouched: the new routes do not overlap with/getting_started/*, so this can be released with #684 without any change inmanaged.Changes
POST /sso/cognito/tenants(alias/sso/aviate/tenants, same convention as the exchange): registers a Kill Bill tenant inkaui_tenantsand allows the user on it (Kaui::SsoCognito::TenantsController).authenticate_kb_user_without_session!ofKaui::KbCognitoAuthenticatable: no Warden session for the browser, no tenant required (the exchange's bearer mode requires an already known tenant, which is what this call creates).name,tenantKey,tenantSecret,kbTenantId. Responses:201registered,200already registered (the user is allowed on it, so a retry is safe),400missing parameter,401token or Kill Bill credentials,403rejected by Kill Bill,409name used by another tenant,404Cognito not configured. Same body as the overlay on success./subscriptions(and sub-paths) added to the exchangeALLOWED_TARGETS, to keep landing on/subscriptions/new?account_id=...&product_category=BASE.Kaui::SsoCognito::BaseControllerholds what the two controllers share (CSRF rule for requests without a bearer token, error handling).exchangeandsession_expiredbehave as before (the 404 when Cognito is not configured still applies toexchangeonly).Differences with the overlay's
getting_started/tenantstenantKey/tenantSecretare valid and belong tokbTenantId(the same call as the tenant creation of the admin screens,Kaui::AdminTenant.find_by_api_key) before storing the secret. Without it, any user with a valid Cognito token could register, or squat the name of, any tenant. Please review: it relies on the user being allowed to read the tenant in Kill Bill.200and allows the user on it (the overlay answers409and does not). A name used by another tenant still answers409.Tests
test/functional/kaui/sso_cognito/tenants_controller_test.rb(15 tests): routes and alias, 404, token errors, basic and bearer success, no session, required parameters, Kill Bill rejections, mismatching id, idempotency and access for a second user, name conflict, CSRF.sso_cognito_controller_test.rb(18 tests) still passes, with a new case for the/subscriptionstarget (fails without the change).🤖 Generated with Claude Code