Skip to content

Commit

Permalink
feat(tenant-management): inegrate auth0
Browse files Browse the repository at this point in the history
integrate auth0

GH-47
  • Loading branch information
Surbhi-sharma1 committed Sep 28, 2024
1 parent e954553 commit bf9ad74
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,52 @@ var path = require('path');
var Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};

exports.up = function(db) {
var filePath = path.join(__dirname, 'sqls', '20240925102459-add-table-tenant-configs-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.up = function (db) {
var filePath = path.join(
__dirname,
'sqls',
'20240925102459-add-table-tenant-configs-up.sql',
);
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20240925102459-add-table-tenant-configs-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.down = function (db) {
var filePath = path.join(
__dirname,
'sqls',
'20240925102459-add-table-tenant-configs-down.sql',
);
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports._meta = {
"version": 1
version: 1,
};
2 changes: 1 addition & 1 deletion services/tenant-management-service/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
LeadTenantController,
PingController,
TenantConfigController,
TenantConfigTenantController,
TenantController,
} from './controllers';
import {InvoiceController} from './controllers/invoice.controller';
Expand Down Expand Up @@ -85,7 +86,6 @@ import {
ProvisioningService,
} from './services';
import {ITenantManagementServiceConfig} from './types';
import {TenantConfigTenantController} from '@sourceloop/ctrl-plane-tenant-management-service/dist/controllers';

export class TenantManagementServiceComponent implements Component {
constructor(
Expand Down
9 changes: 4 additions & 5 deletions services/tenant-management-service/src/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ export const PermissionKey = {
UpdateSubscription: '7002',
ViewSubscription: '7004',
ViewPlan: '7008',
CreateTenantConfig: '10216',

UpdateTenantConfig: '10217',
DeleteTenantConfig: '10218',
ViewTenantConfig: '10219',
CreateTenantConfig: '10220',
ViewTenantConfig: '10221',
UpdateTenantConfig: '10222',
DeleteTenantConfig: '10223',

// notification service
ViewNotificationTemplate: '8000',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ export class Auth0IdpProvider
name: tenant.name,
// eslint-disable-next-line
display_name: configValue.display_name,
branding: {
// eslint-disable-next-line
logo_url: configValue.logo_url,
colors: {
primary: configValue.primary_color,
// eslint-disable-next-line
page_background: configValue.page_background,
},
},
// eslint-disable-next-line
enabled_connections: configValue.enabled_connections,
};

const userData: UserCreate = {
Expand Down Expand Up @@ -113,14 +124,7 @@ export class Auth0IdpProvider
}
async createOrganization(data: PostOrganizationsRequest) {
try {
return await this.management.organizations.create({
name: data.name,
// eslint-disable-next-line
display_name: data.display_name,
branding: {},
// eslint-disable-next-line
enabled_connections: [],
});
return await this.management.organizations.create(data);
} catch (error) {
throw new Error(`Error creating organization: ${error.message}`);
}
Expand All @@ -145,5 +149,4 @@ export class Auth0IdpProvider
throw new Error(`Error adding member to organization: ${error.message}`);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export enum IdPKey {
export type ConfigureIdpFunc<T> = (payload: IdpDetails) => Promise<T>;

export interface IdpDetails {
plan: AnyObject;
identityProvider: IdPKey;
tenant: Tenant;
plan: AnyObject;
}
7 changes: 2 additions & 5 deletions services/tenant-management-service/src/webhook.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,15 @@ import {
SaasTenantRepository,
} from './repositories';
import {WebhookVerifierProvider} from './interceptors';
import {
Auth0IdpProvider,
KeycloakIdpProvider,
SystemUserProvider,
} from './providers';
import {KeycloakIdpProvider, SystemUserProvider} from './providers';
import {CryptoHelperService, NotificationService} from './services';
import {
DEFAULT_SIGNATURE_HEADER,
DEFAULT_TIMESTAMP_HEADER,
DEFAULT_TIMESTAMP_TOLERANCE,
} from './utils';
import {ProvisioningWebhookHandler} from './services/webhook';
import {Auth0IdpProvider} from './providers/idp/idp-auth0.provider';

export class WebhookTenantManagementServiceComponent implements Component {
constructor(
Expand Down

0 comments on commit bf9ad74

Please sign in to comment.