@toa.io/extensions.exposition 1.0.0-alpha.150 → 1.0.0-alpha.151
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/components/identity.federation/manifest.toa.yaml +12 -13
- package/components/identity.federation/operations/authenticate.js +0 -1
- package/components/identity.federation/operations/authenticate.js.map +1 -1
- package/components/identity.federation/operations/decode.js +0 -1
- package/components/identity.federation/operations/decode.js.map +1 -1
- package/components/identity.federation/operations/incept.d.ts +1 -1
- package/components/identity.federation/operations/incept.js +1 -2
- package/components/identity.federation/operations/incept.js.map +1 -1
- package/components/identity.federation/operations/lib/Ctx.d.ts +1 -2
- package/components/identity.federation/operations/lib/decode.js +0 -14
- package/components/identity.federation/operations/lib/decode.js.map +1 -1
- package/components/identity.federation/operations/lib/exchange.js +1 -1
- package/components/identity.federation/operations/lib/exchange.js.map +1 -1
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/operations/types/context.d.ts +1 -2
- package/components/identity.federation/source/authenticate.ts +0 -1
- package/components/identity.federation/source/decode.ts +0 -1
- package/components/identity.federation/source/incept.ts +2 -3
- package/components/identity.federation/source/lib/Ctx.ts +1 -2
- package/components/identity.federation/source/lib/decode.ts +1 -21
- package/components/identity.federation/source/lib/exchange.ts +1 -1
- package/components/identity.federation/source/types/context.ts +1 -3
- package/features/identity.federation.feature +1 -37
- package/package.json +2 -2
- package/source/directives/auth/Incept.ts +1 -0
- package/transpiled/directives/auth/Incept.js +1 -0
- package/transpiled/directives/auth/Incept.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JWTPayload } from 'jose';
|
|
2
|
-
import type { Call, Observation, Query,
|
|
2
|
+
import type { Call, Observation, Query, telemetry } from '@toa.io/types';
|
|
3
3
|
import type { Entity } from './entity';
|
|
4
4
|
import type { Configuration } from './configuration';
|
|
5
5
|
export interface Context {
|
|
@@ -17,7 +17,6 @@ export interface Context {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
logs: telemetry.Logs;
|
|
20
|
-
stash: Stash;
|
|
21
20
|
configuration: Configuration;
|
|
22
21
|
}
|
|
23
22
|
export interface TransitInput {
|
|
@@ -4,11 +4,10 @@ import type { Request } from '@toa.io/types'
|
|
|
4
4
|
import type { Context, Entity, TransitInput, Scheme } from './types'
|
|
5
5
|
|
|
6
6
|
export async function effect (input: Input, context: Context): Promise<Output | Error> {
|
|
7
|
-
if (input.scheme
|
|
7
|
+
if (input.scheme === 'code') return ERR_SCHEME
|
|
8
8
|
|
|
9
9
|
const payload = await decode(input.credentials, {
|
|
10
10
|
trust: context.configuration.trust,
|
|
11
|
-
stash: context.stash,
|
|
12
11
|
logs: context.logs
|
|
13
12
|
})
|
|
14
13
|
|
|
@@ -27,9 +26,9 @@ export async function effect (input: Input, context: Context): Promise<Output |
|
|
|
27
26
|
const ERR_SCHEME = new Err('ERR_SCHEME', 'Unsupported scheme')
|
|
28
27
|
|
|
29
28
|
export interface Input {
|
|
30
|
-
scheme: Scheme
|
|
31
29
|
authority: string
|
|
32
30
|
credentials: string
|
|
31
|
+
scheme?: Scheme
|
|
33
32
|
id?: string
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as jose from 'jose'
|
|
2
2
|
import { createRemoteJWKSet } from './discovery'
|
|
3
|
-
import { ERR_TRUST, ERR_ISS, ERR_SUB
|
|
4
|
-
import type { Stash } from '@toa.io/types'
|
|
3
|
+
import { ERR_TRUST, ERR_ISS, ERR_SUB } from './errors'
|
|
5
4
|
import type { Ctx } from './Ctx'
|
|
6
5
|
import type { Payload } from './Payload'
|
|
7
6
|
|
|
@@ -25,24 +24,5 @@ export async function decode (token: string, ctx: Ctx): Promise<Payload | Error>
|
|
|
25
24
|
|
|
26
25
|
const { payload } = await jose.jwtVerify(token, jwks[iss], { audience: trusted.aud })
|
|
27
26
|
|
|
28
|
-
if (payload.jti !== undefined) {
|
|
29
|
-
const error = await validateJti(payload, ctx.stash)
|
|
30
|
-
|
|
31
|
-
if (error instanceof Error)
|
|
32
|
-
return error
|
|
33
|
-
}
|
|
34
|
-
|
|
35
27
|
return payload as Payload
|
|
36
28
|
}
|
|
37
|
-
|
|
38
|
-
async function validateJti (payload: jose.JWTPayload, stash: Stash): Promise<void | Error> {
|
|
39
|
-
if (payload.exp === undefined)
|
|
40
|
-
return ERR_EXP
|
|
41
|
-
|
|
42
|
-
const ttl = payload.exp - Math.floor(Date.now() / 1000)
|
|
43
|
-
const key = `identity:federation:jti:${payload.jti}`
|
|
44
|
-
const ok = await stash.set(key, 1, 'EX', ttl, 'NX') // set if not exists
|
|
45
|
-
|
|
46
|
-
if (ok === null)
|
|
47
|
-
return ERR_REPLAY
|
|
48
|
-
}
|
|
@@ -95,7 +95,7 @@ async function sign (trust: Trust): Promise<string> {
|
|
|
95
95
|
const signature = trust.signature!
|
|
96
96
|
const aud = Array.isArray(trust.aud) ? trust.aud[0] : trust.aud!
|
|
97
97
|
const now = Math.floor(Date.now() / 1000)
|
|
98
|
-
const key = await jose.importPKCS8(signature.key, 'ES256')
|
|
98
|
+
const key = await jose.importPKCS8(atob(signature.key), 'ES256')
|
|
99
99
|
|
|
100
100
|
return await new jose.SignJWT({})
|
|
101
101
|
.setProtectedHeader({ alg: 'ES256', kid: signature.kid })
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { JWTPayload } from 'jose'
|
|
2
|
-
|
|
3
|
-
import type { Call, Observation, Query, Stash, telemetry } from '@toa.io/types'
|
|
2
|
+
import type { Call, Observation, Query, telemetry } from '@toa.io/types'
|
|
4
3
|
import type { Entity } from './entity'
|
|
5
4
|
import type { Configuration } from './configuration'
|
|
6
5
|
|
|
@@ -19,7 +18,6 @@ export interface Context {
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
logs: telemetry.Logs
|
|
22
|
-
stash: Stash
|
|
23
21
|
configuration: Configuration
|
|
24
22
|
}
|
|
25
23
|
|
|
@@ -236,42 +236,6 @@ Feature: Identity Federation
|
|
|
236
236
|
id: ${{ Bob.id }}
|
|
237
237
|
"""
|
|
238
238
|
|
|
239
|
-
Scenario: Tokens with `jti` are one-time
|
|
240
|
-
Given the `identity.federation` configuration:
|
|
241
|
-
"""yaml
|
|
242
|
-
trust:
|
|
243
|
-
- iss: http://localhost:44444
|
|
244
|
-
"""
|
|
245
|
-
And ID token with jti is issued for User
|
|
246
|
-
When the following request is received:
|
|
247
|
-
"""
|
|
248
|
-
GET /identity/ HTTP/1.1
|
|
249
|
-
host: nex.toa.io
|
|
250
|
-
authorization: Bearer ${{ User.id_token }}
|
|
251
|
-
accept: application/yaml
|
|
252
|
-
"""
|
|
253
|
-
Then the following reply is sent:
|
|
254
|
-
"""
|
|
255
|
-
200 OK
|
|
256
|
-
authorization: Token ${{ User.token }}
|
|
257
|
-
|
|
258
|
-
id: ${{ User.id }}
|
|
259
|
-
roles: []
|
|
260
|
-
"""
|
|
261
|
-
|
|
262
|
-
# second use
|
|
263
|
-
When the following request is received:
|
|
264
|
-
"""
|
|
265
|
-
GET /identity/ HTTP/1.1
|
|
266
|
-
host: nex.toa.io
|
|
267
|
-
authorization: Bearer ${{ User.id_token }}
|
|
268
|
-
accept: application/yaml
|
|
269
|
-
"""
|
|
270
|
-
Then the following reply is sent:
|
|
271
|
-
"""
|
|
272
|
-
401 Unauthorized
|
|
273
|
-
"""
|
|
274
|
-
|
|
275
239
|
Scenario: Authorization code flow with secret
|
|
276
240
|
Given the `identity.federation` configuration:
|
|
277
241
|
"""yaml
|
|
@@ -305,7 +269,7 @@ Feature: Identity Federation
|
|
|
305
269
|
signature:
|
|
306
270
|
iss: io.toa.nex.id
|
|
307
271
|
kid: key-id
|
|
308
|
-
key:
|
|
272
|
+
key: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR0hBZ0VBTUJNR0J5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEJHMHdhd0lCQVFRZzl4OURhdHdIMEdaSFNDbzkKVE1IVFZYeWVZMFlROHFiNzNqSFYydjRNc3llaFJBTkNBQVF3YVlsbmEyaFNWM0cvUklsTkxWNDFsZzhQbTRLZgpIZkN1S0tpdzNCSUpUblNBckFNSkxTeTF2WXdTSU1IejcyMG1rbVdUcld1UWtranZrRHBaeGZSdgotLS0tLUVORCBQUklWQVRFIEtFWS0tLS0t
|
|
309
273
|
"""
|
|
310
274
|
And auth code for Bob is issued for https://web.toa.io/callback/
|
|
311
275
|
When the following request is received:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/extensions.exposition",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.151",
|
|
4
4
|
"description": "Toa Exposition",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
},
|
|
63
63
|
"testEnvironment": "node"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "38345350d7fc75507400826ad41ce29caf3e35c6"
|
|
66
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Incept.js","sourceRoot":"","sources":["../../../source/directives/auth/Incept.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgC;AAChC,uCAAkC;AAClC,iDAAkC;AAClC,mCAA+B;AAC/B,qCAAiC;AACjC,uCAAgD;AAIhD,MAAa,MAAM;IACT,MAAM,CAAU,OAAO,GAAY,EAAwB,CAAA;IAC3D,MAAM,CAAC,SAAS,CAAW;IAElB,QAAQ,CAAe;IAExC,YAAoB,QAAgB,EAAE,SAAoB;QACxD,qBAAM,CAAC,EAAE,CAAC,QAAQ,KAAK,IAAI,IAAI,OAAO,QAAQ,K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