@owlmeans/server-auth 0.1.18-rc.51 → 0.1.18-rc.53

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 (69) hide show
  1. package/README.md +2 -2
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/server-auth/SKILL.md +1 -1
  4. package/build/actions/service.d.ts.map +1 -1
  5. package/build/actions/service.js.map +1 -1
  6. package/build/actions/types.local.d.ts +5 -0
  7. package/build/actions/types.local.d.ts.map +1 -0
  8. package/build/actions/types.local.js +2 -0
  9. package/build/actions/types.local.js.map +1 -0
  10. package/build/manager/consts.local.d.ts +2 -0
  11. package/build/manager/consts.local.d.ts.map +1 -0
  12. package/build/manager/consts.local.js +2 -0
  13. package/build/manager/consts.local.js.map +1 -0
  14. package/build/manager/entrypoints.d.ts +1 -1
  15. package/build/manager/entrypoints.d.ts.map +1 -1
  16. package/build/manager/model.d.ts.map +1 -1
  17. package/build/manager/model.js +66 -43
  18. package/build/manager/model.js.map +1 -1
  19. package/build/manager/plugins/basic-ed25519.js +1 -1
  20. package/build/manager/plugins/basic-ed25519.js.map +1 -1
  21. package/build/manager/plugins/basic-rely.d.ts.map +1 -1
  22. package/build/manager/plugins/basic-rely.js +5 -2
  23. package/build/manager/plugins/basic-rely.js.map +1 -1
  24. package/build/manager/plugins/re-captcha.js +1 -1
  25. package/build/manager/plugins/re-captcha.js.map +1 -1
  26. package/build/manager/plugins/supervisor.d.ts +1 -2
  27. package/build/manager/plugins/supervisor.d.ts.map +1 -1
  28. package/build/manager/plugins/supervisor.js +1 -1
  29. package/build/manager/plugins/supervisor.js.map +1 -1
  30. package/build/manager/rely/flow.d.ts.map +1 -1
  31. package/build/manager/rely/flow.js +7 -5
  32. package/build/manager/rely/flow.js.map +1 -1
  33. package/build/manager/rely.d.ts.map +1 -1
  34. package/build/manager/rely.js.map +1 -1
  35. package/build/manager/supervisor.d.ts +1 -42
  36. package/build/manager/supervisor.d.ts.map +1 -1
  37. package/build/manager/supervisor.js +1 -1
  38. package/build/manager/supervisor.js.map +1 -1
  39. package/build/manager/types.d.ts +41 -1
  40. package/build/manager/types.d.ts.map +1 -1
  41. package/build/manager/types.local.d.ts +4 -0
  42. package/build/manager/types.local.d.ts.map +1 -0
  43. package/build/manager/types.local.js +2 -0
  44. package/build/manager/types.local.js.map +1 -0
  45. package/build/service.d.ts +2 -3
  46. package/build/service.d.ts.map +1 -1
  47. package/build/service.js +18 -7
  48. package/build/service.js.map +1 -1
  49. package/build/types.local.d.ts +4 -0
  50. package/build/types.local.d.ts.map +1 -0
  51. package/build/types.local.js +2 -0
  52. package/build/types.local.js.map +1 -0
  53. package/package.json +32 -31
  54. package/src/actions/service.ts +1 -4
  55. package/src/actions/types.local.ts +6 -0
  56. package/src/manager/README.md +1 -1
  57. package/src/manager/consts.local.ts +1 -0
  58. package/src/manager/model.ts +77 -54
  59. package/src/manager/plugins/basic-ed25519.ts +1 -1
  60. package/src/manager/plugins/basic-rely.ts +6 -2
  61. package/src/manager/plugins/re-captcha.ts +1 -1
  62. package/src/manager/plugins/supervisor.ts +3 -5
  63. package/src/manager/rely/flow.ts +8 -5
  64. package/src/manager/rely.ts +2 -5
  65. package/src/manager/supervisor.ts +2 -49
  66. package/src/manager/types.local.ts +5 -0
  67. package/src/manager/types.ts +46 -1
  68. package/src/service.ts +25 -19
  69. package/src/types.local.ts +5 -0
@@ -1,4 +1,4 @@
1
- import type { AllowanceRequest, AllowanceResponse, Auth, AuthCredentials, AuthToken, RelyToken } from '@owlmeans/auth';
1
+ import type { AllowanceRequest, AllowanceResponse, Auth, AuthCredentials, AuthToken, RelyToken, AuthPayload } from '@owlmeans/auth';
2
2
  import type { KlusterConfig } from '@owlmeans/kluster';
