Skip to content

Commit

Permalink
fix(tenant-management): resolve sonar issues
Browse files Browse the repository at this point in the history
resolve sonar issues

GH-47
  • Loading branch information
Surbhi-sharma1 committed Oct 11, 2024
1 parent c68c044 commit 29c1f8c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,20 @@ export class IdpController {
})
payload: IdpDetailsDTO,
): Promise<IdpResp> {
let res: IdpResp = {
const res: IdpResp = {
authId: '',
};
switch (payload.tenant.identityProvider) {
case IdPKey.AUTH0:
let auth0Resp = await this.idpAuth0Provider(payload);
// eslint-disable-next-line
const auth0Resp = await this.idpAuth0Provider(payload);
return auth0Resp;

case IdPKey.COGNITO:
break;
case IdPKey.KEYCLOAK:
let keycloakResp = await this.idpKeycloakProvider(payload);
// eslint-disable-next-line
const keycloakResp = await this.idpKeycloakProvider(payload);
return keycloakResp;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class SubscriptionDTO implements ISubscription {

@property({type: 'string'})
invoiceId: string;

// Assuming IPlan interface is defined, you can include it here
@property()
plan?: IPlan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Provider} from '@loopback/context';

import {ConfigureIdpFunc, IdpDetails, IdPKey, IdpResp} from '../../types';
import {ManagementClient, PostOrganizationsRequest, UserCreate} from 'auth0';
import { randomBytes } from 'crypto';
import {randomBytes} from 'crypto';
import {repository} from '@loopback/repository';

import {HttpErrors} from '@loopback/rest';
Expand Down Expand Up @@ -57,19 +57,20 @@ export class Auth0IdpProvider implements Provider<ConfigureIdpFunc<IdpResp>> {
enabled_connections: configValue.enabled_connections,
};
function generateStrongPassword(length: number): string {
const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+~`|}{[]:;?><,./-=';

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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ interface Credentials {
temporary: boolean;
}

export class KeycloakIdpProvider implements Provider<ConfigureIdpFunc<IdpResp>> {
export class KeycloakIdpProvider
implements Provider<ConfigureIdpFunc<IdpResp>>
{
constructor() {}

value(): ConfigureIdpFunc<IdpResp> {
Expand Down Expand Up @@ -42,8 +44,8 @@ export class KeycloakIdpProvider implements Provider<ConfigureIdpFunc<IdpResp>>
);
}
return {
authId:"", // dummy authID
}
authId: '', // dummy authID
};
}

async authenticateAdmin(): Promise<string> {
Expand Down

0 comments on commit 29c1f8c

Please sign in to comment.