@tsed/oidc-provider 7.0.0-beta.9 → 7.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coverage.json +6 -0
- package/jest.config.js +9 -0
- package/lib/cjs/OidcModule.js +7 -1
- package/lib/cjs/OidcModule.js.map +1 -1
- package/lib/cjs/domain/OidcAccountsMethods.js.map +1 -1
- package/lib/cjs/domain/OidcBadInteractionName.js +8 -0
- package/lib/cjs/domain/OidcBadInteractionName.js.map +1 -0
- package/lib/cjs/domain/OidcInteractionPromptProps.js +3 -0
- package/lib/cjs/domain/OidcInteractionPromptProps.js.map +1 -0
- package/lib/cjs/domain/OidcSettings.js.map +1 -1
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/middlewares/OidcInteractionMiddleware.js +5 -25
- package/lib/cjs/middlewares/OidcInteractionMiddleware.js.map +1 -1
- package/lib/cjs/services/OidcAdapters.js +22 -0
- package/lib/cjs/services/OidcAdapters.js.map +1 -1
- package/lib/cjs/services/OidcInteractionContext.js +61 -16
- package/lib/cjs/services/OidcInteractionContext.js.map +1 -1
- package/lib/cjs/services/OidcInteractions.js +8 -7
- package/lib/cjs/services/OidcInteractions.js.map +1 -1
- package/lib/cjs/services/OidcJwks.js +3 -0
- package/lib/cjs/services/OidcJwks.js.map +1 -1
- package/lib/cjs/services/OidcProvider.js +19 -7
- package/lib/cjs/services/OidcProvider.js.map +1 -1
- package/lib/esm/OidcModule.js +7 -1
- package/lib/esm/OidcModule.js.map +1 -1
- package/lib/esm/domain/OidcAccountsMethods.js.map +1 -1
- package/lib/esm/domain/OidcBadInteractionName.js +4 -0
- package/lib/esm/domain/OidcBadInteractionName.js.map +1 -0
- package/lib/esm/domain/OidcInteractionPromptProps.js +2 -0
- package/lib/esm/domain/OidcInteractionPromptProps.js.map +1 -0
- package/lib/esm/domain/OidcSettings.js.map +1 -1
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/middlewares/OidcInteractionMiddleware.js +7 -27
- package/lib/esm/middlewares/OidcInteractionMiddleware.js.map +1 -1
- package/lib/esm/services/OidcAdapters.js +22 -0
- package/lib/esm/services/OidcAdapters.js.map +1 -1
- package/lib/esm/services/OidcInteractionContext.js +62 -17
- package/lib/esm/services/OidcInteractionContext.js.map +1 -1
- package/lib/esm/services/OidcInteractions.js +8 -7
- package/lib/esm/services/OidcInteractions.js.map +1 -1
- package/lib/esm/services/OidcJwks.js +3 -0
- package/lib/esm/services/OidcJwks.js.map +1 -1
- package/lib/esm/services/OidcProvider.js +20 -8
- package/lib/esm/services/OidcProvider.js.map +1 -1
- package/lib/types/OidcModule.d.ts +5 -5
- package/lib/types/domain/OidcAccountsMethods.d.ts +1 -2
- package/lib/types/domain/OidcBadInteractionName.d.ts +3 -0
- package/lib/types/domain/OidcInteractionPromptProps.d.ts +9 -0
- package/lib/types/domain/OidcSettings.d.ts +9 -1
- package/lib/types/index.d.ts +2 -0
- package/lib/types/middlewares/OidcInteractionMiddleware.d.ts +3 -5
- package/lib/types/services/OidcAdapters.d.ts +3 -2
- package/lib/types/services/OidcInteractionContext.d.ts +6 -2
- package/lib/types/services/OidcProvider.d.ts +3 -3
- package/package.json +15 -12
- package/readme.md +4 -2
- package/.mocharc.js +0 -5
- package/.nycrc +0 -27
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { PlatformApplication } from "@tsed/common";
|
|
2
3
|
import { Env, setValue } from "@tsed/core";
|
|
3
4
|
import { Constant, Inject, Injectable, InjectorService } from "@tsed/di";
|
|
4
|
-
import { Provider as OIDCProvider
|
|
5
|
+
import { interactionPolicy, Provider as OIDCProvider } from "oidc-provider";
|
|
5
6
|
import { INTERACTIONS } from "../constants/constants.js";
|
|
6
7
|
import { OidcAdapters } from "./OidcAdapters.js";
|
|
7
8
|
import { OidcInteractions } from "./OidcInteractions.js";
|
|
8
9
|
import { OidcJwks } from "./OidcJwks.js";
|
|
9
|
-
import { PlatformApplication } from "@tsed/common";
|
|
10
10
|
let OidcProvider = class OidcProvider {
|
|
11
|
+
raw;
|
|
12
|
+
env;
|
|
13
|
+
httpPort;
|
|
14
|
+
httpsPort;
|
|
15
|
+
issuer;
|
|
16
|
+
oidc;
|
|
17
|
+
platformName;
|
|
18
|
+
oidcJwks;
|
|
19
|
+
oidcInteractions;
|
|
20
|
+
adapters;
|
|
21
|
+
injector;
|
|
22
|
+
app;
|
|
11
23
|
hasConfiguration() {
|
|
12
24
|
return !!this.oidc;
|
|
13
25
|
}
|
|
14
26
|
async getConfiguration() {
|
|
15
27
|
const [jwks, adapter] = await Promise.all([this.oidcJwks.getJwks(), this.adapters.createAdapterClass()]);
|
|
16
|
-
const { issuer, jwksPath, secureKey, proxy, Accounts, ...options } = this.oidc;
|
|
28
|
+
const { issuer, jwksPath, secureKey, proxy, Accounts, secureCookies = this.env == Env.PROD, ...options } = this.oidc;
|
|
17
29
|
const configuration = {
|
|
18
30
|
interactions: {
|
|
19
31
|
/* istanbul ignore next */
|
|
@@ -24,9 +36,9 @@ let OidcProvider = class OidcProvider {
|
|
|
24
36
|
jwks
|
|
25
37
|
};
|
|
26
38
|
if (Accounts) {
|
|
27
|
-
configuration.findAccount = (ctx, id, token) => this.injector.get(Accounts).findAccount(id, token
|
|
39
|
+
configuration.findAccount = (ctx, id, token) => this.injector.get(Accounts).findAccount(id, token);
|
|
28
40
|
}
|
|
29
|
-
if (
|
|
41
|
+
if (secureCookies) {
|
|
30
42
|
setValue(configuration, "cookies.short.secure", true);
|
|
31
43
|
setValue(configuration, "cookies.long.secure", true);
|
|
32
44
|
}
|
|
@@ -57,10 +69,10 @@ let OidcProvider = class OidcProvider {
|
|
|
57
69
|
* Create a new instance of OidcProvider
|
|
58
70
|
*/
|
|
59
71
|
async create() {
|
|
60
|
-
const { proxy, secureKey } = this.oidc;
|
|
72
|
+
const { proxy = this.env === Env.PROD, secureKey, allowHttpLocalhost = this.env !== Env.PROD } = this.oidc;
|
|
61
73
|
const configuration = await this.getConfiguration();
|
|
62
74
|
const oidcProvider = new OIDCProvider(this.getIssuer(), configuration);
|
|
63
|
-
if (proxy
|
|
75
|
+
if (proxy) {
|
|
64
76
|
// istanbul ignore next
|
|
65
77
|
switch (this.platformName) {
|
|
66
78
|
default:
|
|
@@ -76,7 +88,7 @@ let OidcProvider = class OidcProvider {
|
|
|
76
88
|
oidcProvider.app.keys = secureKey;
|
|
77
89
|
}
|
|
78
90
|
this.raw = oidcProvider;
|
|
79
|
-
if (
|
|
91
|
+
if (allowHttpLocalhost) {
|
|
80
92
|
this.allowHttpLocalhost();
|
|
81
93
|
}
|
|
82
94
|
await this.injector.emit("$onCreateOIDC", this.raw);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OidcProvider.js","sourceRoot":"","sources":["../../../src/services/OidcProvider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AACvE,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAiB,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACzF,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAKjD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAoCvB,gBAAgB;QACd,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,CAAC,IAAI,EAAE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gBAEpE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;oBACrB,MAAM,CAAC,GAAG,CACR,IAAI,iBAAiB,CAAC,MAAM,CAAC;wBAC3B,IAAI;wBACJ,GAAG,OAAO;qBACX,CAAC,CACH,CAAC;iBACH;gBAED,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAEnD,IAAI,QAAQ,CAAC,SAAS,EAAE;oBACtB,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;iBACtC;YACH,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;CACF,CAAA;AAjLC;IADC,QAAQ,CAAC,KAAK,CAAC;;yCACG;AAGnB;IADC,QAAQ,CAAC,UAAU,CAAC;;8CACe;AAGpC;IADC,QAAQ,CAAC,WAAW,CAAC;;+CACe;AAGrC;IADC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;;4CACH;AAGzB;IADC,QAAQ,CAAC,MAAM,CAAC;;0CACY;AAG7B;IADC,QAAQ,CAAC,eAAe,CAAC;;kDACK;AAG/B;IADC,MAAM,EAAE;8BACW,QAAQ;8CAAC;AAG7B;IADC,MAAM,EAAE;8BACmB,gBAAgB;sDAAC;AAG7C;IADC,MAAM,EAAE;8BACW,YAAY;8CAAC;AAGjC;IADC,MAAM,EAAE;8BACW,eAAe;8CAAC;AAGpC;IADC,MAAM,EAAE;8BACM,mBAAmB;yCAAC;AAlCxB,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CAqLxB;SArLY,YAAY","sourcesContent":["import {Env, setValue} from \"@tsed/core\";\nimport {Constant, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {Provider as OIDCProvider, Configuration, interactionPolicy} from \"oidc-provider\";\nimport {INTERACTIONS} from \"../constants/constants\";\nimport {OidcAdapters} from \"./OidcAdapters\";\nimport {OidcInteractions} from \"./OidcInteractions\";\nimport {OidcJwks} from \"./OidcJwks\";\nimport {PlatformApplication} from \"@tsed/common\";\nimport {OidcSettings} from \"../domain/OidcSettings\";\nimport {OidcAccountsMethods} from \"../domain/OidcAccountsMethods\";\n\n@Injectable()\nexport class OidcProvider {\n raw: OIDCProvider;\n\n @Constant(\"env\")\n protected env: Env;\n\n @Constant(\"httpPort\")\n protected httpPort: number | string;\n\n @Constant(\"httpsPort\")\n protected httpsPort: number | string;\n\n @Constant(\"oidc.issuer\", \"\")\n protected issuer: string;\n\n @Constant(\"oidc\")\n protected oidc: OidcSettings;\n\n @Constant(\"PLATFORM_NAME\")\n protected platformName: string;\n\n @Inject()\n protected oidcJwks: OidcJwks;\n\n @Inject()\n protected oidcInteractions: OidcInteractions;\n\n @Inject()\n protected adapters: OidcAdapters;\n\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected app: PlatformApplication;\n\n hasConfiguration() {\n return !!this.oidc;\n }\n\n async getConfiguration(): Promise<Configuration> {\n const [jwks, adapter] = await Promise.all([this.oidcJwks.getJwks(), this.adapters.createAdapterClass()]);\n const {issuer, jwksPath, secureKey, proxy, Accounts, ...options} = this.oidc;\n\n const configuration: Configuration = {\n interactions: {\n /* istanbul ignore next */\n url: (ctx, interaction) => `interaction/${interaction.uid}`\n },\n ...options,\n adapter,\n jwks\n };\n\n if (Accounts) {\n configuration.findAccount = (ctx, id, token) =>\n this.injector.get<OidcAccountsMethods>(Accounts)!.findAccount(id, token, (ctx.req as any).$ctx);\n }\n\n if (this.env === Env.PROD) {\n setValue(configuration, \"cookies.short.secure\", true);\n setValue(configuration, \"cookies.long.secure\", true);\n }\n\n const policy = this.getPolicy();\n if (policy) {\n setValue(configuration, \"interactions.policy\", policy);\n }\n\n const url = this.getInteractionsUrl();\n if (url) {\n setValue(configuration, \"interactions.url\", url);\n }\n\n return configuration;\n }\n\n getIssuer() {\n if (this.issuer) {\n return this.issuer;\n }\n\n // istanbul ignore next\n if (this.httpsPort) {\n return `https://localhost:${this.httpsPort}`;\n }\n\n return `http://localhost:${this.httpPort}`;\n }\n\n get(): OIDCProvider {\n return this.raw;\n }\n\n /**\n * Create a new instance of OidcProvider\n */\n async create(): Promise<void | OIDCProvider> {\n const {proxy, secureKey} = this.oidc;\n const configuration = await this.getConfiguration();\n const oidcProvider = new OIDCProvider(this.getIssuer(), configuration);\n\n if (proxy || this.env === Env.PROD) {\n // istanbul ignore next\n switch (this.platformName) {\n default:\n case \"express\":\n oidcProvider.proxy = true;\n break;\n case \"koa\":\n (this.app.rawApp as any).proxy = true;\n break;\n }\n }\n\n if (secureKey) {\n oidcProvider.app.keys = secureKey;\n }\n\n this.raw = oidcProvider;\n\n if (this.env !== Env.PROD) {\n this.allowHttpLocalhost();\n }\n\n await this.injector.emit(\"$onCreateOIDC\", this.raw);\n\n return this.raw;\n }\n\n private getInteractionsUrl() {\n const provider = this.injector.getProviders().find((provider) => provider.subType === INTERACTIONS);\n\n if (provider) {\n return (ctx: any, interaction: any) => {\n // eslint-disable-line no-unused-vars\n return provider.path.replace(/:uid/, interaction.uid);\n };\n }\n }\n\n private allowHttpLocalhost() {\n const {invalidate: orig} = (this.raw.Client as any).Schema.prototype;\n\n (this.raw.Client as any).Schema.prototype.invalidate = function invalidate(message: string, code: string) {\n if (code === \"implicit-force-https\" || code === \"implicit-forbid-localhost\") {\n return;\n }\n\n /* istanbul ignore next */\n return orig.call(this, message);\n };\n }\n\n private getPolicy() {\n const policy = interactionPolicy.base();\n const interactions = this.oidcInteractions.getInteractions();\n\n if (interactions.length) {\n interactions.forEach((provider) => {\n const {name, ...options} = provider.store.get(\"interactionOptions\");\n\n if (!policy.get(name)) {\n policy.add(\n new interactionPolicy.Prompt({\n name,\n ...options\n })\n );\n }\n\n const instance = this.injector.get(provider.token);\n\n if (instance.$onCreate) {\n instance.$onCreate(policy.get(name));\n }\n });\n }\n\n return this.injector.alter(\"$alterOidcPolicy\", policy);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"OidcProvider.js","sourceRoot":"","sources":["../../../src/services/OidcProvider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAC;AACjD,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AACvE,OAAO,EAAgB,iBAAiB,EAAE,QAAQ,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;AACzF,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAGpC,IAAa,YAAY,GAAzB,MAAa,YAAY;IACvB,GAAG,CAAe;IAGR,GAAG,CAAM;IAGT,QAAQ,CAAkB;IAG1B,SAAS,CAAkB;IAG3B,MAAM,CAAS;IAGf,IAAI,CAAe;IAGnB,YAAY,CAAS;IAGrB,QAAQ,CAAW;IAGnB,gBAAgB,CAAmB;IAGnC,QAAQ,CAAe;IAGvB,QAAQ,CAAkB;IAG1B,GAAG,CAAsB;IAEnC,gBAAgB;QACd,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;QACzG,MAAM,EAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,E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ED,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAEnD,IAAI,QAAQ,CAAC,SAAS,EAAE;oBACtB,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;iBACtC;YACH,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;CACF,CAAA;AAhLC;IADC,QAAQ,CAAC,KAAK,CAAC;;yCACG;AAGnB;IADC,QAAQ,CAAC,UAAU,CAAC;;8CACe;AAGpC;IADC,QAAQ,CAAC,WAAW,CAAC;;+CACe;AAGrC;IADC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;;4CACH;AAGzB;IADC,QAAQ,CAAC,MAAM,CAAC;;0CACY;AAG7B;IADC,QAAQ,CAAC,eAAe,CAAC;;kDACK;AAG/B;IADC,MAAM,EAAE;8BACW,QAAQ;8CAAC;AAG7B;IADC,MAAM,EAAE;8BACmB,gBAAgB;sDAAC;AAG7C;IADC,MAAM,EAAE;8BACW,YAAY;8CAAC;AAGjC;IADC,MAAM,EAAE;8BACW,eAAe;8CAAC;AAGpC;IADC,MAAM,EAAE;8BACM,mBAAmB;yCAAC;AAlCxB,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CAoLxB;SApLY,YAAY","sourcesContent":["import {PlatformApplication} from \"@tsed/common\";\nimport {Env, setValue} from \"@tsed/core\";\nimport {Constant, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {Configuration, interactionPolicy, Provider as OIDCProvider} from \"oidc-provider\";\nimport {INTERACTIONS} from \"../constants/constants\";\nimport {OidcAccountsMethods} from \"../domain/OidcAccountsMethods\";\nimport {OidcSettings} from \"../domain/OidcSettings\";\nimport {OidcAdapters} from \"./OidcAdapters\";\nimport {OidcInteractions} from \"./OidcInteractions\";\nimport {OidcJwks} from \"./OidcJwks\";\n\n@Injectable()\nexport class OidcProvider {\n raw: OIDCProvider;\n\n @Constant(\"env\")\n protected env: Env;\n\n @Constant(\"httpPort\")\n protected httpPort: number | string;\n\n @Constant(\"httpsPort\")\n protected httpsPort: number | string;\n\n @Constant(\"oidc.issuer\", \"\")\n protected issuer: string;\n\n @Constant(\"oidc\")\n protected oidc: OidcSettings;\n\n @Constant(\"PLATFORM_NAME\")\n protected platformName: string;\n\n @Inject()\n protected oidcJwks: OidcJwks;\n\n @Inject()\n protected oidcInteractions: OidcInteractions;\n\n @Inject()\n protected adapters: OidcAdapters;\n\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected app: PlatformApplication;\n\n hasConfiguration() {\n return !!this.oidc;\n }\n\n async getConfiguration(): Promise<Configuration> {\n const [jwks, adapter] = await Promise.all([this.oidcJwks.getJwks(), this.adapters.createAdapterClass()]);\n const {issuer, jwksPath, secureKey, proxy, Accounts, secureCookies = this.env == Env.PROD, ...options} = this.oidc;\n\n const configuration: Configuration = {\n interactions: {\n /* istanbul ignore next */\n url: (ctx, interaction) => `interaction/${interaction.uid}`\n },\n ...options,\n adapter,\n jwks\n };\n\n if (Accounts) {\n configuration.findAccount = (ctx, id, token) => this.injector.get<OidcAccountsMethods>(Accounts)!.findAccount(id, token);\n }\n\n if (secureCookies) {\n setValue(configuration, \"cookies.short.secure\", true);\n setValue(configuration, \"cookies.long.secure\", true);\n }\n\n const policy = this.getPolicy();\n if (policy) {\n setValue(configuration, \"interactions.policy\", policy);\n }\n\n const url = this.getInteractionsUrl();\n if (url) {\n setValue(configuration, \"interactions.url\", url);\n }\n\n return configuration;\n }\n\n getIssuer() {\n if (this.issuer) {\n return this.issuer;\n }\n\n // istanbul ignore next\n if (this.httpsPort) {\n return `https://localhost:${this.httpsPort}`;\n }\n\n return `http://localhost:${this.httpPort}`;\n }\n\n get(): OIDCProvider {\n return this.raw;\n }\n\n /**\n * Create a new instance of OidcProvider\n */\n async create(): Promise<void | OIDCProvider> {\n const {proxy = this.env === Env.PROD, secureKey, allowHttpLocalhost = this.env !== Env.PROD} = this.oidc;\n const configuration = await this.getConfiguration();\n const oidcProvider = new OIDCProvider(this.getIssuer(), configuration);\n\n if (proxy) {\n // istanbul ignore next\n switch (this.platformName) {\n default:\n case \"express\":\n oidcProvider.proxy = true;\n break;\n case \"koa\":\n (this.app.rawApp as any).proxy = true;\n break;\n }\n }\n\n if (secureKey) {\n oidcProvider.app.keys = secureKey;\n }\n\n this.raw = oidcProvider;\n\n if (allowHttpLocalhost) {\n this.allowHttpLocalhost();\n }\n\n await this.injector.emit(\"$onCreateOIDC\", this.raw);\n\n return this.raw;\n }\n\n private getInteractionsUrl() {\n const provider = this.injector.getProviders().find((provider) => provider.subType === INTERACTIONS);\n\n if (provider) {\n return (ctx: any, interaction: any) => {\n // eslint-disable-line no-unused-vars\n return provider.path.replace(/:uid/, interaction.uid);\n };\n }\n }\n\n private allowHttpLocalhost() {\n const {invalidate: orig} = (this.raw.Client as any).Schema.prototype;\n\n (this.raw.Client as any).Schema.prototype.invalidate = function invalidate(message: string, code: string) {\n if (code === \"implicit-force-https\" || code === \"implicit-forbid-localhost\") {\n return;\n }\n\n /* istanbul ignore next */\n return orig.call(this, message);\n };\n }\n\n private getPolicy() {\n const policy = interactionPolicy.base();\n const interactions = this.oidcInteractions.getInteractions();\n\n if (interactions.length) {\n interactions.forEach((provider) => {\n const {name, ...options} = provider.store.get(\"interactionOptions\");\n\n if (!policy.get(name)) {\n policy.add(\n new interactionPolicy.Prompt({\n name,\n ...options\n })\n );\n }\n\n const instance = this.injector.get(provider.token);\n\n if (instance.$onCreate) {\n instance.$onCreate(policy.get(name));\n }\n });\n }\n\n return this.injector.alter(\"$alterOidcPolicy\", policy);\n }\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { InjectorService, PlatformApplication } from "@tsed/common";
|
|
2
2
|
import { OidcProvider } from "./services/OidcProvider";
|
|
3
3
|
export declare class OidcModule {
|
|
4
|
-
app: PlatformApplication;
|
|
5
|
-
platformName: string;
|
|
6
|
-
basePath: string;
|
|
7
|
-
oidcProvider: OidcProvider;
|
|
8
|
-
injector: InjectorService;
|
|
4
|
+
protected app: PlatformApplication;
|
|
5
|
+
protected platformName: string;
|
|
6
|
+
protected basePath: string;
|
|
7
|
+
protected oidcProvider: OidcProvider;
|
|
8
|
+
protected injector: InjectorService;
|
|
9
9
|
$onInit(): Promise<void>;
|
|
10
10
|
$onRoutesInit(): Promise<void>;
|
|
11
11
|
$afterRoutesInit(): Promise<void>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { PlatformContext } from "@tsed/common";
|
|
2
1
|
import { Provider, Account } from "oidc-provider";
|
|
3
2
|
export declare type AuthorizationCode = InstanceType<Provider["AuthorizationCode"]>;
|
|
4
3
|
export declare type AccessToken = InstanceType<Provider["AccessToken"]>;
|
|
5
4
|
export declare type DeviceCode = InstanceType<Provider["DeviceCode"]>;
|
|
6
5
|
export declare type BackchannelAuthenticationRequest = InstanceType<Provider["BackchannelAuthenticationRequest"]>;
|
|
7
6
|
export interface OidcAccountsMethods {
|
|
8
|
-
findAccount(id: string, token: AuthorizationCode | AccessToken | DeviceCode | BackchannelAuthenticationRequest | undefined
|
|
7
|
+
findAccount(id: string, token: AuthorizationCode | AccessToken | DeviceCode | BackchannelAuthenticationRequest | undefined): Promise<Account | undefined>;
|
|
9
8
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UnknownObject } from "oidc-provider";
|
|
2
|
+
import { OidcClient } from "./interfaces";
|
|
3
|
+
export declare type OidcInteractionPromptProps<Props = Record<string, any>> = {
|
|
4
|
+
client: OidcClient;
|
|
5
|
+
uid: string;
|
|
6
|
+
grantId: string;
|
|
7
|
+
details: UnknownObject;
|
|
8
|
+
params: Record<string, any>;
|
|
9
|
+
} & Props;
|
|
@@ -3,12 +3,16 @@ import { JwksKeyParameters } from "@tsed/jwks";
|
|
|
3
3
|
import { Configuration } from "oidc-provider";
|
|
4
4
|
import { OidcAccountsMethods } from "./OidcAccountsMethods";
|
|
5
5
|
export interface OidcSettings extends Configuration {
|
|
6
|
+
/**
|
|
7
|
+
* force the secure cookie. By default, in dev mode it's disabled and in production it's enabled.
|
|
8
|
+
*/
|
|
9
|
+
secureCookies?: boolean;
|
|
6
10
|
/**
|
|
7
11
|
* Path on which the oidc-provider instance is mounted.
|
|
8
12
|
*/
|
|
9
13
|
path?: string;
|
|
10
14
|
/**
|
|
11
|
-
* Issuer URI. By default Ts.ED create issuer with http://localhost:${httpPort}
|
|
15
|
+
* Issuer URI. By default, Ts.ED create issuer with http://localhost:${httpPort}
|
|
12
16
|
*/
|
|
13
17
|
issuer?: string;
|
|
14
18
|
/**
|
|
@@ -27,6 +31,10 @@ export interface OidcSettings extends Configuration {
|
|
|
27
31
|
* Enable proxy.
|
|
28
32
|
*/
|
|
29
33
|
proxy?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Allow redirect_uri on HTTP protocol and localhost domain.
|
|
36
|
+
*/
|
|
37
|
+
allowHttpLocalhost?: boolean;
|
|
30
38
|
/**
|
|
31
39
|
* Injectable service to manage accounts.
|
|
32
40
|
*/
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,9 +13,11 @@ export * from "./decorators/params";
|
|
|
13
13
|
export * from "./decorators/prompt";
|
|
14
14
|
export * from "./decorators/uid";
|
|
15
15
|
export * from "./domain/OidcAccountsMethods";
|
|
16
|
+
export * from "./domain/OidcBadInteractionName";
|
|
16
17
|
export * from "./domain/OidcInteraction";
|
|
17
18
|
export * from "./domain/OidcInteractionMethods";
|
|
18
19
|
export * from "./domain/OidcInteractionOptions";
|
|
20
|
+
export * from "./domain/OidcInteractionPromptProps";
|
|
19
21
|
export * from "./domain/OidcSettings";
|
|
20
22
|
export * from "./domain/interfaces";
|
|
21
23
|
export * from "./middlewares/OidcInteractionMiddleware";
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OidcInteractions } from "../services/OidcInteractions";
|
|
1
|
+
import { OidcInteractionContext } from "../services/OidcInteractionContext";
|
|
3
2
|
export declare class OidcInteractionMiddleware {
|
|
4
|
-
protected
|
|
5
|
-
|
|
6
|
-
use(context: Context): Promise<void>;
|
|
3
|
+
protected oidcInteractionContext: OidcInteractionContext;
|
|
4
|
+
use(): Promise<void>;
|
|
7
5
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Adapters } from "@tsed/adapters";
|
|
2
|
-
import { AdapterConstructor } from "oidc-provider";
|
|
1
|
+
import { Adapter, Adapters } from "@tsed/adapters";
|
|
2
|
+
import { Adapter as OidcAdapter, AdapterConstructor } from "oidc-provider";
|
|
3
|
+
export declare type OidcAdapterMethods<Model = any> = Adapter<Model> & Partial<Omit<OidcAdapter, "upsert">>;
|
|
3
4
|
export declare class OidcAdapters {
|
|
4
5
|
protected adapters: Adapters;
|
|
5
6
|
createAdapterClass(): AdapterConstructor;
|
|
@@ -4,14 +4,15 @@ import { Account, InteractionResults, PromptDetail, Provider } from "oidc-provid
|
|
|
4
4
|
import { OidcSession } from "../decorators/oidcSession";
|
|
5
5
|
import { OidcClient } from "../domain/interfaces";
|
|
6
6
|
import { OidcInteraction } from "../domain/OidcInteraction";
|
|
7
|
+
import { OidcInteractionPromptProps } from "../domain/OidcInteractionPromptProps";
|
|
7
8
|
import { OidcInteractions } from "./OidcInteractions";
|
|
8
9
|
import { OidcProvider } from "./OidcProvider";
|
|
9
10
|
export declare class OidcInteractionContext {
|
|
10
11
|
env: Env;
|
|
11
12
|
protected oidcProvider: OidcProvider;
|
|
12
13
|
protected oidcInteractions: OidcInteractions;
|
|
13
|
-
protected
|
|
14
|
-
|
|
14
|
+
protected $ctx: PlatformContext;
|
|
15
|
+
get raw(): OidcInteraction;
|
|
15
16
|
get session(): OidcSession | undefined;
|
|
16
17
|
get prompt(): PromptDetail;
|
|
17
18
|
get params(): Record<string, any>;
|
|
@@ -25,10 +26,13 @@ export declare class OidcInteractionContext {
|
|
|
25
26
|
interactionResult(result: InteractionResults, options?: {
|
|
26
27
|
mergeWithLastSubmission?: boolean;
|
|
27
28
|
}): Promise<string>;
|
|
29
|
+
interactionPrompt(options: Record<string, any>): Promise<OidcInteractionPromptProps>;
|
|
28
30
|
render(view: string, result: any): Promise<string>;
|
|
29
31
|
save(ttl: number): Promise<string>;
|
|
30
32
|
findClient(clientId?: string): Promise<OidcClient | undefined>;
|
|
31
33
|
findAccount(sub?: string, token?: any): Promise<Account | undefined>;
|
|
32
34
|
getGrant(): Promise<InstanceType<Provider["Grant"]>>;
|
|
35
|
+
checkInteractionName(name: string): void;
|
|
36
|
+
checkClientId(clientId?: any): Promise<void>;
|
|
33
37
|
debug(obj?: any): any;
|
|
34
38
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { PlatformApplication } from "@tsed/common";
|
|
1
2
|
import { Env } from "@tsed/core";
|
|
2
3
|
import { InjectorService } from "@tsed/di";
|
|
3
|
-
import { Provider as OIDCProvider
|
|
4
|
+
import { Configuration, Provider as OIDCProvider } from "oidc-provider";
|
|
5
|
+
import { OidcSettings } from "../domain/OidcSettings";
|
|
4
6
|
import { OidcAdapters } from "./OidcAdapters";
|
|
5
7
|
import { OidcInteractions } from "./OidcInteractions";
|
|
6
8
|
import { OidcJwks } from "./OidcJwks";
|
|
7
|
-
import { PlatformApplication } from "@tsed/common";
|
|
8
|
-
import { OidcSettings } from "../domain/OidcSettings";
|
|
9
9
|
export declare class OidcProvider {
|
|
10
10
|
raw: OIDCProvider;
|
|
11
11
|
protected env: Env;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/oidc-provider",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-rc.1",
|
|
4
4
|
"description": "OIDC provider package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -19,30 +19,30 @@
|
|
|
19
19
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
20
20
|
"start": "ts-node -r tsconfig-paths/register test/app/index.ts",
|
|
21
21
|
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
22
|
-
"test": "cross-env NODE_ENV=test
|
|
22
|
+
"test": "cross-env NODE_ENV=test yarn jest --max-workers=2"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@tsed/adapters": "7.0.0-
|
|
25
|
+
"@tsed/adapters": "7.0.0-rc.1",
|
|
26
26
|
"express-urlrewrite": "^1.4.0",
|
|
27
27
|
"jose2": "npm:jose@^2.0.4",
|
|
28
28
|
"koa-mount": "^4.0.0",
|
|
29
29
|
"koa-rewrite": "^3.0.1",
|
|
30
|
-
"tslib": "2.
|
|
30
|
+
"tslib": "2.4.0",
|
|
31
31
|
"uuid": "8.3.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@tsed/common": "7.0.0-
|
|
35
|
-
"@tsed/core": "7.0.0-
|
|
36
|
-
"@tsed/di": "7.0.0-
|
|
37
|
-
"@tsed/exceptions": "7.0.0-
|
|
34
|
+
"@tsed/common": "7.0.0-rc.1",
|
|
35
|
+
"@tsed/core": "7.0.0-rc.1",
|
|
36
|
+
"@tsed/di": "7.0.0-rc.1",
|
|
37
|
+
"@tsed/exceptions": "7.0.0-rc.1",
|
|
38
38
|
"@types/lowdb": "1.0.11",
|
|
39
39
|
"@types/oidc-provider": "^7.1.1",
|
|
40
40
|
"@types/uuid": "8.3.4",
|
|
41
41
|
"lowdb": "3.0.0",
|
|
42
|
-
"oidc-provider": "7.
|
|
42
|
+
"oidc-provider": "7.11.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@tsed/common": "^7.0.0-
|
|
45
|
+
"@tsed/common": "^7.0.0-rc.1",
|
|
46
46
|
"oidc-provider": ">=7.3.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
@@ -54,7 +54,10 @@
|
|
|
54
54
|
"bugs": {
|
|
55
55
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
56
56
|
},
|
|
57
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
57
|
+
"homepage": "https://github.com/tsedio/tsed/tree/rc/packages/security/oidc-provider",
|
|
58
58
|
"author": "Romain Lenzotti",
|
|
59
|
-
"license": "MIT"
|
|
59
|
+
"license": "MIT",
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"tag": "rc"
|
|
62
|
+
}
|
|
60
63
|
}
|
package/readme.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
12
12
|
[](https://github.com/semantic-release/semantic-release)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/sponsors/romakita)
|
|
15
|
+
[](https://opencollective.com/tsed)
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
|
|
@@ -61,6 +62,7 @@ import {MemoryAdapter} from "../adapters/MemoryAdapter";
|
|
|
61
62
|
jwksPath: `./../keys/jwks.json`, // don't forget add this path to .gitignore
|
|
62
63
|
Adapter: MemoryAdapter,
|
|
63
64
|
Accounts: Accounts,
|
|
65
|
+
allowHttpLocalhost: false, // by default. true in dev mode and false in production
|
|
64
66
|
// Clients: Clients,
|
|
65
67
|
clients: [
|
|
66
68
|
{
|
|
@@ -105,7 +107,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
|
|
105
107
|
|
|
106
108
|
The MIT License (MIT)
|
|
107
109
|
|
|
108
|
-
Copyright (c) 2016 -
|
|
110
|
+
Copyright (c) 2016 - 2022 Romain Lenzotti
|
|
109
111
|
|
|
110
112
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
111
113
|
|
package/.mocharc.js
DELETED
package/.nycrc
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": [
|
|
3
|
-
"src/**/*.ts"
|
|
4
|
-
],
|
|
5
|
-
"exclude": [
|
|
6
|
-
"**/*.d.ts",
|
|
7
|
-
"node_modules",
|
|
8
|
-
"**/interfaces/**",
|
|
9
|
-
"**/index.ts",
|
|
10
|
-
"**/*.spec.ts"
|
|
11
|
-
],
|
|
12
|
-
"extension": [
|
|
13
|
-
".ts"
|
|
14
|
-
],
|
|
15
|
-
"require": [],
|
|
16
|
-
"reporter": [
|
|
17
|
-
"text-summary",
|
|
18
|
-
"html",
|
|
19
|
-
"lcov",
|
|
20
|
-
"json"
|
|
21
|
-
],
|
|
22
|
-
"check-coverage": true,
|
|
23
|
-
"statements": 99.67,
|
|
24
|
-
"branches": 77.36,
|
|
25
|
-
"functions": 96.07,
|
|
26
|
-
"lines": 99.65
|
|
27
|
-
}
|