FEAT: block user from login when maestro is dedicated

This commit is contained in:
marcos-silva-rodrigues
2025-06-16 10:34:11 -03:00
parent 17de31f1a6
commit 0aa9c065a5
2 changed files with 28 additions and 7 deletions
+15 -7
View File
@@ -54,14 +54,22 @@ export class AuthClientService implements OnModuleInit {
return lastValueFrom(this.authService.AuthSnowflakeSignIn(input));
}
checkDedicatedProxy(customerId: string) {
checkDedicatedProxy({
customer
}: AuthSignInResponse) {
const DEDICATED_PROXY = process.env.DEDICATED_PROXY || '';
this.logger.info('SignIn - Setting customer ID for dedicated proxy: ' + DEDICATED_PROXY);
if (DEDICATED_PROXY !== '') {
this.logger.info('Customer ID: ' + customerId);
if (DEDICATED_PROXY !== customerId) {
throw new ForbiddenException();
}
this.logger.info('Customer ID: ' + customer.id);
if (DEDICATED_PROXY !== '' && DEDICATED_PROXY !== customer.id) {
throw new ForbiddenException();
}
// Bloquear o customer de acesso o maestro publico
this.logger.info('Check if customer have network policy: ' + customer.modules);
const hasNetworkPolicyModule = customer.modules.includes('network-policy');
if (hasNetworkPolicyModule && DEDICATED_PROXY === '') {
throw new ForbiddenException();
}
}
@@ -85,7 +93,7 @@ export class AuthClientService implements OnModuleInit {
}
if (result.customer) {
this.checkDedicatedProxy(result.customer.id);
this.checkDedicatedProxy(result);
}
return result