diff --git a/services/tenant-management-service/src/component.ts b/services/tenant-management-service/src/component.ts index 9a7ac0e..0bfaf44 100644 --- a/services/tenant-management-service/src/component.ts +++ b/services/tenant-management-service/src/component.ts @@ -33,7 +33,6 @@ import { import { ContactController, HomePageController, - IdpController, LeadController, LeadTenantController, PingController, diff --git a/services/tenant-management-service/src/keys.ts b/services/tenant-management-service/src/keys.ts index 9ce6414..c4620a5 100644 --- a/services/tenant-management-service/src/keys.ts +++ b/services/tenant-management-service/src/keys.ts @@ -18,7 +18,6 @@ import { } from '@loopback/core'; import {BINDING_PREFIX} from '@sourceloop/core'; import {IEventConnector} from './types/i-event-connector.interface'; -import {Auth0Response} from './providers/idp'; export namespace TenantManagementServiceBindings { export const Config = diff --git a/services/tenant-management-service/src/models/dtos/idp-details-dto.model.ts b/services/tenant-management-service/src/models/dtos/idp-details-dto.model.ts index 7dec337..744e620 100644 --- a/services/tenant-management-service/src/models/dtos/idp-details-dto.model.ts +++ b/services/tenant-management-service/src/models/dtos/idp-details-dto.model.ts @@ -1,7 +1,5 @@ import {getJsonSchema} from '@loopback/openapi-v3'; import {AnyObject, Model, model, property} from '@loopback/repository'; -import {IdpDetails, IdPKey} from '../../types'; -import {TenantDto} from './tenant-dto.model'; @model({ description: 'model describing payload for IDP controller', diff --git a/services/tenant-management-service/src/providers/idp/idp-auth0.provider.ts b/services/tenant-management-service/src/providers/idp/idp-auth0.provider.ts index f363cc0..d8f86e1 100644 --- a/services/tenant-management-service/src/providers/idp/idp-auth0.provider.ts +++ b/services/tenant-management-service/src/providers/idp/idp-auth0.provider.ts @@ -2,9 +2,7 @@ import {Provider} from '@loopback/context'; import {ConfigureIdpFunc, IdpDetails, IdPKey, IdpResp} from '../../types'; import {ManagementClient, PostOrganizationsRequest, UserCreate} from 'auth0'; - -import {Auth0Response} from './types'; - +import { randomBytes } from 'crypto'; import {repository} from '@loopback/repository'; import {HttpErrors} from '@loopback/rest'; @@ -58,7 +56,22 @@ export class Auth0IdpProvider implements Provider> { // eslint-disable-next-line enabled_connections: configValue.enabled_connections, }; - + function generateStrongPassword(length: number): string { + const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+~`|}{[]:;?><,./-='; + + // Generate random bytes + const randomBytesArray = randomBytes(length); + + // Map each byte to a character in the charset + const password = Array.from(randomBytesArray) + .map(byte => charset[byte % charset.length]) + .join(''); + + return password; + } + + const passwordLength = 16; + const password = generateStrongPassword(passwordLength); const userData: UserCreate = { email: tenant.contacts[0].email, @@ -68,7 +81,7 @@ export class Auth0IdpProvider implements Provider> { ** the user will be forced to change it on first login ** need to check actions in auth0 to see how we can achieve this **/ - password: 'test123!@#', + password: password, // eslint-disable-next-line verify_email: configValue.verify_email, // eslint-disable-next-line diff --git a/services/tenant-management-service/src/types/i-idp.interface.ts b/services/tenant-management-service/src/types/i-idp.interface.ts index 3b5995a..031386f 100644 --- a/services/tenant-management-service/src/types/i-idp.interface.ts +++ b/services/tenant-management-service/src/types/i-idp.interface.ts @@ -1,5 +1,4 @@ import {AnyObject} from '@loopback/repository'; -import {Tenant} from '../models'; export enum IdPKey { AUTH0 = 'auth0',