Hey Descopers :slightly_smiling_face: Got a questi...
# ask-a-descoper
i
Hey Descopers 🙂 Got a question regarding
dct
claim Under session management
dct
claim is used inorder to set a state for which tenant the current authenticated users is working against. I would like to understand if there is a best practice for tenant switching and changing the
dct
claim (We are working with NextJS for FE and BE and also some nodejs based api's that use the descope node sdk ) And what is the practice for tenant selection and switching for JWT exchanged by access keys? Today we require users to provide the tenant id they would like to "work" against and upon validation of the JWT we check if they are members of that tenant (Along with other authz validations, and thats mostly done in our backend using the descope node sdk)
m
i
Nope but since i would like to have my own component for that in my FE (And maybe in the future through CLI) whats the equivalent descope node-sdk / next-sdk / api to perform this switch? session refresh with setting dct custom claim validating that the tenant being switched to is allowed for the user?
m
@Nir Gur Arie @Tomer Lichtash can you help here ?
i
In general, we are seeing more and more API use cases in my product. Initially, we went with an approach to pass the tenant ID in the path as an alternative mechanism for tenant selection, but this becomes less intuitive for APIs as the user now needs to be aware of the specific tenant ID they belong to and other tenant IDs they have access to. If they would like to perform an action against a specific tenant or switch tenants, this becomes a burden of making sure they pass the tenant ID in the path all the time. So I thought about moving to utilizing DCT stored in JWT both in my frontend and other interfaces, and exposing an API to retrieve available tenants and an API to switch between tenants. I just want to make sure we are doing it correctly and that we aren't reinventing the wheel here... 😅
i
Awesome! thanks 🙌