:wave: Could we request to add parameter for /v1/a...
# ask-a-descoper
e
đź‘‹ Could we request to add parameter for /v1/auth/tenant/select that would allow us to request a sessions token for a single tenant instead of a sessions token for all of them?
essentially we'd like to have two type tokens. refresh and session. of should contain your tenant list of ids and the other should be single tenant scoped like this
Copy code
{
  "amr": "[list-of-strings-of-identifiers-used]",
  "drn": "[string-of-type-of-token]",
  "exp": "[timestamp-of-expiration-time]",
  "iat": "[timestamp-of-issued-time]",
  "iss": "https://api.descope.com/xxxxx",
  "sub": "[string-of-user-id]",
  "dct": "string-tenant-id",
  "roles": "[list-of-strings] //tenant level",
  "permissions": "[list-of-strings] //tenant level",
  "tenant_list": "{{[tenants_list_of_ids]}}"
}
is that possible?
g
@Ereli - If you use JWT templates, you can set the scope of the access token. Is this what you are asking for?
e
we have too many tenants, permissions and roles on the token and it's bigger than 4k, making it difficult to store as cookie due to browser limits we need to still switch between tenants use refresh token, but get sessions tokens that only contains permissions and roles for single tenant.
the default descope token isn't good because it includes all tenants all the time. leading to tokens that are too big to be stored as a cookie.
g
Understood. And if you set it to "Current Tenant", will that not work for you?
e
Current tenant, no tenant reference
would work, but we'd still need to a way to get the list of the tenants for a user so the user can trigger a sessions switch between tenants.
g
@Chris Carper can we please assign someone to assist here more closely?
c
@Ereli - how are you doing the tenant select switching? Are you using a tenant select widget within a flow or specifically calling the
/v1/auth/tenant/select
API endpoint? The widget within an embedded flow would already load the applicable tenants for that user and allow them to switch between them. @Bhagyesh Parna @Nick Rodriguez - do you recall me having an example of this recently? It'd basically be an embedded flow that calls load user, then has a small screen with the select tenant widget. @Ereli - is it moreso the number of tenants on the JWT or the tenants paired with the permissions? We do have a feature coming out soon to allow you to not add all of the tenant level permissions to the JWT that may be helpful. @Bhagyesh Parna please monitor and follow up here as needed.
👍 2
e
We aren't using the widget because we want a more native, in-app experience. having a
dct
for the selected tenant or storing that elsewhere on the browser sessions doesn't address the issue directly. if there was another endpoint tell the user which tenant they can access we could have used that well, but I couldn't find one in the docs.
b
Hey @Ereli linking the docs to a potential solution: Configure once: Switch your project’s JWT template to “Current Tenant, No Tenant Reference.” Docs: JWT Templates, Current Tenant, No Tenant Reference At runtime: 1. After sign-in, keep the refresh token (server-side/HttpOnly) and a small session token (client cookie). 2. Call
myTenants()
to render your own tenant list in-app. 3. When a user picks a tenant, call
selectTenant(tenantId, refreshToken)
and then replace the session token with the returned one (now scoped to that tenant). 4. Repeat step 3 whenever they switch tenants. Docs: Client SDK Auth Helpers
đź‘€ 1
🙏 1