diff --git a/dev/src/app.module.ts b/dev/src/app.module.ts index f95f786..7bc9472 100644 --- a/dev/src/app.module.ts +++ b/dev/src/app.module.ts @@ -36,7 +36,7 @@ import { SomeModule } from "./some/some.module"; callbackUrl: "http://localhost:3000/sso/callback", scopes: ["esi-characters.read_titles.v1"], }), - CloneBayModule.forRoot({}), + CloneBayModule.forRoot({ unsafeEnableMocking: true }), CloneBaySsoModule, CloneBayResolversModule, SomeModule, diff --git a/lib/src/clone-bay-module-options.interface.ts b/lib/src/clone-bay-module-options.interface.ts index 2b5188d..67af52d 100644 --- a/lib/src/clone-bay-module-options.interface.ts +++ b/lib/src/clone-bay-module-options.interface.ts @@ -16,6 +16,17 @@ export interface CloneBayModuleOptions { */ esiBaseUrl?: string; + /** + * Enable mocking for testing and development. + * + * **DO NOT ENABLE IN PRODUCTION!** + * + * Turning this on will cause the mocking module to be loaded which will mount + * REST endpoints that will enable anyone to trivially take over your + * application if it is connectable. + */ + unsafeEnableMocking?: boolean; + /** * Override dynamic configuration values. * diff --git a/lib/src/config/module-config.model.ts b/lib/src/config/module-config.model.ts index 0caf2d3..04e386b 100644 --- a/lib/src/config/module-config.model.ts +++ b/lib/src/config/module-config.model.ts @@ -1,4 +1,4 @@ -import { IsUrl } from "class-validator"; +import { IsBoolean, IsUrl } from "class-validator"; import { DynamicConfig } from "./dynamic-config.model"; /** `CloneBayModule` static configuration. */ @@ -21,5 +21,8 @@ export class ModuleConfig { }) esiBaseUrl = "https://esi.evetech.net"; + @IsBoolean() + unsafeEnableMocking = false; + dynamicConfigOverride?: Partial = {}; } diff --git a/lib/test/mocks/mock-module-config.ts b/lib/test/mocks/mock-module-config.ts index 4f6b94d..9352bfa 100644 --- a/lib/test/mocks/mock-module-config.ts +++ b/lib/test/mocks/mock-module-config.ts @@ -5,6 +5,7 @@ import { provideMockService } from "./mock-services"; export const defaultMockConfiguration: ModuleConfig = { afterLoginUrl: "/", esiBaseUrl: "", + unsafeEnableMocking: false, }; export const provideMockModuleConfigService = (