Compare commits
3 Commits
fix/action
...
hotfix/ser
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb4b8a5876 | ||
|
|
629730a309 | ||
|
|
e0f468aa1c |
@@ -676,6 +676,13 @@ export const INFRA_CONFIG_RESET_FAILED = 'infra_config/reset_failed' as const;
|
|||||||
*/
|
*/
|
||||||
export const INFRA_CONFIG_INVALID_INPUT = 'infra_config/invalid_input' as const;
|
export const INFRA_CONFIG_INVALID_INPUT = 'infra_config/invalid_input' as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Infra Config service (auth provider/mailer/audit logs) not configured
|
||||||
|
* (InfraConfigService)
|
||||||
|
*/
|
||||||
|
export const INFRA_CONFIG_SERVICE_NOT_CONFIGURED =
|
||||||
|
'infra_config/service_not_configured' as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error message for when the database table does not exist
|
* Error message for when the database table does not exist
|
||||||
* (InfraConfigService)
|
* (InfraConfigService)
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ import {
|
|||||||
INFRA_CONFIG_NOT_LISTED,
|
INFRA_CONFIG_NOT_LISTED,
|
||||||
INFRA_CONFIG_RESET_FAILED,
|
INFRA_CONFIG_RESET_FAILED,
|
||||||
INFRA_CONFIG_UPDATE_FAILED,
|
INFRA_CONFIG_UPDATE_FAILED,
|
||||||
|
INFRA_CONFIG_SERVICE_NOT_CONFIGURED,
|
||||||
} from 'src/errors';
|
} from 'src/errors';
|
||||||
import { throwErr, validateEmail, validateSMTPUrl } from 'src/utils';
|
import { throwErr, validateEmail, validateSMTPUrl } from 'src/utils';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { ServiceStatus, stopApp } from './helper';
|
import { ServiceStatus, stopApp } from './helper';
|
||||||
import { EnableAndDisableSSOArgs, InfraConfigArgs } from './input-args';
|
import { EnableAndDisableSSOArgs, InfraConfigArgs } from './input-args';
|
||||||
|
import { AuthProvider } from 'src/auth/helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class InfraConfigService implements OnModuleInit {
|
export class InfraConfigService implements OnModuleInit {
|
||||||
@@ -124,7 +126,7 @@ export class InfraConfigService implements OnModuleInit {
|
|||||||
cast(dbInfraConfig: DBInfraConfig) {
|
cast(dbInfraConfig: DBInfraConfig) {
|
||||||
return <InfraConfig>{
|
return <InfraConfig>{
|
||||||
name: dbInfraConfig.name,
|
name: dbInfraConfig.name,
|
||||||
value: dbInfraConfig.value,
|
value: dbInfraConfig.value ?? '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +184,38 @@ export class InfraConfigService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the service is configured or not
|
||||||
|
* @param service Service can be Auth Provider, Mailer, Audit Log etc.
|
||||||
|
* @returns Either true or false
|
||||||
|
*/
|
||||||
|
isServiceConfigured(service: AuthProvider) {
|
||||||
|
switch (service) {
|
||||||
|
case AuthProvider.GOOGLE:
|
||||||
|
return (
|
||||||
|
this.configService.get<string>('INFRA.GOOGLE_CLIENT_ID') &&
|
||||||
|
this.configService.get<string>('INFRA.GOOGLE_CLIENT_SECRET')
|
||||||
|
);
|
||||||
|
case AuthProvider.GITHUB:
|
||||||
|
return (
|
||||||
|
this.configService.get<string>('INFRA.GITHUB_CLIENT_ID') &&
|
||||||
|
!this.configService.get<string>('INFRA.GITHUB_CLIENT_SECRET')
|
||||||
|
);
|
||||||
|
case AuthProvider.MICROSOFT:
|
||||||
|
return (
|
||||||
|
this.configService.get<string>('INFRA.MICROSOFT_CLIENT_ID') &&
|
||||||
|
!this.configService.get<string>('INFRA.MICROSOFT_CLIENT_SECRET')
|
||||||
|
);
|
||||||
|
case AuthProvider.EMAIL:
|
||||||
|
return (
|
||||||
|
this.configService.get<string>('INFRA.MAILER_SMTP_URL') &&
|
||||||
|
this.configService.get<string>('INFRA.MAILER_ADDRESS_FROM')
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable or Disable SSO for login/signup
|
* Enable or Disable SSO for login/signup
|
||||||
* @param provider Auth Provider to enable or disable
|
* @param provider Auth Provider to enable or disable
|
||||||
@@ -195,15 +229,21 @@ export class InfraConfigService implements OnModuleInit {
|
|||||||
|
|
||||||
let updatedAuthProviders = allowedAuthProviders;
|
let updatedAuthProviders = allowedAuthProviders;
|
||||||
|
|
||||||
providerInfo.forEach(({ provider, status }) => {
|
for (let i = 0; i < providerInfo.length; i++) {
|
||||||
|
const { provider, status } = providerInfo[i];
|
||||||
|
|
||||||
if (status === ServiceStatus.ENABLE) {
|
if (status === ServiceStatus.ENABLE) {
|
||||||
|
const isConfigured = this.isServiceConfigured(provider);
|
||||||
|
if (!isConfigured) {
|
||||||
|
throwErr(INFRA_CONFIG_SERVICE_NOT_CONFIGURED);
|
||||||
|
}
|
||||||
updatedAuthProviders.push(provider);
|
updatedAuthProviders.push(provider);
|
||||||
} else if (status === ServiceStatus.DISABLE) {
|
} else if (status === ServiceStatus.DISABLE) {
|
||||||
updatedAuthProviders = updatedAuthProviders.filter(
|
updatedAuthProviders = updatedAuthProviders.filter(
|
||||||
(p) => p !== provider,
|
(p) => p !== provider,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
updatedAuthProviders = [...new Set(updatedAuthProviders)];
|
updatedAuthProviders = [...new Set(updatedAuthProviders)];
|
||||||
|
|
||||||
@@ -286,6 +326,9 @@ export class InfraConfigService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the values of the InfraConfigs
|
||||||
|
*/
|
||||||
validateEnvValues(
|
validateEnvValues(
|
||||||
infraConfigs: {
|
infraConfigs: {
|
||||||
name: InfraConfigEnumForClient | InfraConfigEnum;
|
name: InfraConfigEnumForClient | InfraConfigEnum;
|
||||||
@@ -302,6 +345,24 @@ export class InfraConfigService implements OnModuleInit {
|
|||||||
const isValidEmail = validateEmail(infraConfigs[i].value);
|
const isValidEmail = validateEmail(infraConfigs[i].value);
|
||||||
if (!isValidEmail) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
if (!isValidEmail) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||||
break;
|
break;
|
||||||
|
case InfraConfigEnumForClient.GOOGLE_CLIENT_ID:
|
||||||
|
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||||
|
break;
|
||||||
|
case InfraConfigEnumForClient.GOOGLE_CLIENT_SECRET:
|
||||||
|
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||||
|
break;
|
||||||
|
case InfraConfigEnumForClient.GITHUB_CLIENT_ID:
|
||||||
|
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||||
|
break;
|
||||||
|
case InfraConfigEnumForClient.GITHUB_CLIENT_SECRET:
|
||||||
|
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||||
|
break;
|
||||||
|
case InfraConfigEnumForClient.MICROSOFT_CLIENT_ID:
|
||||||
|
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||||
|
break;
|
||||||
|
case InfraConfigEnumForClient.MICROSOFT_CLIENT_SECRET:
|
||||||
|
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<Splitpanes
|
<Splitpanes
|
||||||
|
class="smart-splitter"
|
||||||
:rtl="SIDEBAR_ON_LEFT && mdAndLarger"
|
:rtl="SIDEBAR_ON_LEFT && mdAndLarger"
|
||||||
:class="{
|
:class="{
|
||||||
'!flex-row-reverse': SIDEBAR_ON_LEFT && mdAndLarger,
|
'!flex-row-reverse': SIDEBAR_ON_LEFT && mdAndLarger,
|
||||||
'smart-splitter': SIDEBAR && hasSidebar,
|
|
||||||
'no-splitter': !(SIDEBAR && hasSidebar),
|
|
||||||
}"
|
}"
|
||||||
:horizontal="!mdAndLarger"
|
:horizontal="!mdAndLarger"
|
||||||
@resize="setPaneEvent($event, 'vertical')"
|
@resize="setPaneEvent($event, 'vertical')"
|
||||||
>
|
>
|
||||||
<Pane
|
<Pane
|
||||||
:size="SIDEBAR && hasSidebar ? PANE_MAIN_SIZE : 100"
|
:size="PANE_MAIN_SIZE"
|
||||||
min-size="65"
|
min-size="65"
|
||||||
class="flex flex-col !overflow-auto"
|
class="flex flex-col !overflow-auto"
|
||||||
>
|
>
|
||||||
@@ -37,8 +36,9 @@
|
|||||||
</Splitpanes>
|
</Splitpanes>
|
||||||
</Pane>
|
</Pane>
|
||||||
<Pane
|
<Pane
|
||||||
:size="SIDEBAR && hasSidebar ? PANE_SIDEBAR_SIZE : 0"
|
v-if="SIDEBAR && hasSidebar"
|
||||||
:min-size="25"
|
:size="PANE_SIDEBAR_SIZE"
|
||||||
|
min-size="25"
|
||||||
class="flex flex-col !overflow-auto bg-primaryContrast"
|
class="flex flex-col !overflow-auto bg-primaryContrast"
|
||||||
>
|
>
|
||||||
<slot name="sidebar" />
|
<slot name="sidebar" />
|
||||||
|
|||||||
Reference in New Issue
Block a user