@defra/lis-hubs-infra-access 0.15.0 → 0.16.0

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.
Files changed (2) hide show
  1. package/README.md +57 -0
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -25,6 +25,63 @@ direct-port requests to the microsite's configured `basePath` and sends that
25
25
  relative path to the front-office login route. Relative return URLs prevent an
26
26
  untrusted host header from becoming an authentication redirect target.
27
27
 
28
+ ## Application route authentication modes
29
+
30
+ Application modules use user-session authentication by default. Hub-service
31
+ authentication is applied to individual routes only; whole modules and
32
+ taxonomies must not be configured as hub-service authenticated.
33
+
34
+ ### `user-session`
35
+
36
+ This is the default mode and does not normally need to be declared on a route.
37
+ The request must contain a valid hub session cookie. If it does not, the guard
38
+ redirects the browser to the appropriate hub login route.
39
+
40
+ ```js
41
+ server.route({
42
+ method: 'GET',
43
+ path: '/',
44
+ handler
45
+ })
46
+ ```
47
+
48
+ ### `hub-service`
49
+
50
+ Use this mode for an internal interface that a hub calls directly, such as a
51
+ summary-data endpoint. Mark only the relevant route with
52
+ `app.authMode: 'hub-service'`:
53
+
54
+ ```js
55
+ server.route({
56
+ method: 'GET',
57
+ path: '/summary-data',
58
+ options: {
59
+ app: { authMode: 'hub-service' }
60
+ },
61
+ handler
62
+ })
63
+ ```
64
+
65
+ The application must also enable route-aware hub-service authentication when
66
+ it creates its spoke guard:
67
+
68
+ ```js
69
+ const authGuard = createSpokeGuard({
70
+ // Standard spoke guard configuration...
71
+ allowHubServiceRoutes: true
72
+ })
73
+ ```
74
+
75
+ The calling hub sends a bearer token created with `createSpokeAuthToken`. The
76
+ guard validates its signature, issuer, audience, expiry, authorization model
77
+ version, `hub-service` subject, taxonomy, and spoke ID. A missing or invalid
78
+ token receives `401 Unauthorized`; a hub session cookie alone does not grant
79
+ access to a route marked `hub-service`.
80
+
81
+ Unmarked routes continue to use `user-session` authentication when
82
+ `allowHubServiceRoutes` is enabled. Do not set a module or taxonomy access mode
83
+ to `hub-service` to expose an internal interface.
84
+
28
85
  This package should depend on hub facts from `@defra/lis-hubs-infra-registry`, not on deployable hub policy.
29
86
 
30
87
  Current implementation notes:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/lis-hubs-infra-access",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Shared hub access and capability resolution for the livestock platform.",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "author": "Defra DDTS",
34
34
  "license": "OGL-UK-3.0",
35
35
  "dependencies": {
36
- "@defra/lis-hubs-infra-registry": "^0.1.0",
36
+ "@defra/lis-hubs-infra-registry": "^0.3.0",
37
37
  "convict": "6.2.5",
38
38
  "convict-format-with-validator": "6.2.0",
39
39
  "eslint-plugin-jsdoc": "^63.0.8",
@@ -48,7 +48,7 @@
48
48
  "eslint": "^9.0.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@defra/lis-hubs-infra-core": "^0.6.0",
51
+ "@defra/lis-hubs-infra-core": "^0.7.0",
52
52
  "@defra/lis-infra-eslint-config": "^0.6.0",
53
53
  "@hapi/boom": "10.0.1",
54
54
  "@hapi/wreck": "18.1.2",