Pass tenant context (name/id) to JavaScript providers - #98
Merged
Conversation
Provider scripts (UserLoginProvider / UserValidationProvider) previously only
received the username/password. To let a provider target an external, multi-
tenant user service (e.g. Uitrusting, whose API is scoped by tenant id), expose
the tenant to the script as a nested 'tenant' object on the constructor argument:
constructor(credentials) {
const name = credentials.tenant.name;
const id = credentials.tenant.id; // Kubernetes CRD UID, null for file tenants
}
Adds JSInputTenant and threads it through all four provider call sites (login,
activate, password grant, refresh validation). The field is additive, so
existing provider scripts keep working.
Expose the tenant to provider scripts as { name, namespace } instead of
{ name, id }. CRD tenants are stored as "<namespace>/<name>"; the name is now
the bare tenant name and namespace is the Kubernetes namespace (nil for
file-based tenants).
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.
Summary
Tenant JavaScript providers (
UserLoginProvider/UserValidationProvider) previously received only the username/password. That is not enough to talk to an external, multi-tenant user service such as Uitrusting, whose API is scoped by tenant (e.g./tenants/{tenantId}/users). This PR exposes the tenant to the provider script.What changed
The constructor argument now carries a nested
tenantobject:JSInputTenant { name, id }—idis the Kubernetes CRD UID when the tenant is loaded from a CRD,nilfor file-based tenants (identify those byname).tenantadded toJSInputCredentialsandJSInputUsername.LoginController(interactive login),ActivateController(device grant), the password grant, andUserValidation(refresh-token re-validation).The field is additive — existing provider scripts that ignore
tenantkeep working unchanged.Tests
UserLoginTenantContextTest(new): a provider script readscredentials.tenant.name/.idand the values are asserted end-to-end; plusJSInputTenant(from:)mapping for Kubernetes vs. file tenant refs.JSInputParameterTestand the other provider tests for the new field (encode/decode/round-trip).Verification
swift buildclean; provider + controller suites 102/102 pass;./tooling.sh lint0 violations.