@owlmeans/server-oidc-provider 0.1.18-rc.47 → 0.1.18-rc.49
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/README.md +2 -2
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-oidc-provider/SKILL.md +1 -1
- package/build/iam.d.ts +1 -28
- package/build/iam.d.ts.map +1 -1
- package/build/iam.js.map +1 -1
- package/build/service.d.ts.map +1 -1
- package/build/service.js +33 -17
- package/build/service.js.map +1 -1
- package/build/types.d.ts +28 -0
- package/build/types.d.ts.map +1 -1
- package/build/utils/client.d.ts.map +1 -1
- package/build/utils/client.js +7 -6
- package/build/utils/client.js.map +1 -1
- package/build/utils/config.d.ts.map +1 -1
- package/build/utils/config.js +4 -2
- package/build/utils/config.js.map +1 -1
- package/build/utils/consts.d.ts +3 -0
- package/build/utils/consts.d.ts.map +1 -0
- package/build/utils/consts.js +3 -0
- package/build/utils/consts.js.map +1 -0
- package/build/utils/policy.d.ts +0 -2
- package/build/utils/policy.d.ts.map +1 -1
- package/build/utils/policy.js +1 -2
- package/build/utils/policy.js.map +1 -1
- package/package.json +17 -16
- package/src/iam.ts +2 -27
- package/src/service.ts +38 -21
- package/src/types.ts +28 -0
- package/src/utils/client.ts +8 -7
- package/src/utils/config.ts +6 -2
- package/src/utils/consts.ts +2 -0
- package/src/utils/policy.ts +1 -3
- package/tests/pairwise.spec.ts +1 -1
- package/tests/policy.spec.ts +3 -3
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Embedded OIDC identity provider — wraps the `oidc-provider` library as an OwlM
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
bun add @owlmeans/server-oidc-provider@^0.1.18-rc.
|
|
17
|
+
bun add @owlmeans/server-oidc-provider@^0.1.18-rc.49
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Usage
|
|
@@ -72,7 +72,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
72
72
|
your project's skill store (`.agents/skills/`):
|
|
73
73
|
|
|
74
74
|
```sh
|
|
75
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
75
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.48
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/server-oidc-provider",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"version": "0.1.18-rc.49",
|
|
5
|
+
"generatedAt": "2026-10-05T08:32:19.130Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -8,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/server-oidc-provider
|
|
9
9
|
|
|
10
10
|
**Layer:** Server
|
|
11
|
-
**Install:** `"@owlmeans/server-oidc-provider": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/server-oidc-provider": "^0.1.18-rc.49"` in `dependencies`
|
|
12
12
|
**Runtime deps:** `oidc-provider@9.11.1` (exact), `jose@6.2.5` (exact), `@types/oidc-provider@9.5.0`
|
|
13
13
|
|
|
14
14
|
Use this only when your service **is** the identity provider. For consuming someone else's issuer,
|
package/build/iam.d.ts
CHANGED
|
@@ -1,31 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/** A registered OIDC client stored in the provider's Client adapter. */
|
|
3
|
-
export interface OidcRegisteredClient {
|
|
4
|
-
clientId: string;
|
|
5
|
-
secret: string;
|
|
6
|
-
/** The entity (realm) this client belongs to — used for identity scoping. */
|
|
7
|
-
entityId?: string;
|
|
8
|
-
/** Application display name */
|
|
9
|
-
name?: string;
|
|
10
|
-
redirectUris?: string[];
|
|
11
|
-
grantTypes?: string[];
|
|
12
|
-
responseTypes?: string[];
|
|
13
|
-
scope?: string;
|
|
14
|
-
}
|
|
15
|
-
/** Full oidc-provider ClientMetadata with our entity extension. */
|
|
16
|
-
export type OidcClientMetadata = ClientMetadata & {
|
|
17
|
-
entityId?: string;
|
|
18
|
-
owlEntityId?: string;
|
|
19
|
-
};
|
|
1
|
+
import type { OidcClientMetadata, OidcRegisteredClient } from './types.js';
|
|
20
2
|
/** Convert an OidcRegisteredClient to the oidc-provider ClientMetadata shape. */
|
|
21
3
|
export declare const toClientMetadata: (client: OidcRegisteredClient) => OidcClientMetadata;
|
|
22
|
-
/** Extension seam for IAM integration into the OIDC provider — Phase 2 fills this */
|
|
23
|
-
export interface OidcProviderIamExtension {
|
|
24
|
-
/** Convert a stored client record to oidc-provider ClientMetadata */
|
|
25
|
-
toClientMetadata: typeof toClientMetadata;
|
|
26
|
-
/** Type of a stored client record */
|
|
27
|
-
OidcRegisteredClient: OidcRegisteredClient;
|
|
28
|
-
/** Extended metadata type */
|
|
29
|
-
OidcClientMetadata: OidcClientMetadata;
|
|
30
|
-
}
|
|
31
4
|
//# sourceMappingURL=iam.d.ts.map
|
package/build/iam.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iam.d.ts","sourceRoot":"","sources":["../src/iam.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"iam.d.ts","sourceRoot":"","sources":["../src/iam.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAE1E,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,WAAY,oBAAoB,KAAG,kBAS9D,CAAA"}
|
package/build/iam.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iam.js","sourceRoot":"","sources":["../src/iam.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"iam.js","sourceRoot":"","sources":["../src/iam.ts"],"names":[],"mappings":"AAGA,iFAAiF;AACjF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAA4B,EAAsB,EAAE,CAAC,CAAC;IACrF,SAAS,EAAE,MAAM,CAAC,QAAQ;IAC1B,aAAa,EAAE,MAAM,CAAC,MAAM;IAC5B,aAAa,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE;IACxC,WAAW,EAAE,MAAM,CAAC,UAAU,IAAI,CAAC,oBAAoB,EAAE,eAAe,CAAC;IACzE,cAAc,EAAE,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,MAAM,CAAC,CAAmB;IACpE,0BAA0B,EAAE,qBAAqB;IACjD,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,+BAA+B;IACtD,WAAW,EAAE,MAAM,CAAC,QAAQ;CAC7B,CAAC,CAAA"}
|
package/build/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAA0C,mBAAmB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAA0C,mBAAmB,EAAE,MAAM,YAAY,CAAA;AA2C9G,eAAO,MAAM,yBAAyB,WAAW,MAAM,KAAmB,mBAqGzE,CAAA;AAED,eAAO,MAAM,yBAAyB,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,OACzE,CAAC,UAAS,MAAM,KACpB,CAOF,CAAA"}
|
package/build/service.js
CHANGED
|
@@ -2,10 +2,38 @@ import { assertContext, createService } from '@owlmeans/context';
|
|
|
2
2
|
import { DEFAULT_ALIAS, OIDC_ACCOUNT_SERVICE } from './consts.js';
|
|
3
3
|
import { DEFAULT_PATH, INTERACTION, INTERACTION_UID } from '@owlmeans/oidc';
|
|
4
4
|
import Provider from 'oidc-provider';
|
|
5
|
+
import { logger } from '@owlmeans/log';
|
|
5
6
|
import { PARAM, SEP } from '@owlmeans/route';
|
|
6
7
|
import { makeSecurityHelper } from '@owlmeans/config';
|
|
7
8
|
import { combineConfig } from './utils/config.js';
|
|
8
9
|
import { makeInteractionPolicy } from './utils/policy.js';
|
|
10
|
+
const log = logger('server-oidc-provider');
|
|
11
|
+
/** An OIDC error the provider answers with a 4xx — the client's mistake, not the provider's. */
|
|
12
|
+
const isClientError = (error) => {
|
|
13
|
+
const status = error?.status;
|
|
14
|
+
return typeof status === 'number' && status >= 400 && status < 500;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* One provider error. The state dump carries ids only — never a token, code or secret the
|
|
18
|
+
* request holds.
|
|
19
|
+
*/
|
|
20
|
+
const reportProviderError = (issuer, kind, ctx, error) => {
|
|
21
|
+
const state = ctx?.oidc;
|
|
22
|
+
const data = { kind, issuer, clientId: state?.client?.clientId, code: error.error, error };
|
|
23
|
+
if (isClientError(error)) {
|
|
24
|
+
log.warn('OIDC provider refused a request', data);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
log.error('OIDC provider error', data);
|
|
28
|
+
}
|
|
29
|
+
if (state != null && log.enabled('debug')) {
|
|
30
|
+
log.debug('OIDC provider error state', {
|
|
31
|
+
kind, fields: Object.getOwnPropertyNames(state),
|
|
32
|
+
grant: state.grant != null
|
|
33
|
+
? { grantId: state.grant.jti, accountId: state.grant.accountId, clientId: state.grant.clientId } : undefined,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
9
37
|
let _initializedOidc = undefined;
|
|
10
38
|
export const createOidcProviderService = (alias = DEFAULT_ALIAS) => {
|
|
11
39
|
const service = createService(alias, {
|
|
@@ -73,23 +101,11 @@ export const createOidcProviderService = (alias = DEFAULT_ALIAS) => {
|
|
|
73
101
|
next();
|
|
74
102
|
});
|
|
75
103
|
api.server.use(base, oidc.callback());
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
oidc.on('server_error', (ctx, error) => {
|
|
83
|
-
console.warn('SERVER ERROR .......: ', Object.getOwnPropertyNames(ctx.oidc));
|
|
84
|
-
console.info(ctx.oidc.grant);
|
|
85
|
-
console.error('!!!! SERVER ERROR: ', error);
|
|
86
|
-
});
|
|
87
|
-
oidc.on('userinfo.error', (ctx, error) => {
|
|
88
|
-
console.warn('USER INFO ERROR .......: ', Object.getOwnPropertyNames(ctx.oidc));
|
|
89
|
-
console.info(ctx.oidc.grant);
|
|
90
|
-
console.error('!!!! USER INFO ERROR: ', error);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
104
|
+
// Always attached: a provider error reaches the log — at `warn` when the client caused it
|
|
105
|
+
// (an OIDC 4xx such as `invalid_grant`), at `error` otherwise; the request state at `debug`.
|
|
106
|
+
oidc.on('grant.error', (ctx, error) => { reportProviderError(oidc.issuer, 'grant', ctx, error); });
|
|
107
|
+
oidc.on('server_error', (ctx, error) => { reportProviderError(oidc.issuer, 'server', ctx, error); });
|
|
108
|
+
oidc.on('userinfo.error', (ctx, error) => { reportProviderError(oidc.issuer, 'userinfo', ctx, error); });
|
|
93
109
|
_initializedOidc = service.oidc = oidc;
|
|
94
110
|
},
|
|
95
111
|
instance: () => {
|
package/build/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAG3E,OAAO,QA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IAChD,MAAM,OAAO,GAAG,GAAQ,CAAA;IAExB,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAEhC,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
package/build/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { OidcSharedConfig } from '@owlmeans/oidc';
|
|
|
3
3
|
import type { ApiServer, ApiServerAppend } from '@owlmeans/server-api';
|
|
4
4
|
import type { ServerConfig, ServerContext } from '@owlmeans/server-context';
|
|
5
5
|
import type { Account, Adapter, ClientMetadata, Configuration, Interaction, Provider } from 'oidc-provider';
|
|
6
|
+
import { toClientMetadata } from './iam.js';
|
|
6
7
|
export interface OidcProviderService extends InitializedService {
|
|
7
8
|
oidc: Provider;
|
|
8
9
|
update: (api: ApiServer) => Promise<void>;
|
|
@@ -64,4 +65,31 @@ export interface Config extends ServerConfig, OidcConfigAppend {
|
|
|
64
65
|
}
|
|
65
66
|
export interface Context<C extends Config = Config> extends ServerContext<C>, ApiServerAppend {
|
|
66
67
|
}
|
|
68
|
+
/** A registered OIDC client stored in the provider's Client adapter. */
|
|
69
|
+
export interface OidcRegisteredClient {
|
|
70
|
+
clientId: string;
|
|
71
|
+
secret: string;
|
|
72
|
+
/** The entity (realm) this client belongs to — used for identity scoping. */
|
|
73
|
+
entityId?: string;
|
|
74
|
+
/** Application display name */
|
|
75
|
+
name?: string;
|
|
76
|
+
redirectUris?: string[];
|
|
77
|
+
grantTypes?: string[];
|
|
78
|
+
responseTypes?: string[];
|
|
79
|
+
scope?: string;
|
|
80
|
+
}
|
|
81
|
+
/** Full oidc-provider ClientMetadata with our entity extension. */
|
|
82
|
+
export type OidcClientMetadata = ClientMetadata & {
|
|
83
|
+
entityId?: string;
|
|
84
|
+
owlEntityId?: string;
|
|
85
|
+
};
|
|
86
|
+
/** Extension seam for IAM integration into the OIDC provider — Phase 2 fills this */
|
|
87
|
+
export interface OidcProviderIamExtension {
|
|
88
|
+
/** Convert a stored client record to oidc-provider ClientMetadata */
|
|
89
|
+
toClientMetadata: typeof toClientMetadata;
|
|
90
|
+
/** Type of a stored client record */
|
|
91
|
+
OidcRegisteredClient: OidcRegisteredClient;
|
|
92
|
+
/** Extended metadata type */
|
|
93
|
+
OidcClientMetadata: OidcClientMetadata;
|
|
94
|
+
}
|
|
67
95
|
//# sourceMappingURL=types.d.ts.map
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC3G,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,MAAM,WAAW,m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IACrE,gBAAgB,EAAE,OAAO,gBAAgB,CAAA;IACzC,qCAAqC;IACrC,oBAAoB,EAAE,oBAAoB,CAAA;IAC1C,6BAA6B;IAC7B,kBAAkB,EAAE,kBAAkB,CAAA;CACvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/utils/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EAAU,OAAO,EAAE,MAAM,aAAa,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/utils/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EAAU,OAAO,EAAE,MAAM,aAAa,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAMtD,eAAO,MAAM,YAAY,YAAa,OAAO,UAAU,cAAc,KAAG,cAkBvE,CAAA;AAED,qGAAqG;AACrG,eAAO,MAAM,cAAc,YAAa,OAAO,UAAU,cAAc,WAAW,MAAM,KAAG,MAS1F,CAAA"}
|
package/build/utils/client.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { randomBytes } from '@noble/hashes/utils';
|
|
1
|
+
import { randomBytes } from '@noble/hashes/utils.js';
|
|
2
2
|
import { hex } from '@scure/base';
|
|
3
3
|
import { makeSecurityHelper } from '@owlmeans/config';
|
|
4
4
|
import { SEP } from '@owlmeans/route';
|
|
5
|
+
import { logger } from '@owlmeans/log';
|
|
6
|
+
const log = logger('server-oidc-provider');
|
|
5
7
|
export const updateClient = (context, client) => {
|
|
6
8
|
if (client.client_secret == null) {
|
|
7
9
|
if (!context.cfg.debug.all && !context.cfg.debug.oidc) {
|
|
8
10
|
throw new SyntaxError('Client secret is required');
|
|
9
11
|
}
|
|
10
12
|
client.client_secret = hex.encode(randomBytes(32));
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
console.info('\n');
|
|
13
|
+
// The secret itself is never written to a log.
|
|
14
|
+
log.warn('Exceptionally insecure: a client secret was generated for an OIDC client (debug only)', {
|
|
15
|
+
clientId: client.client_id,
|
|
16
|
+
});
|
|
16
17
|
}
|
|
17
18
|
const helper = makeSecurityHelper(context);
|
|
18
19
|
const updateUri = makeUriUpdater(context, helper);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/utils/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/utils/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAGjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,MAAM,GAAG,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAA;AAE1C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAE,MAAsB,EAAkB,EAAE;IACvF,IAAI,MAAM,CAAC,aAAa,IAAI,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YACtD,MAAM,IAAI,WAAW,CAAC,2BAA2B,CAAC,CAAA;QACpD,CAAC;QACD,MAAM,CAAC,aAAa,GAAG,GAAG,CAAC,M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AuB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAUnE,eAAO,MAAM,aAAa,YAAmB,OAAO,aAAa,OAAO,KAAG,OAAO,CAAC,uBAAuB,CAiDzG,CAAA"}
|
package/build/utils/config.js
CHANGED
|
@@ -2,6 +2,8 @@ import { makeUriUpdater, updateClient } from './client.js';
|
|
|
2
2
|
import { ORGANIZATIONS_CLAIM, ORGANIZATIONS_SCOPE, PERMISSIONS_CLAIM, PERMISSIONS_SCOPE } from '@owlmeans/oidc';
|
|
3
3
|
import { makeSecurityHelper } from '@owlmeans/config';
|
|
4
4
|
import * as jose from 'jose';
|
|
5
|
+
/** A claim list is an array, or (as the provider's types also allow) a record keyed by claim name. */
|
|
6
|
+
const claimNamesOf = (claims) => claims == null ? [] : Array.isArray(claims) ? claims : Object.keys(claims);
|
|
5
7
|
export const combineConfig = async (context, _unsecure) => {
|
|
6
8
|
const cfg = context.cfg.oidc;
|
|
7
9
|
const updateUri = makeUriUpdater(context, makeSecurityHelper(context));
|
|
@@ -12,10 +14,10 @@ export const combineConfig = async (context, _unsecure) => {
|
|
|
12
14
|
...(cfg.customConfiguration?.clients ?? [])
|
|
13
15
|
].map(client => updateClient(context, client)),
|
|
14
16
|
claims: {
|
|
15
|
-
email: ['email', 'email_verified', ...cfg.customConfiguration?.claims?.email
|
|
17
|
+
email: ['email', 'email_verified', ...claimNamesOf(cfg.customConfiguration?.claims?.email)],
|
|
16
18
|
profile: [
|
|
17
19
|
'username', 'family_name', 'given_name', 'locale', 'name', 'nickname', 'preferred_username',
|
|
18
|
-
...cfg.customConfiguration?.claims?.profile
|
|
20
|
+
...claimNamesOf(cfg.customConfiguration?.claims?.profile)
|
|
19
21
|
],
|
|
20
22
|
// Inert unless the account service actually emits the claim (integrated IAM mode)
|
|
21
23
|
[PERMISSIONS_SCOPE]: [PERMISSIONS_CLAIM],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAC/G,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,OAAgB,EAAE,SAAkB,EAAoC,EAAE;IAC5G,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA;IAC5B,MAAM,SAAS,GAAG,cAAc,CAAC,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAA;IAEtE,MAAM,aAAa,GAA4B;QAC7C,GAAG,GAAG,CAAC,mBAAmB;QAC1B,OAAO,EAAE;YACP,GAAG,GAAG,CAAC,OAAO;YACd,GAAG,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,IAAI,EAAE,CAAC;SAC5C,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9C,MAAM,EAAE;YACN,KAAK,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,GAAG,CAAC,mBAAmB,EAAE,MAAM,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,M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,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../src/utils/consts.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAA"}
|
package/build/utils/policy.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { interactionPolicy } from 'oidc-provider';
|
|
2
|
-
/** The `reason` of the login check this module adds to the provider's default policy. */
|
|
3
|
-
export declare const ACCOUNT_REFUSED_REASON = "account_refused";
|
|
4
2
|
/**
|
|
5
3
|
* The provider's default interaction policy plus one login check: a session whose account the
|
|
6
4
|
* application REFUSED to load is a session that identifies nobody, so the person logs in again.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/utils/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,iBAAiB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/utils/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,qBAAqB,QAAO,iBAAiB,CAAC,aAqB1D,CAAA"}
|
package/build/utils/policy.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { errors, interactionPolicy } from 'oidc-provider';
|
|
2
|
-
|
|
3
|
-
export const ACCOUNT_REFUSED_REASON = 'account_refused';
|
|
2
|
+
import { ACCOUNT_REFUSED_REASON } from './consts.js';
|
|
4
3
|
/**
|
|
5
4
|
* The provider's default interaction policy plus one login check: a session whose account the
|
|
6
5
|
* application REFUSED to load is a session that identifies nobody, so the person logs in again.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/utils/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/utils/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAoC,EAAE;IACzE,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,CAAA;IAEvC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,iBAAiB,CAAC,KAAK,CACzD,sBAAsB,EACtB,8DAA8D,EAC9D,gBAAgB,EAChB,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;QACX,IAAI,IAAI,CAAC,OAAO,EAAE,SAAS,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;YAC5D,OAAO,iBAAiB,CAAC,KAAK,CAAC,iBAAiB,CAAA;QAClD,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,4CAA4C,CAAC,CAAA;QACxF,CAAC;QAED,OAAO,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAA;IAC/C,CAAC,CACF,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/server-oidc-provider",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.49",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@owlmeans/dep-config": "workspace:*",
|
|
26
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
27
|
-
"@types/bun": "^1.4.
|
|
28
|
-
"@types/node": "^26.
|
|
29
|
-
"@types/oidc-provider": "9.
|
|
26
|
+
"@owlmeans/context": "^0.1.18-rc.33",
|
|
27
|
+
"@types/bun": "^1.4.2",
|
|
28
|
+
"@types/node": "^26.6.4",
|
|
29
|
+
"@types/oidc-provider": "9.12.1",
|
|
30
30
|
"nodemon": "^3.1.14",
|
|
31
31
|
"typescript": "^7.0.2"
|
|
32
32
|
},
|
|
@@ -34,17 +34,18 @@
|
|
|
34
34
|
"fastify": "*"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@noble/hashes": "^
|
|
38
|
-
"@owlmeans/config": "^0.1.18-rc.
|
|
39
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
40
|
-
"@owlmeans/entrypoint": "^0.1.18-rc.
|
|
41
|
-
"@owlmeans/
|
|
42
|
-
"@owlmeans/
|
|
43
|
-
"@owlmeans/
|
|
44
|
-
"@owlmeans/server-
|
|
45
|
-
"@
|
|
46
|
-
"
|
|
47
|
-
"
|
|
37
|
+
"@noble/hashes": "^2.4.0",
|
|
38
|
+
"@owlmeans/config": "^0.1.18-rc.43",
|
|
39
|
+
"@owlmeans/context": "^0.1.18-rc.33",
|
|
40
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.40",
|
|
41
|
+
"@owlmeans/log": "^0.1.18-rc.1",
|
|
42
|
+
"@owlmeans/oidc": "^0.1.18-rc.54",
|
|
43
|
+
"@owlmeans/route": "^0.1.18-rc.34",
|
|
44
|
+
"@owlmeans/server-api": "^0.1.18-rc.50",
|
|
45
|
+
"@owlmeans/server-context": "^0.1.18-rc.42",
|
|
46
|
+
"@scure/base": "^2.4.0",
|
|
47
|
+
"jose": "6.2.12",
|
|
48
|
+
"oidc-provider": "9.12.2"
|
|
48
49
|
},
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|
package/src/iam.ts
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
/** A registered OIDC client stored in the provider's Client adapter. */
|
|
4
|
-
export interface OidcRegisteredClient {
|
|
5
|
-
clientId: string
|
|
6
|
-
secret: string
|
|
7
|
-
/** The entity (realm) this client belongs to — used for identity scoping. */
|
|
8
|
-
entityId?: string
|
|
9
|
-
/** Application display name */
|
|
10
|
-
name?: string
|
|
11
|
-
redirectUris?: string[]
|
|
12
|
-
grantTypes?: string[]
|
|
13
|
-
responseTypes?: string[]
|
|
14
|
-
scope?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** Full oidc-provider ClientMetadata with our entity extension. */
|
|
18
|
-
export type OidcClientMetadata = ClientMetadata & { entityId?: string; owlEntityId?: string }
|
|
1
|
+
import type { ResponseType } from 'oidc-provider'
|
|
2
|
+
import type { OidcClientMetadata, OidcRegisteredClient } from './types.js'
|
|
19
3
|
|
|
20
4
|
/** Convert an OidcRegisteredClient to the oidc-provider ClientMetadata shape. */
|
|
21
5
|
export const toClientMetadata = (client: OidcRegisteredClient): OidcClientMetadata => ({
|
|
@@ -29,12 +13,3 @@ export const toClientMetadata = (client: OidcRegisteredClient): OidcClientMetada
|
|
|
29
13
|
owlEntityId: client.entityId,
|
|
30
14
|
})
|
|
31
15
|
|
|
32
|
-
/** Extension seam for IAM integration into the OIDC provider — Phase 2 fills this */
|
|
33
|
-
export interface OidcProviderIamExtension {
|
|
34
|
-
/** Convert a stored client record to oidc-provider ClientMetadata */
|
|
35
|
-
toClientMetadata: typeof toClientMetadata
|
|
36
|
-
/** Type of a stored client record */
|
|
37
|
-
OidcRegisteredClient: OidcRegisteredClient
|
|
38
|
-
/** Extended metadata type */
|
|
39
|
-
OidcClientMetadata: OidcClientMetadata
|
|
40
|
-
}
|
package/src/service.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { DEFAULT_PATH, INTERACTION, INTERACTION_UID } from '@owlmeans/oidc'
|
|
|
4
4
|
import type { ServerResponse } from 'node:http'
|
|
5
5
|
import type { Config, Context, OidcAccountService, OidcAdapterService, OidcProviderService } from './types.js'
|
|
6
6
|
import Provider from 'oidc-provider'
|
|
7
|
+
import type { KoaContextWithOIDC } from 'oidc-provider'
|
|
8
|
+
import { logger } from '@owlmeans/log'
|
|
7
9
|
import type { BasicRoute } from '@owlmeans/route'
|
|
8
10
|
import type { CommonEntrypoint } from '@owlmeans/entrypoint'
|
|
9
11
|
import { PARAM, SEP } from '@owlmeans/route'
|
|
@@ -11,6 +13,37 @@ import { makeSecurityHelper } from '@owlmeans/config'
|
|
|
11
13
|
import { combineConfig } from './utils/config.js'
|
|
12
14
|
import { makeInteractionPolicy } from './utils/policy.js'
|
|
13
15
|
|
|
16
|
+
const log = logger('server-oidc-provider')
|
|
17
|
+
|
|
18
|
+
/** An OIDC error the provider answers with a 4xx — the client's mistake, not the provider's. */
|
|
19
|
+
const isClientError = (error: unknown): boolean => {
|
|
20
|
+
const status = (error as { status?: unknown } | null)?.status
|
|
21
|
+
return typeof status === 'number' && status >= 400 && status < 500
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* One provider error. The state dump carries ids only — never a token, code or secret the
|
|
26
|
+
* request holds.
|
|
27
|
+
*/
|
|
28
|
+
const reportProviderError = (issuer: string, kind: string, ctx: KoaContextWithOIDC | undefined, error: Error): void => {
|
|
29
|
+
const state = ctx?.oidc as unknown as {
|
|
30
|
+
client?: { clientId?: string }, grant?: { jti?: string, accountId?: string, clientId?: string }
|
|
31
|
+
} | undefined
|
|
32
|
+
const data = { kind, issuer, clientId: state?.client?.clientId, code: (error as { error?: unknown }).error, error }
|
|
33
|
+
if (isClientError(error)) {
|
|
34
|
+
log.warn('OIDC provider refused a request', data)
|
|
35
|
+
} else {
|
|
36
|
+
log.error('OIDC provider error', data)
|
|
37
|
+
}
|
|
38
|
+
if (state != null && log.enabled('debug')) {
|
|
39
|
+
log.debug('OIDC provider error state', {
|
|
40
|
+
kind, fields: Object.getOwnPropertyNames(state),
|
|
41
|
+
grant: state.grant != null
|
|
42
|
+
? { grantId: state.grant.jti, accountId: state.grant.accountId, clientId: state.grant.clientId } : undefined,
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
14
47
|
let _initializedOidc: Provider | undefined = undefined
|
|
15
48
|
export const createOidcProviderService = (alias: string = DEFAULT_ALIAS): OidcProviderService => {
|
|
16
49
|
const service: OidcProviderService = createService<OidcProviderService>(alias, {
|
|
@@ -94,27 +127,11 @@ export const createOidcProviderService = (alias: string = DEFAULT_ALIAS): OidcPr
|
|
|
94
127
|
|
|
95
128
|
api.server.use(base, oidc.callback())
|
|
96
129
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
console.error('!!!! GRANT ERROR: ', error)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
oidc.on('server_error', (ctx, error) => {
|
|
106
|
-
console.warn('SERVER ERROR .......: ', Object.getOwnPropertyNames(ctx.oidc))
|
|
107
|
-
console.info((ctx.oidc as any).grant)
|
|
108
|
-
console.error('!!!! SERVER ERROR: ', error)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
oidc.on('userinfo.error', (ctx, error) => {
|
|
112
|
-
console.warn('USER INFO ERROR .......: ', Object.getOwnPropertyNames(ctx.oidc))
|
|
113
|
-
console.info((ctx.oidc as any).grant)
|
|
114
|
-
console.error('!!!! USER INFO ERROR: ', error)
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
}
|
|
130
|
+
// Always attached: a provider error reaches the log — at `warn` when the client caused it
|
|
131
|
+
// (an OIDC 4xx such as `invalid_grant`), at `error` otherwise; the request state at `debug`.
|
|
132
|
+
oidc.on('grant.error', (ctx, error) => { reportProviderError(oidc.issuer, 'grant', ctx, error) })
|
|
133
|
+
oidc.on('server_error', (ctx, error) => { reportProviderError(oidc.issuer, 'server', ctx, error) })
|
|
134
|
+
oidc.on('userinfo.error', (ctx, error) => { reportProviderError(oidc.issuer, 'userinfo', ctx, error) })
|
|
118
135
|
|
|
119
136
|
_initializedOidc = service.oidc = oidc
|
|
120
137
|
},
|
package/src/types.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { OidcSharedConfig } from '@owlmeans/oidc'
|
|
|
3
3
|
import type { ApiServer, ApiServerAppend } from '@owlmeans/server-api'
|
|
4
4
|
import type { ServerConfig, ServerContext } from '@owlmeans/server-context'
|
|
5
5
|
import type { Account, Adapter, ClientMetadata, Configuration, Interaction, Provider } from 'oidc-provider'
|
|
6
|
+
import { toClientMetadata } from './iam.js'
|
|
6
7
|
|
|
7
8
|
export interface OidcProviderService extends InitializedService {
|
|
8
9
|
oidc: Provider
|
|
@@ -76,3 +77,30 @@ export interface Config extends ServerConfig, OidcConfigAppend {
|
|
|
76
77
|
|
|
77
78
|
export interface Context<C extends Config = Config> extends ServerContext<C>
|
|
78
79
|
, ApiServerAppend { }
|
|
80
|
+
|
|
81
|
+
/** A registered OIDC client stored in the provider's Client adapter. */
|
|
82
|
+
export interface OidcRegisteredClient {
|
|
83
|
+
clientId: string
|
|
84
|
+
secret: string
|
|
85
|
+
/** The entity (realm) this client belongs to — used for identity scoping. */
|
|
86
|
+
entityId?: string
|
|
87
|
+
/** Application display name */
|
|
88
|
+
name?: string
|
|
89
|
+
redirectUris?: string[]
|
|
90
|
+
grantTypes?: string[]
|
|
91
|
+
responseTypes?: string[]
|
|
92
|
+
scope?: string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Full oidc-provider ClientMetadata with our entity extension. */
|
|
96
|
+
export type OidcClientMetadata = ClientMetadata & { entityId?: string; owlEntityId?: string }
|
|
97
|
+
|
|
98
|
+
/** Extension seam for IAM integration into the OIDC provider — Phase 2 fills this */
|
|
99
|
+
export interface OidcProviderIamExtension {
|
|
100
|
+
/** Convert a stored client record to oidc-provider ClientMetadata */
|
|
101
|
+
toClientMetadata: typeof toClientMetadata
|
|
102
|
+
/** Type of a stored client record */
|
|
103
|
+
OidcRegisteredClient: OidcRegisteredClient
|
|
104
|
+
/** Extended metadata type */
|
|
105
|
+
OidcClientMetadata: OidcClientMetadata
|
|
106
|
+
}
|
package/src/utils/client.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { randomBytes } from '@noble/hashes/utils'
|
|
1
|
+
import { randomBytes } from '@noble/hashes/utils.js'
|
|
2
2
|
import { hex } from '@scure/base'
|
|
3
3
|
import type { ClientMetadata } from 'oidc-provider'
|
|
4
4
|
import type { Config, Context } from '../types.js'
|
|
5
5
|
import { makeSecurityHelper } from '@owlmeans/config'
|
|
6
6
|
import type { SecurityHelper } from '@owlmeans/config'
|
|
7
7
|
import { SEP } from '@owlmeans/route'
|
|
8
|
+
import { logger } from '@owlmeans/log'
|
|
9
|
+
|
|
10
|
+
const log = logger('server-oidc-provider')
|
|
8
11
|
|
|
9
12
|
export const updateClient = (context: Context, client: ClientMetadata): ClientMetadata => {
|
|
10
13
|
if (client.client_secret == null) {
|
|
@@ -12,12 +15,10 @@ export const updateClient = (context: Context, client: ClientMetadata): ClientMe
|
|
|
12
15
|
throw new SyntaxError('Client secret is required')
|
|
13
16
|
}
|
|
14
17
|
client.client_secret = hex.encode(randomBytes(32))
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
console.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
|
|
20
|
-
console.info('\n')
|
|
18
|
+
// The secret itself is never written to a log.
|
|
19
|
+
log.warn('Exceptionally insecure: a client secret was generated for an OIDC client (debug only)', {
|
|
20
|
+
clientId: client.client_id,
|
|
21
|
+
})
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const helper = makeSecurityHelper<Config, Context>(context)
|
package/src/utils/config.ts
CHANGED
|
@@ -4,6 +4,10 @@ import { ORGANIZATIONS_CLAIM, ORGANIZATIONS_SCOPE, PERMISSIONS_CLAIM, PERMISSION
|
|
|
4
4
|
import { makeSecurityHelper } from '@owlmeans/config'
|
|
5
5
|
import * as jose from 'jose'
|
|
6
6
|
|
|
7
|
+
/** A claim list is an array, or (as the provider's types also allow) a record keyed by claim name. */
|
|
8
|
+
const claimNamesOf = (claims: readonly string[] | Readonly<Record<string, null>> | null | undefined): readonly string[] =>
|
|
9
|
+
claims == null ? [] : Array.isArray(claims) ? claims : Object.keys(claims)
|
|
10
|
+
|
|
7
11
|
export const combineConfig = async (context: Context, _unsecure: boolean): Promise<OidcCustomConfiguration> => {
|
|
8
12
|
const cfg = context.cfg.oidc
|
|
9
13
|
const updateUri = makeUriUpdater(context, makeSecurityHelper(context))
|
|
@@ -15,10 +19,10 @@ export const combineConfig = async (context: Context, _unsecure: boolean): Promi
|
|
|
15
19
|
...(cfg.customConfiguration?.clients ?? [])
|
|
16
20
|
].map(client => updateClient(context, client)),
|
|
17
21
|
claims: {
|
|
18
|
-
email: ['email', 'email_verified', ...cfg.customConfiguration?.claims?.email
|
|
22
|
+
email: ['email', 'email_verified', ...claimNamesOf(cfg.customConfiguration?.claims?.email)],
|
|
19
23
|
profile: [
|
|
20
24
|
'username', 'family_name', 'given_name', 'locale', 'name', 'nickname', 'preferred_username',
|
|
21
|
-
...cfg.customConfiguration?.claims?.profile
|
|
25
|
+
...claimNamesOf(cfg.customConfiguration?.claims?.profile)
|
|
22
26
|
],
|
|
23
27
|
// Inert unless the account service actually emits the claim (integrated IAM mode)
|
|
24
28
|
[PERMISSIONS_SCOPE]: [PERMISSIONS_CLAIM],
|
package/src/utils/policy.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { errors, interactionPolicy } from 'oidc-provider'
|
|
2
|
-
|
|
3
|
-
/** The `reason` of the login check this module adds to the provider's default policy. */
|
|
4
|
-
export const ACCOUNT_REFUSED_REASON = 'account_refused'
|
|
2
|
+
import { ACCOUNT_REFUSED_REASON } from './consts.js'
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* The provider's default interaction policy plus one login check: a session whose account the
|
package/tests/pairwise.spec.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { AddressInfo } from 'node:net'
|
|
|
5
5
|
import { generateKeyPairSync } from 'node:crypto'
|
|
6
6
|
import Provider from 'oidc-provider'
|
|
7
7
|
import type { ClientMetadata, KoaContextWithOIDC } from 'oidc-provider'
|
|
8
|
-
import { sha256 } from '@noble/hashes/sha2'
|
|
8
|
+
import { sha256 } from '@noble/hashes/sha2.js'
|
|
9
9
|
import { base58 } from '@scure/base'
|
|
10
10
|
import { AppType, makeBasicContext } from '@owlmeans/context'
|
|
11
11
|
import { ORGANIZATIONS_CLAIM, ORGANIZATIONS_SCOPE, PERMISSIONS_CLAIM, PERMISSIONS_SCOPE } from '@owlmeans/oidc'
|
package/tests/policy.spec.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { describe, it, expect, afterEach } from 'bun:test'
|
|
2
|
-
import { createServer } from 'node:http'
|
|
3
|
-
import type { Server } from 'node:http'
|
|
2
|
+
import { createServer, type Server } from 'node:http'
|
|
4
3
|
import type { AddressInfo } from 'node:net'
|
|
5
4
|
import { createHmac } from 'node:crypto'
|
|
6
5
|
import Provider, { errors, interactionPolicy } from 'oidc-provider'
|
|
7
6
|
import type { Configuration } from 'oidc-provider'
|
|
8
|
-
import {
|
|
7
|
+
import { makeInteractionPolicy } from '../src/utils/policy.js'
|
|
8
|
+
import { ACCOUNT_REFUSED_REASON } from '../src/utils/consts.js'
|
|
9
9
|
|
|
10
10
|
const KEYS = ['policy-spec-cookie-key']
|
|
11
11
|
const CLIENT_ID = 'policy-spec-client'
|