Skip to content

Unable to get the service token in multitenant scenario #6288

@rashmiangadi11

Description

@rashmiangadi11

Describe the Question

Hi Team,

I have the below scenario

There is a leading SaaS application bound to dms(btp service). When a tenant 1 subscribes to this app a token is generated to call api's of dms service. when tenant 2 subscribes to this app the token is same but i want a different token.

async function transformSDMServiceBindingToClientCredentialsDestination(service, options,subdomain) {
  // Extract tenant subdomain and replace provider subdomain in UAA URL for multi-tenant support
  console.log("SUBDOMAIN IN ***** "+subdomain);
  let uaaUrl = service.credentials.uaa.url;
  if(!subdomain)
    subdomain = cds.context?.user?.authInfo?.token?.payload?.ext_attr?.zdn;
  if (subdomain && uaaUrl.includes('://')) {
    const providerSubdomain = uaaUrl.substring(uaaUrl.indexOf('://') + 3, uaaUrl.indexOf('.'));
    uaaUrl = uaaUrl.replace(providerSubdomain, subdomain);
  }
  console.log("SUBDOMAIN LATER ***** "+subdomain);
  const transformedService = {
    ...service,
    credentials: { ...service.credentials.uaa, url: uaaUrl }
  };

  const token = await serviceToken(transformedService, options);
  return buildClientCredentialsDestination(
    token,
    uaaUrl,
    service.name
  );
}

this is the method used. The clientId and client secret remains the same only the auth url changes based on subdomain to generate the token. How can this be achieved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions