Compare commits
5 Commits
chore/desk
...
hotfix/ser
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb4b8a5876 | ||
|
|
629730a309 | ||
|
|
e0f468aa1c | ||
|
|
7374a35b41 | ||
|
|
5ad8f6c2ce |
@@ -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;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* (InfraConfigService)
|
||||
|
||||
@@ -15,11 +15,13 @@ import {
|
||||
INFRA_CONFIG_NOT_LISTED,
|
||||
INFRA_CONFIG_RESET_FAILED,
|
||||
INFRA_CONFIG_UPDATE_FAILED,
|
||||
INFRA_CONFIG_SERVICE_NOT_CONFIGURED,
|
||||
} from 'src/errors';
|
||||
import { throwErr, validateEmail, validateSMTPUrl } from 'src/utils';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { ServiceStatus, stopApp } from './helper';
|
||||
import { EnableAndDisableSSOArgs, InfraConfigArgs } from './input-args';
|
||||
import { AuthProvider } from 'src/auth/helper';
|
||||
|
||||
@Injectable()
|
||||
export class InfraConfigService implements OnModuleInit {
|
||||
@@ -124,7 +126,7 @@ export class InfraConfigService implements OnModuleInit {
|
||||
cast(dbInfraConfig: DBInfraConfig) {
|
||||
return <InfraConfig>{
|
||||
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
|
||||
* @param provider Auth Provider to enable or disable
|
||||
@@ -195,15 +229,21 @@ export class InfraConfigService implements OnModuleInit {
|
||||
|
||||
let updatedAuthProviders = allowedAuthProviders;
|
||||
|
||||
providerInfo.forEach(({ provider, status }) => {
|
||||
for (let i = 0; i < providerInfo.length; i++) {
|
||||
const { provider, status } = providerInfo[i];
|
||||
|
||||
if (status === ServiceStatus.ENABLE) {
|
||||
const isConfigured = this.isServiceConfigured(provider);
|
||||
if (!isConfigured) {
|
||||
throwErr(INFRA_CONFIG_SERVICE_NOT_CONFIGURED);
|
||||
}
|
||||
updatedAuthProviders.push(provider);
|
||||
} else if (status === ServiceStatus.DISABLE) {
|
||||
updatedAuthProviders = updatedAuthProviders.filter(
|
||||
(p) => p !== provider,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updatedAuthProviders = [...new Set(updatedAuthProviders)];
|
||||
|
||||
@@ -286,6 +326,9 @@ export class InfraConfigService implements OnModuleInit {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the values of the InfraConfigs
|
||||
*/
|
||||
validateEnvValues(
|
||||
infraConfigs: {
|
||||
name: InfraConfigEnumForClient | InfraConfigEnum;
|
||||
@@ -302,6 +345,24 @@ export class InfraConfigService implements OnModuleInit {
|
||||
const isValidEmail = validateEmail(infraConfigs[i].value);
|
||||
if (!isValidEmail) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||
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:
|
||||
break;
|
||||
}
|
||||
|
||||
11
packages/hoppscotch-common/src/components.d.ts
vendored
11
packages/hoppscotch-common/src/components.d.ts
vendored
@@ -1,11 +1,11 @@
|
||||
// generated by unplugin-vue-components
|
||||
// We suggest you to commit this file into source control
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
// @ts-nocheck
|
||||
// Generated by unplugin-vue-components
|
||||
// Read more: https://github.com/vuejs/core/pull/3399
|
||||
import '@vue/runtime-core'
|
||||
|
||||
export {}
|
||||
|
||||
declare module '@vue/runtime-core' {
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
AppActionHandler: typeof import('./components/app/ActionHandler.vue')['default']
|
||||
AppBanner: typeof import('./components/app/Banner.vue')['default']
|
||||
@@ -210,5 +210,4 @@ declare module '@vue/runtime-core' {
|
||||
WorkspaceCurrent: typeof import('./components/workspace/Current.vue')['default']
|
||||
WorkspaceSelector: typeof import('./components/workspace/Selector.vue')['default']
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ const GqlCollectionsGistExporter: ImporterOrExporter = {
|
||||
exporter: "gist",
|
||||
})
|
||||
|
||||
window.open(res.right, "_blank")
|
||||
platform.io.openExternalLink(res.right)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ const HoppEnvironmentsGistExporter: ImporterOrExporter = {
|
||||
platform: "rest",
|
||||
})
|
||||
|
||||
window.open(res.right, "_blank")
|
||||
platform.io.openExternalLink(res.right)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -81,4 +81,11 @@ export type IOPlatformDef = {
|
||||
saveFileWithDialog: (
|
||||
opts: SaveFileWithDialogOptions
|
||||
) => Promise<SaveFileResponse>
|
||||
|
||||
/**
|
||||
* Opens a link in the user's browser.
|
||||
* The expected behaviour is for the browser to open a new tab/window (for example in desktop app) with the given URL.
|
||||
* @param url The URL to open
|
||||
*/
|
||||
openExternalLink: (url: string) => Promise<void>
|
||||
}
|
||||
|
||||
@@ -34,4 +34,10 @@ export const browserIODef: IOPlatformDef = {
|
||||
// Browsers provide no way for us to know the save went successfully.
|
||||
return Promise.resolve({ type: "unknown" })
|
||||
},
|
||||
openExternalLink(url) {
|
||||
window.open(url, "_blank")
|
||||
|
||||
// Browsers provide no way for us to know the open went successfully.
|
||||
return Promise.resolve()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import IconGitHub from "~icons/lucide/github"
|
||||
import IconBook from "~icons/lucide/book"
|
||||
import IconLifeBuoy from "~icons/lucide/life-buoy"
|
||||
import IconZap from "~icons/lucide/zap"
|
||||
import { platform } from "~/platform"
|
||||
|
||||
type Doc = {
|
||||
text: string | string[]
|
||||
@@ -113,7 +114,7 @@ export class GeneralSpotlightSearcherService extends StaticSpotlightSearcherServ
|
||||
}
|
||||
|
||||
private openURL(url: string) {
|
||||
window.open(url, "_blank")
|
||||
platform.io.openExternalLink(url)
|
||||
}
|
||||
|
||||
public onDocSelected(id: string): void {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IOPlatformDef } from "@hoppscotch/common/platform/io"
|
||||
import { save } from "@tauri-apps/api/dialog"
|
||||
import { open } from "@tauri-apps/api/shell"
|
||||
import { writeBinaryFile, writeTextFile } from "@tauri-apps/api/fs"
|
||||
|
||||
export const ioDef: IOPlatformDef = {
|
||||
@@ -21,4 +22,7 @@ export const ioDef: IOPlatformDef = {
|
||||
|
||||
return { type: "saved", path }
|
||||
},
|
||||
openExternalLink(url) {
|
||||
return open(url)
|
||||
},
|
||||
}
|
||||
|
||||
8
packages/hoppscotch-selfhost-web/postcss.config.cjs
Normal file
8
packages/hoppscotch-selfhost-web/postcss.config.cjs
Normal file
@@ -0,0 +1,8 @@
|
||||
const config = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = config
|
||||
Reference in New Issue
Block a user