3
3
  import type { GuardService } from '@owlmeans/entrypoint';
4
4
  import type { ApiServerAppend } from '@owlmeans/server-api';
@@ -30,4 +30,44 @@ export interface RelyCarrier {
30
30
  source: RelyToken;
31
31
  rely: RelyToken;
32
32
  }
33
+ /**
34
+ * What a `SupervisorUserResolver` returns: the identity the supervisor-minted
35
+ * token will represent. Only `userId` is required - the rest default sensibly.
36
+ */
37
+ export interface SupervisorUserResolution extends Partial<Pick<AuthPayload, 'profileId' | 'entitySlug' | 'role' | 'scopes'>> {
38
+ userId: string;
39
+ }
40
+ /**
41
+ * Find-or-create the target identity for a supervisor login. `register` reflects
42
+ * `allowRegistration`; when false the resolver should only look existing users up.
43
+ * Wire this to the project's identity store (e.g. `@owlmeans/server-auth-identity`).
44
+ */
45
+ export interface SupervisorUserResolver {
46
+ <C extends AppConfig, T extends AppContext<C>>(userId: string, context: T, opts: {
47
+ register: boolean;
48
+ }): Promise<SupervisorUserResolution>;
49
+ }
50
+ /** Resolved options handed to the plugin factory. */
51
+ export interface SupervisorPluginOptions {
52
+ supervisors: string[];
53
+ allowRegistration: boolean;
54
+ resolveUser?: SupervisorUserResolver;
55
+ }
56
+ export interface SupervisorAuthOptions {
57
+ /** Trusted-record aliases authorized to act as supervisor. Default: master + superuser. */
58
+ supervisors?: string[];
59
+ /** Find-or-create the target user by id/email. Default: trust the id as-is. */
60
+ resolveUser?: SupervisorUserResolver;
61
+ /** Allow minting a token for an unknown user (registration). Default: true. */
62
+ allowRegistration?: boolean;
63
+ /** Force enable/disable. Default: development only (cfg.debug.all || cfg.debug.supervisor). */
64
+ enabled?: boolean;
65
+ /**
66
+ * Also accept internal owlmeans `Ed25519BasicToken`s even when another guard
67
+ * (e.g. OIDC) is the primary guard on protected entrypoints. Default: true.
68
+ */
69
+ acceptInternalTokens?: boolean;
70
+ /** The internal-token guard to add as a coguard. Default: DEFAULT_GUARD ('auth'). */
71
+ guard?: string;
72
+ }
33
73
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/manager/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,IAAI,EAAE,eAAe,EAAE,S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F;IAC3F,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,sBAAsB,CAAA;IACpC,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,+FAA+F;IAC/F,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
@@ -0,0 +1,4 @@
1
+ import type { ServerConfig, ServerContext } from '@owlmeans/server-context';
2
+ export type Config = ServerConfig;
3
+ export type Context = ServerContext<Config>;
4
+ //# sourceMappingURL=types.local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.d.ts","sourceRoot":"","sources":["../../src/manager/types.local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE3E,MAAM,MAAM,MAAM,GAAG,YAAY,CAAA;AAEjC,MAAM,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.js","sourceRoot":"","sources":["../../src/manager/types.local.ts"],"names":[],"mappings":""}
@@ -1,7 +1,6 @@
1
- import type { ServerContext, ServerConfig } from '@owlmeans/server-context';
1
+ import type { ServerContext } from '@owlmeans/server-context';
2
2
  import type { AuthServiceAppend, AuthService } from './types.js';
3
- type Config = ServerConfig;
3
+ import type { Config } from './types.local.js';
4
4
  export declare const makeAuthService: (alias?: string) => AuthService;
5
5
  export declare const appendAuthService: <C extends Config, T extends ServerContext<C>>(ctx: T, alias?: string) => T & AuthServiceAppend;
6
- export {};
7
6
  //# sourceMappingURL=service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAG3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAa,MAAM,YAAY,CAAA;AAoB3E,KAAK,MAAM,GAAG,YAAY,CAAA;AAG1B,eAAO,MAAM,eAAe,WAAW,MAAM,KAAmB,WAqL/D,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,OACvE,CAAC,UAAS,MAAM,KACpB,CAAC,GAAG,iBAiBN,CAAA"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAG7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAa,MAAM,YAAY,CAAA;AAa3E,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,kBAAkB,CAAA;AAgBvD,eAAO,MAAM,eAAe,WAAW,MAAM,KAAmB,WAqL/D,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,OACvE,CAAC,UAAS,MAAM,KACpB,CAAC,GAAG,iBAiBN,CAAA"}
