@toa.io/extensions.exposition 1.0.0-alpha.185 → 1.0.0-alpha.187

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.
@@ -4,17 +4,19 @@ export async function effect (input: Input, context: Context): Promise<Output> {
4
4
  const { authority, username } = input
5
5
  const code = Math.floor(100000 + Math.random() * 900000).toString()
6
6
  const key = `${authority}:${username}:${code}`
7
+ const lifetime = input.lifetime ?? context.configuration.lifetime
7
8
 
8
- context.logs.debug('Issue OTP', { authority, username, code })
9
-
10
- await context.stash.set(key, 1, 'EX', context.configuration.lifetime)
9
+ context.logs.debug('Issue OTP', { authority, username, code, lifetime })
11
10
 
11
+ await context.stash.set(key, 1, 'EX', lifetime)
12
+
12
13
  return { code }
13
14
  }
14
15
 
15
16
  interface Input {
16
17
  authority: string
17
18
  username: string
19
+ lifetime?: number
18
20
  }
19
21
 
20
22
  interface Output {
@@ -95,14 +95,22 @@ password?: string
95
95
 
96
96
  Access requires basic credentials of the modified Identity or `system:identity:basic` role.
97
97
 
98
+ <code>POST</code> Incept new basic credentials. Request body is as follows:
99
+
100
+ ```yaml
101
+ username: string
102
+ password: string
103
+ ```
104
+
105
+ Identity should not have associated basic credentials. Access requires any credentials of the Identity.
106
+
98
107
  #### `/identity/basic/usernames/:username/`
99
108
 
100
109
  <code>GET</code> Check if the username is available.
101
110
 
102
111
  `username` must be Base64 URL encoded.
103
112
 
104
- Returns empty response with status `204`
105
- if the username is already taken or `404` if it is available.
113
+ Returns empty response with status `204` if the username is already taken or `404` if it is available.
106
114
 
107
115
  ## Identity federation (OpenID connect)
108
116
 
@@ -424,3 +424,53 @@ Feature: Basic authentication
424
424
  """
425
425
  404 Not Found
426
426
  """
427
+
428
+ Scenario: Adding new basic credentials
429
+ Given transient identity
430
+ When the following request is received:
431
+ """
432
+ POST /identity/basic/${{ identity.id }}/ HTTP/1.1
433
+ host: nex.toa.io
434
+ authorization: Token ${{ identity.token }}
435
+ accept: application/yaml
436
+ content-type: application/yaml
437
+
438
+ username: developer
439
+ password: secret#1234
440
+ """
441
+ Then the following reply is sent:
442
+ """
443
+ 201 Created
444
+ """
445
+ When the following request is received:
446
+ """
447
+ GET /identity/ HTTP/1.1
448
+ host: nex.toa.io
449
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldCMxMjM0
450
+ accept: application/yaml
451
+ """
452
+ Then the following reply is sent:
453
+ """
454
+ 200 OK
455
+
456
+ id: ${{ id }}
457
+ """
458
+
459
+ # credentials already exist
460
+ When the following request is received:
461
+ """
462
+ POST /identity/basic/${{ identity.id }}/ HTTP/1.1
463
+ host: nex.toa.io
464
+ authorization: Token ${{ identity.token }}
465
+ accept: application/yaml
466
+ content-type: application/yaml
467
+
468
+ username: painter
469
+ password: secret#4321
470
+ """
471
+ Then the following reply is sent:
472
+ """
473
+ 422 Unprocessable Entity
474
+
475
+ code: EXISTS
476
+ """
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/extensions.exposition",
3
- "version": "1.0.0-alpha.185",
3
+ "version": "1.0.0-alpha.187",
4
4
  "description": "Toa Exposition",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -63,5 +63,5 @@
63
63
  },
64
64
  "testEnvironment": "node"
65
65
  },
66
- "gitHead": "77151bc325f47d41cd719713c14e4a42eecfaa45"
66
+ "gitHead": "8279dd4f84dd1862f956682551ef418278be2ee8"
67
67
  }
@@ -1,5 +0,0 @@
1
- import { Context } from './types';
2
- export declare function effect(input: Input, context: Context): Promise<void>;
3
- interface Input {
4
- }
5
- export {};
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.effect = void 0;
4
- function effect(input, context) {
5
- }
6
- exports.effect = effect;
7
- //# sourceMappingURL=assert.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assert.js","sourceRoot":"","sources":["../source/assert.ts"],"names":[],"mappings":";;;AAEA,SAAgB,MAAM,CAAC,KAAY,EAAE,OAAgB;AAErD,CAAC;AAFD,wBAEC"}