async function getsettings()

in resources/oidc-provider/settings.js [154:211]


async function getsettings(clientId) {
/**
 * Querying DynamoDB for Clients
 * @see https://github.com/panva/node-oidc-provider/blob/master/docs/configuration.md
 */
  try {
    Log.debug('client_id to be used for settings lookup', clientId);
    const tenantId = await gettenant(clientId);
    Log.debug('Looked up tenant_id for client_id', tenantId);
    const tenantconfig = await gettenantsettings(tenantId);
    Log.debug('received tenant config', tenantconfig);
    const clients = await getclients(tenantId);
    Log.debug('clients received', clients);
    const features = await getfeatures();
    Log.debug('features received', features);

    const retrievedsettings = {

      ...tenantconfig,
      configuration: {
        ...getbasesettings(clientId),
        ...tenantconfig.configuration,
        clients,
        features,
      },
    };
    Log.debug('retrieved settings', retrievedsettings);
    // if (tenantconfig.authtype === 'cognito') {
    //   retrievedsettings.configuration.findAccount = Account.findById
    // } else if (tenantconfig.authtype === 'ldap') {
    //   retrievedsettings.configuration.findAccount = Account.findById
    // } else {
    //   throw new Error('Tenant does not have a valid auth type')
    // }
    if (tenantconfig.authtype === 'cognito') {
      Log.debug(`going to create a cognitaccount object with clientid:${tenantconfig.clientId} and userpoolid:${tenantconfig.userPoolId} and tenantid:${tenantId}`);
      retrievedsettings.configuration.Account = new CognitoAccount(null, null, tenantconfig.clientId, tenantconfig.userPoolId, tenantId);
    } else if (tenantconfig.authtype === 'ldap') {
      retrievedsettings.configuration.Account = new LdapAccount(null, null, tenantconfig);
    } else {
      throw new Error('Tenant has invalid/unsupported auth type');
    }
    // delete retrievedsettings.configuration.id
    // delete retrievedsettings.configuration.domain
    // delete retrievedsettings.configuration.type
    // delete retrievedsettings.configuration.tenant_id
    Log.debug('Going to return retrived settings with findaccount', retrievedsettings);
    return retrievedsettings;
  } catch (err) {
    Log.error('Unable to query. Error:', err);
    throw err;
  }

/**
 * Values for setting and initializing Provider.
 * @see https://github.com/panva/node-oidc-provider/blob/master/docs/configuration.md
 */
}