package/build/service.js CHANGED
@@ -5,11 +5,22 @@ import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope';
5
5
  import { AuthenFailed, AuthorizationError, AuthroizationType, AuthUnavailable } from '@owlmeans/auth';
6
6
  import { createStaticResource } from '@owlmeans/static-resource';
7
7
  import { trust, extractAuthToken } from '@owlmeans/auth-common/utils';
8
- import { ENTITY_RESOLVER } from '@owlmeans/auth-common';
8
+ import { ENTITY_RESOLVER, TOKEN_UPDATE } from '@owlmeans/auth-common';
9
9
  import { AUTH_IDENTITY_PROFILE } from '@owlmeans/server-auth-identity';
10
10
  import { appendMemoryAuthSessionManager, AUTH_SESSION_MANAGER, AUTH_SESSION_TTL } from '@owlmeans/server-auth-session';
11
11
  import { uuid } from '@owlmeans/basic-ids';
12
- import { TOKEN_UPDATE } from '@owlmeans/auth-common';
12
+ import { logger } from '@owlmeans/log';
13
+ const log = logger('server-auth');
14
+ /**
15
+ * A refused token exchange — the manager's token presented to open a session. Logged with the
16
+ * reason and the account id only; returns the error for the caller to throw.
17
+ */
18
+ const refuse = (reason, error, userId) => {
19
+ const accountId = userId == null ? undefined
20
+ : userId.includes('@') ? `*@${userId.slice(userId.lastIndexOf('@') + 1)}` : userId;
21
+ log.warn('Session exchange refused', { reason, ...(accountId != null ? { accountId } : {}) }, { event: 'auth.refused' });
22
+ return error;
23
+ };
13
24
  export const makeAuthService = (alias = DEFAULT_ALIAS) => {
14
25
  const location = `server-auth:${alias}`;
15
26
  const cache = (context) => context.resource(AUTH_CACHE);
@@ -131,7 +142,7 @@ export const makeAuthService = (alias = DEFAULT_ALIAS) => {
131
142
  const envelope = makeEnvelopeModel(token.token, EnvelopeKind.Token);
132
143
  const authService = await trust(context, TRUSTED, AUTH_SRV_KEY);
133
144
  if (!await envelope.verify(authService.key)) {
134
- throw new AuthenFailed();
145
+ throw refuse('signature', new AuthenFailed());
135
146
  }
136
147
  const credentials = envelope.message();
137
148
  const msg = credentials.challenge;
@@ -140,10 +151,10 @@ export const makeAuthService = (alias = DEFAULT_ALIAS) => {
140
151
  await cache(context).create({ id: msg }, { ttl: AUTHEN_TIMEFRAME / 1000 });
141
152
  }
142
153
  catch {
143
- throw new AuthenFailed();
154
+ throw refuse('replay', new AuthenFailed(), credentials.userId);
144
155
  }
145
156
  if (credentials.credential !== authService.user.id) {
146
- throw new AuthenFailed();
157
+ throw refuse('issuer', new AuthenFailed(), credentials.userId);
147
158
  }
148
159
  // @TODO Move to a plugin
149
160
  const issuedAt = Date.now();
@@ -167,13 +178,13 @@ export const makeAuthService = (alias = DEFAULT_ALIAS) => {
167
178
  if (manager != null) {
168
179
  const entityId = await entityIdFor(context, auth.entitySlug);
169
180
  if (entityId == null || auth.profileId == null)
170
- throw new AuthenFailed('session');
181
+ throw refuse('session', new AuthenFailed('session'), auth.userId);
171
182
  const decision = await manager.register({
172
183
  id: auth.sessionId, kind: 'bearer', entityId, profileId: auth.profileId,
173
184
  issuedAt, expiresAt: expiresAt.getTime()
174
185
  });
175
186
  if (decision.state !== 'active')
176
- throw new AuthenFailed('session');
187
+ throw refuse('session', new AuthenFailed('session'), auth.userId);
177
188
  auth.authorizationVersion = decision.version;
178
189
  }
179
190
  return { token: await sign(context, auth) };
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEvF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE1E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,EACL,8BAA8B,EAAE,oBAAoB,EAAE,gBAAgB,EACvE,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB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,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IACtC,MAAM,OAAO,GAAG,GAA4B,CAAA;IAE5C,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAChC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAE/C,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { ServerContext, ServerConfig } from '@owlmeans/server-context';
2
+ export type Config = ServerConfig;
3
+ export type Context = ServerContext<Config>;
4
+ //# sourceMappingURL=types.local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.d.ts","sourceRoot":"","sources":["../src/types.local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE3E,MAAM,MAAM,MAAM,GAAG,YAAY,CAAA;AAEjC,MAAM,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.js","sourceRoot":"","sources":["../src/types.local.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/server-auth",
3
- "version": "0.1.18-rc.51",
3
+ "version": "0.1.18-rc.53",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -36,42 +36,43 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@noble/hashes": "^1.5.0",
40
- "@owlmeans/api": "^0.1.18-rc.44",
41
- "@owlmeans/api-config-server": "^0.1.18-rc.48",
42
- "@owlmeans/auth": "^0.1.18-rc.38",
43
- "@owlmeans/auth-common": "^0.1.18-rc.44",
44
- "@owlmeans/basic-envelope": "^0.1.18-rc.43",
45
- "@owlmeans/basic-ids": "^0.1.18-rc.34",
46
- "@owlmeans/basic-keys": "^0.1.18-rc.45",
47
- "@owlmeans/client-config": "^0.1.18-rc.41",
48
- "@owlmeans/client-entrypoint": "^0.1.18-rc.44",
49
- "@owlmeans/config": "^0.1.18-rc.41",
50
- "@owlmeans/context": "^0.1.18-rc.32",
51
- "@owlmeans/kluster": "^0.1.18-rc.40",
52
- "@owlmeans/entrypoint": "^0.1.18-rc.39",
53
- "@owlmeans/redis-resource": "^0.1.18-rc.41",
54
- "@owlmeans/resource": "^0.1.18-rc.37",
55
- "@owlmeans/route": "^0.1.18-rc.33",
56
- "@owlmeans/server-api": "^0.1.18-rc.48",
57
- "@owlmeans/server-auth-identity": "^0.1.18-rc.44",
58
- "@owlmeans/server-auth-session": "^0.1.18-rc.13",
59
- "@owlmeans/server-context": "^0.1.18-rc.40",
60
- "@owlmeans/server-entrypoint": "^0.1.18-rc.38",
61
- "@owlmeans/server-route": "^0.1.18-rc.32",
62
- "@owlmeans/server-socket": "^0.1.18-rc.51",
63
- "@owlmeans/socket": "^0.1.18-rc.37",
64
- "@owlmeans/static-resource": "^0.1.18-rc.36",
65
- "@scure/base": "^2.3.0"
39
+ "@noble/hashes": "^2.4.0",
40
+ "@owlmeans/api": "^0.1.18-rc.46",
41
+ "@owlmeans/api-config-server": "^0.1.18-rc.50",
42
+ "@owlmeans/auth": "^0.1.18-rc.39",
43
+ "@owlmeans/auth-common": "^0.1.18-rc.46",
44
+ "@owlmeans/basic-envelope": "^0.1.18-rc.45",
45
+ "@owlmeans/basic-ids": "^0.1.18-rc.36",
46
+ "@owlmeans/basic-keys": "^0.1.18-rc.47",
47
+ "@owlmeans/client-config": "^0.1.18-rc.43",
48
+ "@owlmeans/client-entrypoint": "^0.1.18-rc.46",
49
+ "@owlmeans/config": "^0.1.18-rc.43",
50
+ "@owlmeans/context": "^0.1.18-rc.33",
51
+ "@owlmeans/kluster": "^0.1.18-rc.42",
52
+ "@owlmeans/log": "^0.1.18-rc.1",
53
+ "@owlmeans/entrypoint": "^0.1.18-rc.40",
54
+ "@owlmeans/redis-resource": "^0.1.18-rc.43",
55
+ "@owlmeans/resource": "^0.1.18-rc.39",
56
+ "@owlmeans/route": "^0.1.18-rc.34",
57
+ "@owlmeans/server-api": "^0.1.18-rc.50",
58
+ "@owlmeans/server-auth-identity": "^0.1.18-rc.46",
59
+ "@owlmeans/server-auth-session": "^0.1.18-rc.15",
60
+ "@owlmeans/server-context": "^0.1.18-rc.42",
61
+ "@owlmeans/server-entrypoint": "^0.1.18-rc.39",
62
+ "@owlmeans/server-route": "^0.1.18-rc.33",
63
+ "@owlmeans/server-socket": "^0.1.18-rc.53",
64
+ "@owlmeans/socket": "^0.1.18-rc.39",
65
+ "@owlmeans/static-resource": "^0.1.18-rc.38",
66
+ "@scure/base": "^2.4.0"
66
67
  },
67
68
  "peerDependencies": {
68
69
  "ajv": "*"
69
70
  },
70
71
  "devDependencies": {
71
72
  "@owlmeans/dep-config": "workspace:*",
72
- "@owlmeans/test-auth": "^0.1.18-rc.43",
73
- "@types/bun": "^1.4.0",
74
- "@types/node": "^26.1.0",
73
+ "@owlmeans/test-auth": "^0.1.18-rc.45",
74
+ "@types/bun": "^1.4.2",
75
+ "@types/node": "^26.6.4",
75
76
  "nodemon": "^3.1.14",
76
77
  "typescript": "^7.0.2"
77
78
  },
@@ -1,12 +1,9 @@
1
1
  import { handlers } from '@owlmeans/server-api'
2
2
  import type { EntrypointProtocol } from '@owlmeans/entrypoint'
3
3
  import type { AuthToken } from '@owlmeans/auth'
4
- import { AuthServiceAppend } from '../types.js'
5
- import type { ServerConfig, ServerContext } from '@owlmeans/server-context'
6
4
  import { assertContext } from '@owlmeans/context'
5
+ import type { Context } from './types.local.js'
7
6
 
8
- type Config = ServerConfig
9
- type Context = ServerContext<Config> & AuthServiceAppend
10
7
  const api = handlers<Context>()
11
8
 
12
9
  export const authenticate = (protocol: EntrypointProtocol<{ body: AuthToken }, AuthToken>) =>
@@ -0,0 +1,6 @@
1
+ import type { ServerConfig, ServerContext } from '@owlmeans/server-context'
2
+ import { AuthServiceAppend } from '../types.js'
3
+
4
+ export type Config = ServerConfig
5
+
6
+ export type Context = ServerContext<Config> & AuthServiceAppend
@@ -38,7 +38,7 @@ The manager is built on the OwlMeans entrypoint system, providing:
38
38
  This manager app is part of the `@owlmeans/server-auth` package:
39
39
 
40
40
  ```bash
41
- npm install @owlmeans/server-auth@^0.1.18-rc.51
41
+ npm install @owlmeans/server-auth@^0.1.18-rc.53
42
42
  ```
43
43
 
44
44
  ## API Reference
@@ -0,0 +1 @@
1
+ export const DEFAULT_SUPERVISORS = ['master', 'superuser']
@@ -1,21 +1,26 @@
1
1
  import type { AuthModel, AppConfig, AppContext } from './types.js'
2
- import { AuthenFailed, AuthenPayloadError, entitySlugOf } from '@owlmeans/auth'
3
- import type { AuthCredentials } from '@owlmeans/auth'
4
- import type { EntityResolverService } from '@owlmeans/auth-common'
5
- import { ENTITY_RESOLVER } from '@owlmeans/auth-common'
2
+ import { AuthenFailed, AuthenPayloadError, AuthError, AuthUnavailable, entitySlugOf, type AuthCredentials } from '@owlmeans/auth'
3
+ import { logger } from '@owlmeans/log'
4
+ import { type EntityResolverService, ENTITY_RESOLVER } from '@owlmeans/auth-common'
6
5
  import { getPlugin } from './plugins/utils.js'
7
6
  import { AUTH_CACHE, AUTHEN_TIMEFRAME } from '../consts.js'
8
- import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope'
9
- import type { EnvelopeModel } from '@owlmeans/basic-envelope'
7
+ import { EnvelopeKind, makeEnvelopeModel, type EnvelopeModel } from '@owlmeans/basic-envelope'
10
8
  import { createRelyFlow } from './rely/flow.js'
11
9
  import { trusted } from './utils/trusted.js'
12
- import type { ServerConfig, ServerContext } from '@owlmeans/server-context'
13
10
  import type { Resource } from '@owlmeans/resource'
14
11
  import type { AuthSpent } from '../types.js'
15
12
  import { AuthChallengeReplayPolicy } from './plugins/replay-policy.js'
13
+ import type { Context } from './types.local.js'
16
14
 
17
- type Config = ServerConfig
18
- type Context = ServerContext<Config>
15
+
16
+ const log = logger('server-auth')
17
+
18
+ /** An account id as a log may carry it: an e-mail is reduced to its domain. */
19
+ const accountOf = (userId: string | undefined): string | undefined =>
20
+ userId == null ? undefined : userId.includes('@') ? `*@${userId.slice(userId.lastIndexOf('@') + 1)}` : userId
21
+
22
+ const compact = <T extends Record<string, unknown>>(value: T): Partial<T> =>
23
+ Object.fromEntries(Object.entries(value).filter(([, entry]) => entry != null)) as Partial<T>
19
24
 
20
25
  export const makeAuthModel = (context: AppContext<AppConfig>): AuthModel => {
21
26
  const cache = (context: Context): Resource<AuthSpent> =>
@@ -44,61 +49,79 @@ export const makeAuthModel = (context: AppContext<AppConfig>): AuthModel => {
44
49
  },
45
50
 
46
51
  authenticate: async credential => {
47
- const [trustedUser, keyPair] = await trusted(context)
48
- const envelope: EnvelopeModel = makeEnvelopeModel(credential.challenge, EnvelopeKind.Wrap)
49
- if (!await envelope.verify(keyPair)) {
50
- throw new AuthenFailed('challenge')
51
- }
52
+ // The one place every manager sign-in method (each plugin) is decided — logged once here.
53
+ const method = credential.type
54
+ try {
55
+ const [trustedUser, keyPair] = await trusted(context)
56
+ const envelope: EnvelopeModel = makeEnvelopeModel(credential.challenge, EnvelopeKind.Wrap)
57
+ if (!await envelope.verify(keyPair)) {
58
+ throw new AuthenFailed('challenge')
59
+ }
52
60
 
53
- const msg: string = envelope.message(true)
61
+ const msg: string = envelope.message(true)
54
62
 
55
- const plugin = await getPlugin(envelope.type(), context)
63
+ const plugin = await getPlugin(envelope.type(), context)
56
64
 
57
- if (plugin.challengeReplayPolicy !== AuthChallengeReplayPolicy.Plugin) {
58
- try {
59
- await cache(context).create({ id: msg }, { ttl: (envelope.envelope.ttl ?? AUTHEN_TIMEFRAME) / 1000 })
60
- } catch (e) {
61
- const error = new AuthenFailed('challenge')
62
- if (e instanceof Error) {
63
- error.oiriginalStack = `${e} : ${e.stack}`
65
+ if (plugin.challengeReplayPolicy !== AuthChallengeReplayPolicy.Plugin) {
66
+ try {
67
+ await cache(context).create({ id: msg }, { ttl: (envelope.envelope.ttl ?? AUTHEN_TIMEFRAME) / 1000 })
68
+ } catch (e) {
69
+ const error = new AuthenFailed('challenge')
70
+ if (e instanceof Error) {
71
+ error.oiriginalStack = `${e} : ${e.stack}`
72
+ }
73
+ throw error
64
74
  }
65
- throw error
66
75
  }
67
- }
68
76
 
69
- if (credential.userId == null) {
70
- throw new AuthenPayloadError('userId')
71
- }
77
+ if (credential.userId == null) {
78
+ throw new AuthenPayloadError('userId')
79
+ }
72
80
 
73
- // @TODO this token PROBABLY needs to be registered somewhere and rechecked
74
- // from time to time to make sure that the session is not deleted
75
- // or permission hasn't changed.
76
- // Alternative solution is to have permissions cached and cleaned
77
- // when some broadcast message is sent from authentication system.
78
-
79
- const challenge = credential.challenge
80
- const { token } = await plugin.authenticate(Object.assign(credential, { challenge: msg }))
81
- credential.challenge = token === '' ? challenge : token
82
-
83
- // Plugins accept whatever the caller typed — a current slug, a slug the organization has
84
- // since retired, or (for a token minted before slugs existed) its stable key. The token is
85
- // signed once and read for as long as it lives, so the value is canonicalized here rather
86
- // than at every place that later reads it back.
87
- const entitySlug = entitySlugOf(credential)
88
- if (entitySlug != null && context.hasService(ENTITY_RESOLVER)) {
89
- const entity = await context.service<EntityResolverService>(ENTITY_RESOLVER).resolve(entitySlug)
90
- if (entity == null) {
91
- throw new AuthenFailed('entity')
81
+ // @TODO this token PROBABLY needs to be registered somewhere and rechecked
82
+ // from time to time to make sure that the session is not deleted
83
+ // or permission hasn't changed.
84
+ // Alternative solution is to have permissions cached and cleaned
85
+ // when some broadcast message is sent from authentication system.
86
+
87
+ const challenge = credential.challenge
88
+ const { token } = await plugin.authenticate(Object.assign(credential, { challenge: msg }))
89
+ credential.challenge = token === '' ? challenge : token
90
+
91
+ // Plugins accept whatever the caller typed — a current slug, a slug the organization has
92
+ // since retired, or (for a token minted before slugs existed) its stable key. The token is
93
+ // signed once and read for as long as it lives, so the value is canonicalized here rather
94
+ // than at every place that later reads it back.
95
+ const entitySlug = entitySlugOf(credential)
96
+ if (entitySlug != null && context.hasService(ENTITY_RESOLVER)) {
97
+ const entity = await context.service<EntityResolverService>(ENTITY_RESOLVER).resolve(entitySlug)
98
+ if (entity == null) {
99
+ throw new AuthenFailed('entity')
100
+ }
101
+ credential.entitySlug = entity.slug
92
102
  }
93
- credential.entitySlug = entity.slug
94
- }
95
103
 
96
- credential.credential = trustedUser.id
104
+ credential.credential = trustedUser.id
97
105
 
98
- return {
99
- token: await makeEnvelopeModel<AuthCredentials>(credential.type)
100
- .send(credential, AUTHEN_TIMEFRAME)
101
- .sign(keyPair, EnvelopeKind.Token)
106
+ const result = {
107
+ token: await makeEnvelopeModel<AuthCredentials>(credential.type)
108
+ .send(credential, AUTHEN_TIMEFRAME)
109
+ .sign(keyPair, EnvelopeKind.Token)
110
+ }
111
+ log.info('Signed in', compact({
112
+ method, accountId: accountOf(credential.userId), profileId: credential.profileId,
113
+ entitySlug: credential.entitySlug,
114
+ }), { event: 'auth.signed-in' })
115
+
116
+ return result
117
+ } catch (error) {
118
+ // An outage (`AuthUnavailable`) is not a refusal; it propagates and is logged as a failure.
119
+ if (error instanceof AuthError && !(error instanceof AuthUnavailable)) {
120
+ log.warn('Sign-in refused', compact({
121
+ method, accountId: accountOf(credential.userId), reason: error.message,
122
+ }), { event: 'auth.refused' })
123
+ }
124
+ throw error
102
125
  }
103
126
  },
104
127
 
@@ -1,7 +1,7 @@
1
1
  import { AuthenticationType, AuthenFailed, ALL_SCOPES, AuthRole } from '@owlmeans/auth'
2
2
  import type { AuthPlugin } from './types.js'
3
3
  import { assertType } from './utils.js'
4
- import { randomBytes } from '@noble/hashes/utils'
4
+ import { randomBytes } from '@noble/hashes/utils.js'
5
5
  import { base64 } from '@scure/base'
6
6
  import { fromPubKey } from '@owlmeans/basic-keys'
7
7
  import type { AppConfig, AppContext } from '../types.js'
@@ -9,6 +9,9 @@ import { AUTH_CACHE } from '../../consts.js'
9
9
  import { ResourceError } from '@owlmeans/resource'
10
10
  import type { Unsubscribe } from '@owlmeans/resource'
11
11
  import { RELY_CALL_TIMEOUT, RELY_PIN_PERFIX, RELY_TOKEN_PREFIX } from '@owlmeans/auth-common'
12
+ import { logger } from '@owlmeans/log'
13
+
14
+ const log = logger('server-auth:rely')
12
15
 
13
16
  const _subscriptions: Record<string, Unsubscribe> = {}
14
17
  export const basicRely = (context: AppContext, type?: string): AuthPlugin => {
@@ -75,7 +78,7 @@ export const basicRely = (context: AppContext, type?: string): AuthPlugin => {
75
78
  return response
76
79
  } catch (e) {
77
80
  if (e instanceof ResourceError) {
78
- console.error('COLISION ON TRY TO CREATE RELY PIN\TOKEN...', e)
81
+ log.warn('Rely pin/token collision; retrying', e)
79
82
  } else {
80
83
  throw e
81
84
  }
@@ -118,7 +121,8 @@ export const basicRely = (context: AppContext, type?: string): AuthPlugin => {
118
121
  rely = envelop.message()
119
122
  } catch (e) {
120
123
  if (e instanceof ResourceError) {
121
- console.error(e)
124
+ // The peer's pin/token is unknown; the refusal itself is logged where sign-in is decided.
125
+ log.debug('Rely peer lookup failed', e)
122
126
  throw new AuthorizationError('rely')
123
127
  } else {
124
128
  throw e
@@ -7,7 +7,7 @@ import { PluginMissconfigured } from '@owlmeans/config'
7
7
  import type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
8
8
  import { EntrypointOutcome } from '@owlmeans/entrypoint'
9
9
  import { base64 } from '@scure/base'
10
- import { randomBytes } from '@noble/hashes/utils'
10
+ import { randomBytes } from '@noble/hashes/utils.js'
11
11
  import { assertType } from './utils.js'
12
12
 
13
13
  export const reCaptcha = <C extends AppConfig, T extends AppContext<C>>(context: T): AuthPlugin => {
@@ -1,13 +1,11 @@
1
- import { AuthenticationType, AuthenFailed, AuthRole, ALL_SCOPES, buildSupervisorPayload } from '@owlmeans/auth'
2
- import type { SupervisorCredentialPayload } from '@owlmeans/auth'
1
+ import { AuthenticationType, AuthenFailed, AuthRole, ALL_SCOPES, buildSupervisorPayload, type SupervisorCredentialPayload } from '@owlmeans/auth'
3
2
  import type { AuthPlugin } from './types.js'
4
3
  import { base64 } from '@scure/base'
5
- import { randomBytes } from '@noble/hashes/utils'
4
+ import { randomBytes } from '@noble/hashes/utils.js'
6
5
  import { fromPubKey } from '@owlmeans/basic-keys'
7
6
  import { TRUSTED } from '@owlmeans/config'
8
7
  import type { TrustedRecord } from '@owlmeans/auth-common'
9
- import type { AppConfig, AppContext } from '../types.js'
10
- import type { SupervisorPluginOptions } from '../supervisor.js'
8
+ import type { AppConfig, AppContext, SupervisorPluginOptions } from '../types.js'
11
9
 
12
10
  /**
13
11
  * PK-based supervisor authentication plugin. A privileged operator (or an e2e
@@ -9,6 +9,7 @@ import { trusted } from '../utils/trusted.js'
9
9
  import { RELY_TUNNEL } from '../consts.js'
10
10
  import type { RedisResource } from '@owlmeans/redis-resource'
11
11
  import { RELY_ACTION_TIMEOUT } from '@owlmeans/auth-common'
12
+ import { logger } from '@owlmeans/log'
12
13
 
13
14
  // 1. There is a difference between privileged (provider)
14
15
  // and non-privileged (consumer) request
@@ -20,6 +21,8 @@ import { RELY_ACTION_TIMEOUT } from '@owlmeans/auth-common'
20
21
  // process can be started from scratch following same stages
21
22
  // and using the same plugins but via socket
22
23
 
24
+ const log = logger('server-auth:rely')
25
+
23
26
  export const createRelyFlow = (context: AppContext, conn: Connection, auth?: Auth | null): AuthenticateMethod => {
24
27
  const auhtenticate = conn.authenticate
25
28
 
@@ -40,9 +43,9 @@ export const createRelyFlow = (context: AppContext, conn: Connection, auth?: Aut
40
43
  }
41
44
  }, { channel: source.nonce })
42
45
  // We allow to just forward call messages back and forth
43
- conn._receiveCall = async msg => { console.info(source.nonce, 'Forward call', msg.method, msg.id) }
44
- conn._receiveResult = async msg => { console.info(source.nonce, 'Forward result', msg.id) }
45
- conn._receiveError = async msg => { console.info(source.nonce, 'Forward error', msg.id) }
46
+ conn._receiveCall = async msg => { log.debug('Forward call', { nonce: source.nonce, method: msg.method, id: msg.id }) }
47
+ conn._receiveResult = async msg => { log.debug('Forward result', { nonce: source.nonce, id: msg.id }) }
48
+ conn._receiveError = async msg => { log.debug('Forward error', { nonce: source.nonce, id: msg.id }) }
46
49
  conn.defaultCallTimeout = RELY_ACTION_TIMEOUT * 1000
47
50
  const closeSender = conn.listen(async message => {
48
51
  if (isMessage(message, true)) {
@@ -94,7 +97,7 @@ export const createRelyFlow = (context: AppContext, conn: Connection, auth?: Aut
94
97
  try {
95
98
  return [stage, await model.init(_payload as AllowanceRequest) as any]
96
99
  } catch (e) {
97
- console.error(e)
100
+ log.warn('Rely init failed; connection closed', e)
98
101
  await conn.close()
99
102
  }
100
103
  break
@@ -118,7 +121,7 @@ export const createRelyFlow = (context: AppContext, conn: Connection, auth?: Aut
118
121
 
119
122
  return [AuthenticationStage.Authenticated, internalAuth as any]
120
123
  } catch (e) {
121
- console.error(e)
124
+ log.warn('Rely authentication failed; connection closed', e)
122
125
  await conn.close()
123
126
  }
124
127
  break