@memberjunction/auth-providers 6.1.0-edge.2 → 6.1.0-edge.4

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 (47) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +76 -0
  3. package/LICENSE +180 -4
  4. package/README.md +71 -2
  5. package/dist/AuthProviderFactory.d.ts +17 -7
  6. package/dist/AuthProviderFactory.d.ts.map +1 -1
  7. package/dist/AuthProviderFactory.js +54 -8
  8. package/dist/AuthProviderFactory.js.map +1 -1
  9. package/dist/IEnvironmentConfigurableProvider.d.ts +51 -0
  10. package/dist/IEnvironmentConfigurableProvider.d.ts.map +1 -0
  11. package/dist/IEnvironmentConfigurableProvider.js +7 -0
  12. package/dist/IEnvironmentConfigurableProvider.js.map +1 -0
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/providers/Auth0Provider.d.ts +7 -0
  18. package/dist/providers/Auth0Provider.d.ts.map +1 -1
  19. package/dist/providers/Auth0Provider.js +21 -0
  20. package/dist/providers/Auth0Provider.js.map +1 -1
  21. package/dist/providers/CognitoProvider.d.ts +6 -0
  22. package/dist/providers/CognitoProvider.d.ts.map +1 -1
  23. package/dist/providers/CognitoProvider.js +20 -0
  24. package/dist/providers/CognitoProvider.js.map +1 -1
  25. package/dist/providers/MSALProvider.d.ts +8 -0
  26. package/dist/providers/MSALProvider.d.ts.map +1 -1
  27. package/dist/providers/MSALProvider.js +21 -0
  28. package/dist/providers/MSALProvider.js.map +1 -1
  29. package/dist/providers/OktaProvider.d.ts +8 -0
  30. package/dist/providers/OktaProvider.d.ts.map +1 -1
  31. package/dist/providers/OktaProvider.js +22 -0
  32. package/dist/providers/OktaProvider.js.map +1 -1
  33. package/dist/providers/WorkOSProvider.d.ts +14 -0
  34. package/dist/providers/WorkOSProvider.d.ts.map +1 -1
  35. package/dist/providers/WorkOSProvider.js +26 -0
  36. package/dist/providers/WorkOSProvider.js.map +1 -1
  37. package/package.json +4 -3
  38. package/src/AuthProviderFactory.ts +56 -8
  39. package/src/IEnvironmentConfigurableProvider.ts +54 -0
  40. package/src/__tests__/BuiltInProviderRegistration.test.ts +37 -0
  41. package/src/__tests__/EnvironmentDiscovery.test.ts +146 -0
  42. package/src/index.ts +1 -0
  43. package/src/providers/Auth0Provider.ts +22 -0
  44. package/src/providers/CognitoProvider.ts +21 -0
  45. package/src/providers/MSALProvider.ts +22 -0
  46. package/src/providers/OktaProvider.ts +23 -0
  47. package/src/providers/WorkOSProvider.ts +27 -0
@@ -1,4 +1,4 @@
1
1
 
2
- > @memberjunction/auth-providers@6.1.0-edge.2 build /home/runner/work/MJ/MJ/packages/AuthProviders
2
+ > @memberjunction/auth-providers@6.1.0-edge.4 build /home/runner/work/MJ/MJ/packages/AuthProviders
3
3
  > tsc && tsc-alias -f
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,81 @@
1
1
  # @memberjunction/auth-providers
2
2
 
3
+ ## 6.1.0-edge.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [4586215]
8
+ - Updated dependencies [e2ad3c0]
9
+ - Updated dependencies [a5f92d2]
10
+ - Updated dependencies [647bd71]
11
+ - Updated dependencies [d90a3ea]
12
+ - Updated dependencies [8ad04e8]
13
+ - Updated dependencies [53c341c]
14
+ - Updated dependencies [a1a8989]
15
+ - @memberjunction/global@6.1.0-edge.4
16
+ - @memberjunction/core@6.1.0-edge.4
17
+
18
+ ## 6.1.0-edge.3
19
+
20
+ ### Minor Changes
21
+
22
+ - 048c5ce: feat(auth): metadata-driven pluggable authentication providers
23
+
24
+ Authentication providers are now discovered the MJ way — a `@RegisterClass(BaseAuthProvider, 'x')`
25
+ subclass plus a row in the new `MJ: Authentication Providers` entity, resolved at runtime through
26
+ `ClassFactory` by `DriverClass`. Adding a provider requires no core edits.
27
+ - **New entity** `__mj.AuthenticationProvider`, with the OIDC connection fields as columns, an
28
+ optional `CredentialID` for the rare provider needing server-side secrets, and login-picker
29
+ presentation fields. Driver configuration is split by trust boundary: `AdditionalConfiguration`
30
+ is server-only, `ClientConfiguration` is published to the browser.
31
+ - **`AuthProviderEngine`** loads the catalog at startup and registers it with `AuthProviderFactory`.
32
+ - **Layered resolution** — `mj.config.cjs` `authProviders[]` remains fully supported as the baseline
33
+ and fallback, so existing deployments are unaffected and need no changes.
34
+ - **`GET /auth/providers`** publishes the non-secret catalog to the pre-auth browser (rate-limited,
35
+ mounted ahead of the auth middleware, allow-list projection).
36
+ - **`<mj-login-picker>`** — a reusable, app-agnostic multi-IdP picker built on `mjButton`, rendered
37
+ only when 2+ client-visible providers exist. Single-provider deployments look exactly as before.
38
+ - `AuthProviderFactory` no longer carries a hard-wired list of built-in provider imports; the
39
+ package entry point and the class-registration manifests already covered registration.
40
+ - **Environment-variable configuration is now pluggable too.** The hard-coded block in MJServer's
41
+ config that enumerated Entra / Auth0 / Cognito inline is replaced by an optional
42
+ `configFromEnvironment` static on each provider class (`IEnvironmentConfigurableProvider`),
43
+ collected through the ClassFactory registry by `AuthProviderFactory.discoverFromEnvironment()`.
44
+ A third-party provider can now offer the same "set two variables and you're done" experience
45
+ with no change to MJ core. The three existing mappings are preserved byte-for-byte; **Okta**
46
+ (`OKTA_DOMAIN` + `OKTA_CLIENT_ID`) and **WorkOS** (`WORKOS_CLIENT_ID`) gain env-var support they
47
+ did not previously have.
48
+
49
+ ### Patch Changes
50
+
51
+ - Updated dependencies [834f8d7]
52
+ - Updated dependencies [07cb22e]
53
+ - Updated dependencies [c581b4f]
54
+ - Updated dependencies [d79fe39]
55
+ - Updated dependencies [08829f5]
56
+ - Updated dependencies [815b9bc]
57
+ - Updated dependencies [f5ec13b]
58
+ - Updated dependencies [50987c4]
59
+ - Updated dependencies [7b4abe7]
60
+ - Updated dependencies [051e0ff]
61
+ - Updated dependencies [95fc3e6]
62
+ - Updated dependencies [cefc302]
63
+ - Updated dependencies [bbb7fcc]
64
+ - Updated dependencies [b8130f3]
65
+ - Updated dependencies [be0bdb2]
66
+ - Updated dependencies [68b9cf0]
67
+ - Updated dependencies [048c5ce]
68
+ - Updated dependencies [7300953]
69
+ - Updated dependencies [7300953]
70
+ - Updated dependencies [b46330e]
71
+ - Updated dependencies [84f276e]
72
+ - Updated dependencies [6ecfaa0]
73
+ - Updated dependencies [f5ec13b]
74
+ - Updated dependencies [1bd9674]
75
+ - Updated dependencies [d0a2a55]
76
+ - @memberjunction/global@6.1.0-edge.3
77
+ - @memberjunction/core@6.1.0-edge.3
78
+
3
79
  ## 6.1.0-edge.2
4
80
 
5
81
  ### Patch Changes
package/LICENSE CHANGED
@@ -1,7 +1,183 @@
1
- ISC License
1
+ Business Source License 1.1
2
2
 
3
- Copyright (c) 2023 MemberJunction
3
+ License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB plc.
4
5
 
5
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6
+ -----------------------------------------------------------------------------
6
7
 
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8
+ Parameters
9
+
10
+ Licensor: Blue Cypress, Inc.
11
+
12
+ Licensed Work: MemberJunction.
13
+ The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
14
+
15
+ Additional Use Grant: Subject to the terms of this License, Licensor grants
16
+ you the following additional rights to make Production
17
+ Use of the Licensed Work.
18
+
19
+ 1. Internal Use
20
+
21
+ You may make production use of the Licensed Work for
22
+ your own internal business or organizational operations.
23
+
24
+ 2. Nonprofit Use
25
+
26
+ If you are a Nonprofit, you may make production use of
27
+ the Licensed Work for the operations and activities of
28
+ your Organizational Family.
29
+
30
+ 3. MemberJunction Certified Program Use
31
+
32
+ If you are authorized by Licensor under the
33
+ MemberJunction Certified Program to provide professional
34
+ services using the Licensed Work, you may make
35
+ production use of the Licensed Work in providing such
36
+ professional services to a client, provided that:
37
+
38
+ (a) the Licensed Work is deployed in, and the applicable
39
+ production use occurs within, an environment owned,
40
+ leased, licensed, subscribed to, or otherwise controlled
41
+ by that client; and
42
+
43
+ (b) the production use is for that client's own internal
44
+ business or organizational operations or is otherwise
45
+ independently permitted to that client under this
46
+ Additional Use Grant.
47
+
48
+ 4. Definitions Applicable to the Additional Use Grant
49
+
50
+ "Affiliate" means, with respect to a specified Person,
51
+ any other Person that directly or indirectly Controls,
52
+ is Controlled by, or is under common Control with such
53
+ specified Person.
54
+
55
+ "Control" (including the terms "Controls," "Controlled
56
+ by," and "under common Control with") means the direct
57
+ or indirect possession of the power to direct or cause
58
+ the direction of the management and policies of a
59
+ Person, whether through ownership of voting interests,
60
+ by contract, or otherwise.
61
+
62
+ "Organizational Family" means, with respect to a Person,
63
+ (a) such Person and its Affiliates, and (b) any
64
+ nonprofit organization, governmental entity, chapter,
65
+ division, local affiliate, regional affiliate, state
66
+ affiliate, national affiliate, or other entity that is
67
+ formally affiliated with such Person through governing
68
+ documents, a charter, bylaws, a membership agreement, or
69
+ another written organizational instrument, and is
70
+ recognized under such documents as part of the same
71
+ organizational structure.
72
+
73
+ "Nonprofit" means a Person recognized by the Internal
74
+ Revenue Service as exempt from federal income taxation
75
+ under Section 501(c)(3), 501(c)(4), 501(c)(5), or
76
+ 501(c)(6) of the Internal Revenue Code, or a foreign
77
+ organization recognized under substantially equivalent
78
+ laws.
79
+
80
+ A Person claiming eligibility as a Nonprofit shall, upon
81
+ Licensor's reasonable request, provide documentation
82
+ reasonably sufficient to demonstrate that it qualifies
83
+ as a Nonprofit. If such Person materially misrepresents,
84
+ or is unable to demonstrate, its qualification as a
85
+ Nonprofit, the rights granted to such Person under
86
+ Section 2 of this Additional Use Grant shall terminate.
87
+
88
+ "MemberJunction Certified Program" means Licensor's
89
+ then-current program for certifying and authorizing a
90
+ Person to provide professional services using the
91
+ Licensed Work.
92
+
93
+ "Person" means any individual, corporation, limited
94
+ liability company, partnership, association, nonprofit
95
+ organization, governmental entity, or other legal or
96
+ organizational entity.
97
+
98
+ Change Date: Four (4) years from the date the Licensed Work is first
99
+ made available.
100
+
101
+ Change License: MIT License.
102
+
103
+ For information about alternative licensing arrangements for the Licensed
104
+ Work, please contact Blue Cypress, Inc.
105
+
106
+ -----------------------------------------------------------------------------
107
+
108
+ Terms
109
+
110
+ The Licensor hereby grants you the right to copy, modify, create derivative
111
+ works, redistribute, and make non-production use of the Licensed Work. The
112
+ Licensor may make an Additional Use Grant, above, permitting limited
113
+ production use.
114
+
115
+ Effective on the Change Date, or the fourth anniversary of the first publicly
116
+ available distribution of a specific version of the Licensed Work under this
117
+ License, whichever comes first, the Licensor hereby grants you rights under
118
+ the terms of the Change License, and the rights granted in the paragraph
119
+ above terminate.
120
+
121
+ If your use of the Licensed Work does not comply with the requirements
122
+ currently in effect as described in this License, you must purchase a
123
+ commercial license from the Licensor, its affiliated entities, or authorized
124
+ resellers, or you must refrain from using the Licensed Work.
125
+
126
+ All copies of the original and modified Licensed Work, and derivative works
127
+ of the Licensed Work, are subject to this License. This License applies
128
+ separately for each version of the Licensed Work and the Change Date may vary
129
+ for each version of the Licensed Work released by Licensor.
130
+
131
+ You must conspicuously display this License on each original or modified copy
132
+ of the Licensed Work. If you receive the Licensed Work in original or
133
+ modified form from a third party, the terms and conditions set forth in this
134
+ License apply to your use of that work.
135
+
136
+ Any use of the Licensed Work in violation of this License will automatically
137
+ terminate your rights under this License for the current and all other
138
+ versions of the Licensed Work.
139
+
140
+ This License does not grant you any right in any trademark or logo of
141
+ Licensor or its affiliates (provided that you may use a trademark or logo of
142
+ Licensor as expressly required by this License).
143
+
144
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
145
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
146
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
147
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
148
+ TITLE.
149
+
150
+ MariaDB hereby grants you permission to use this License's text to license
151
+ your works, and to refer to it using the trademark "Business Source License",
152
+ as long as you comply with the Covenants of Licensor below.
153
+
154
+ -----------------------------------------------------------------------------
155
+
156
+ Covenants of Licensor
157
+
158
+ In consideration of the right to use this License's text and the "Business
159
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
160
+ other recipients of the licensed work to be provided by Licensor:
161
+
162
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
163
+ or a license that is compatible with GPL Version 2.0 or a later version,
164
+ where "compatible" means that software provided under the Change License
165
+ can be included in a program with software provided under GPL Version 2.0
166
+ or a later version. Licensor may specify additional Change Licenses without
167
+ limitation.
168
+
169
+ 2. To either: (a) specify an additional grant of rights to use that does not
170
+ impose any additional restriction on the right granted in this License, as
171
+ the Additional Use Grant; or (b) insert the text "None".
172
+
173
+ 3. To specify a Change Date.
174
+
175
+ 4. Not to modify this License in any other way.
176
+
177
+ -----------------------------------------------------------------------------
178
+
179
+ Notice
180
+
181
+ The Business Source License (this document, or the "License") is not an Open
182
+ Source license. However, the Licensed Work will eventually be made available
183
+ under an Open Source License, as stated in this License.
package/README.md CHANGED
@@ -102,6 +102,75 @@ Each built-in provider is registered with the MJ class factory under a lowercase
102
102
 
103
103
  Every provider also requires the base fields: `name`, `type`, `issuer`, `audience`, `jwksUri`. See [`AuthProviderConfig`](../MJCore/src/generic/authTypes.ts) for the full shape.
104
104
 
105
+ > The list above is **not a closed set** — it is what MJ happens to ship. `type` is resolved through
106
+ > the class factory, so any `@RegisterClass(BaseAuthProvider, 'your-key')` subclass is instantiable
107
+ > the same way, with no change to this package. Nothing validates `type` against an enum.
108
+
109
+ ## Where provider configuration comes from
110
+
111
+ A provider config can reach the factory from three places. They layer rather than compete, and none
112
+ is mandatory:
113
+
114
+ | Source | Set by | Notes |
115
+ | --- | --- | --- |
116
+ | **Environment variables** | Each provider class's optional `ConfigFromEnvironment` static | The zero-config path. See below. |
117
+ | **`mj.config.cjs`** | The `authProviders` array | Explicit and exact. Declaring it **replaces** the environment-derived set rather than merging. |
118
+ | **`MJ: Authentication Providers` metadata** | Rows in the database | Enables admin-managed configuration and the multi-IdP login picker. Layered on top at startup by MJServer's `AuthProviderEngine`. |
119
+
120
+ Config and environment remain the bootstrap path: you cannot configure authentication through a UI
121
+ you must first authenticate to reach.
122
+
123
+ ### Environment-variable configuration (`ConfigFromEnvironment`)
124
+
125
+ A provider class declares its own environment mapping by implementing the optional
126
+ [`IEnvironmentConfigurableProvider`](src/IEnvironmentConfigurableProvider.ts) static.
127
+ `AuthProviderFactory.DiscoverFromEnvironment()` walks the class-factory registry and collects every
128
+ provider that finds its variables — so a third-party provider gets the same "set two variables and
129
+ you're done" experience as a built-in, without touching MJ core.
130
+
131
+ | Provider | Variables | Resulting provider name |
132
+ | --- | --- | --- |
133
+ | Entra ID / Azure AD | `TENANT_ID` + `WEB_CLIENT_ID` | `azure` |
134
+ | Auth0 | `AUTH0_DOMAIN` + `AUTH0_CLIENT_ID` (optional `AUTH0_CLIENT_SECRET`) | `auth0` |
135
+ | AWS Cognito | `COGNITO_USER_POOL_ID` + `COGNITO_CLIENT_ID` + `AWS_REGION` | `cognito` |
136
+ | Okta | `OKTA_DOMAIN` + `OKTA_CLIENT_ID` (optional `OKTA_ISSUER`, `OKTA_AUDIENCE`) | `okta` |
137
+ | WorkOS | `WORKOS_CLIENT_ID` (optional `WORKOS_AUDIENCE`) | `workos` |
138
+
139
+ Implementing it on your own provider:
140
+
141
+ ```typescript
142
+ @RegisterClass(BaseAuthProvider, 'my-idp')
143
+ export class MyIdpProvider extends BaseAuthProvider {
144
+ static ConfigFromEnvironment(env: NodeJS.ProcessEnv): AuthProviderConfig | null {
145
+ // MUST return null — never a partial config — when the variables are absent, or the
146
+ // half-populated result fails validateConfig() and errors on every deployment that
147
+ // simply does not use this provider.
148
+ if (!env.MY_IDP_DOMAIN || !env.MY_IDP_CLIENT_ID) return null;
149
+ return {
150
+ name: 'my-idp',
151
+ type: 'my-idp',
152
+ issuer: `https://${env.MY_IDP_DOMAIN}/`,
153
+ audience: env.MY_IDP_CLIENT_ID,
154
+ jwksUri: `https://${env.MY_IDP_DOMAIN}/.well-known/jwks.json`,
155
+ clientId: env.MY_IDP_CLIENT_ID
156
+ };
157
+ }
158
+ // ...extractUserInfo, etc.
159
+ }
160
+ ```
161
+
162
+ ### Metadata configuration
163
+
164
+ `MJ: Authentication Providers` rows name a `DriverClass` — the same key as `@RegisterClass` — plus
165
+ the non-secret OIDC fields, and are resolved at runtime through the class factory. Two configuration
166
+ blobs are split by trust boundary: `AdditionalConfiguration` is server-only and never published,
167
+ while `ClientConfiguration` is published verbatim to the unauthenticated pre-auth catalog endpoint
168
+ that the browser reads before login. Real secrets belong behind `CredentialID`, which points at an
169
+ encrypted `MJ: Credentials` record.
170
+
171
+ MJ ships seed rows for its providers (all `Inactive`, connection fields blank) — see
172
+ [`metadata/authentication-providers/`](../../metadata/authentication-providers/README.md).
173
+
105
174
  ## Configuration
106
175
 
107
176
  In an MJ server, providers are configured under `authProviders` in `mj.config.cjs`. Multiple providers can be registered concurrently — the factory dispatches incoming tokens to the right one based on the `iss` claim.
@@ -243,7 +312,7 @@ export class KeycloakProvider extends BaseAuthProvider {
243
312
  // Then in mj.config.cjs use type: 'keycloak'
244
313
  ```
245
314
 
246
- > **Important:** because the provider is loaded via class-factory metadata and not by direct reference, your bundler may tree-shake it out. Make sure the file containing the `@RegisterClass` decorator is imported (directly or transitively) before `AuthProviderFactory.createProvider()` runs. The built-in providers do this from [`AuthProviderFactory.ts`](src/AuthProviderFactory.ts); follow the same pattern in your own entry point or a manifest. See the class-registration manifest discussion in [packages/CodeGenLib/CLAUDE.md](../CodeGenLib/CLAUDE.md) for background.
315
+ > **Important:** because the provider is loaded via class-factory metadata and not by direct reference, your bundler may tree-shake it out. Make sure the file containing the `@RegisterClass` decorator is imported (directly or transitively) before `AuthProviderFactory.createProvider()` runs. The built-in providers achieve this by being exported from this package's [`index.ts`](src/index.ts) — importing anything from `@memberjunction/auth-providers` loads and registers all of them. (`AuthProviderFactory.ts` used to carry a literal roster of side-effect imports for this; it was removed because it made the built-ins look like a closed set you had to append to, and `index.ts` already covered it.) For your own provider, export it from your package entry point and make sure that package is reachable from a class-registration manifest — see the discussion in [packages/CodeGenLib/CLAUDE.md](../CodeGenLib/CLAUDE.md).
247
316
 
248
317
  ## API reference
249
318
 
@@ -314,4 +383,4 @@ A `GraphQLError` with `extensions.code = 'JWT_EXPIRED'` and `extensions.expiryDa
314
383
 
315
384
  ## License
316
385
 
317
- ISC part of the [MemberJunction](https://github.com/MemberJunction/MJ) monorepo.
386
+ Business Source License 1.1 see [LICENSE](../../LICENSE) for details.
@@ -1,13 +1,6 @@
1
1
  import { AuthProviderConfig } from '@memberjunction/core';
2
2
  import { IAuthProvider } from './IAuthProvider.js';
3
3
  import { BaseSingleton } from '@memberjunction/global';
4
- import './providers/Auth0Provider.js';
5
- import './providers/MSALProvider.js';
6
- import './providers/OktaProvider.js';
7
- import './providers/CognitoProvider.js';
8
- import './providers/GoogleProvider.js';
9
- import './providers/WorkOSProvider.js';
10
- import './providers/MagicLinkProvider.js';
11
4
  /**
12
5
  * Factory and registry for managing authentication providers
13
6
  * Combines provider creation and lifecycle management in a single class
@@ -72,6 +65,23 @@ export declare class AuthProviderFactory extends BaseSingleton<AuthProviderFacto
72
65
  * Gets all registered provider types from the ClassFactory
73
66
  */
74
67
  static getRegisteredProviderTypes(): string[];
68
+ /**
69
+ * Collects provider configurations from environment variables by asking every registered
70
+ * provider class to configure itself.
71
+ *
72
+ * This replaces the hard-coded env block that used to live in MJServer's config and
73
+ * enumerated Entra / Auth0 / Cognito inline. Discovery is now driven by the same
74
+ * `@RegisterClass` registry that resolves drivers, so a third-party provider gets the
75
+ * env-var experience without a core edit — see {@link IEnvironmentConfigurableProvider}.
76
+ *
77
+ * A provider whose variables are absent returns null and is skipped. A provider whose
78
+ * mapping throws is skipped with an error rather than taking down startup, because one
79
+ * malformed mapping must not cost a deployment its other providers.
80
+ *
81
+ * @param env Environment to read from; defaults to `process.env`.
82
+ * @returns One config per provider that found its variables, deduplicated by name.
83
+ */
84
+ static DiscoverFromEnvironment(env?: NodeJS.ProcessEnv): AuthProviderConfig[];
75
85
  /**
76
86
  * Checks if a provider type is registered
77
87
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AuthProviderFactory.d.ts","sourceRoot":"","sources":["../src/AuthProviderFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAe,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAY,aAAa,EAAc,MAAM,wBAAwB,CAAC;AAG7E,OAAO,8BAA8B,CAAC;AACtC,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AACrC,OAAO,gCAAgC,CAAC;AACxC,OAAO,+BAA+B,CAAC;AACvC,OAAO,+BAA+B,CAAC;AACvC,OAAO,kCAAkC,CAAC;AAE1C;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,aAAa,CAAC,mBAAmB,CAAC;IACzE,OAAO,CAAC,SAAS,CAAyC;IAC1D;;;;;;OAMG;IACH,OAAO,CAAC,WAAW,CAA6F;IAChH;;OAEG;IACH,OAAO,CAAC,gBAAgB,CAAi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kB,GAAG,aAAa;IAsBhE;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAiBvC;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAmBtD;;;;;;OAMG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,EAAE;IAqB/C;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIlD;;OAEG;IACH,eAAe,IAAI,aAAa,EAAE;IAIlC;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,MAAM,CAAC,0BAA0B,IAAI,MAAM,EAAE;IAW7C;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,uBAAuB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,kBAAkB,EAAE;IA0B1F;;OAEG;IACH,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CASvD"}
@@ -1,14 +1,20 @@
1
1
  import { LogStatusEx } from '@memberjunction/core';
2
2
  import { BaseAuthProvider } from './BaseAuthProvider.js';
3
+ import { isEnvironmentConfigurable } from './IEnvironmentConfigurableProvider.js';
3
4
  import { MJGlobal, BaseSingleton, MJLruCache } from '@memberjunction/global';
4
- // Import providers to ensure they're registered
5
- import './providers/Auth0Provider.js';
6
- import './providers/MSALProvider.js';
7
- import './providers/OktaProvider.js';
8
- import './providers/CognitoProvider.js';
9
- import './providers/GoogleProvider.js';
10
- import './providers/WorkOSProvider.js';
11
- import './providers/MagicLinkProvider.js';
5
+ // NOTE: this file deliberately contains NO list of concrete providers.
6
+ //
7
+ // It used to carry a literal `import './providers/Auth0Provider.js'` roster, which made the
8
+ // built-ins look like a closed set that had to be edited to add a provider. They never were:
9
+ // providers are @RegisterClass plugins resolved by key, and `index.ts` already exports all of
10
+ // them by name, so importing anything from '@memberjunction/auth-providers' loads and registers
11
+ // every built-in. HostIdentityProvider — added later — was never in that roster and has always
12
+ // registered fine through the package entry point and the server-bootstrap manifest, which is
13
+ // the proof the roster was redundant rather than load-bearing.
14
+ //
15
+ // Adding a provider is therefore: ship a @RegisterClass(BaseAuthProvider, 'x') subclass (in this
16
+ // package, or in any package covered by a class-registration manifest) and add an
17
+ // `MJ: Authentication Providers` row naming 'x' as its DriverClass. No edit here.
12
18
  /**
13
19
  * Factory and registry for managing authentication providers
14
20
  * Combines provider creation and lifecycle management in a single class
@@ -154,6 +160,46 @@ export class AuthProviderFactory extends BaseSingleton {
154
160
  // Return unique provider types
155
161
  return Array.from(new Set(providerTypes));
156
162
  }
163
+ /**
164
+ * Collects provider configurations from environment variables by asking every registered
165
+ * provider class to configure itself.
166
+ *
167
+ * This replaces the hard-coded env block that used to live in MJServer's config and
168
+ * enumerated Entra / Auth0 / Cognito inline. Discovery is now driven by the same
169
+ * `@RegisterClass` registry that resolves drivers, so a third-party provider gets the
170
+ * env-var experience without a core edit — see {@link IEnvironmentConfigurableProvider}.
171
+ *
172
+ * A provider whose variables are absent returns null and is skipped. A provider whose
173
+ * mapping throws is skipped with an error rather than taking down startup, because one
174
+ * malformed mapping must not cost a deployment its other providers.
175
+ *
176
+ * @param env Environment to read from; defaults to `process.env`.
177
+ * @returns One config per provider that found its variables, deduplicated by name.
178
+ */
179
+ static DiscoverFromEnvironment(env = process.env) {
180
+ const registrations = MJGlobal.Instance.ClassFactory.GetAllRegistrations(BaseAuthProvider);
181
+ const configs = new Map();
182
+ for (const registration of registrations) {
183
+ const providerClass = registration.SubClass;
184
+ if (!isEnvironmentConfigurable(providerClass)) {
185
+ continue;
186
+ }
187
+ try {
188
+ const config = providerClass.ConfigFromEnvironment(env);
189
+ if (config && !configs.has(config.name)) {
190
+ configs.set(config.name, config);
191
+ }
192
+ }
193
+ catch (error) {
194
+ const message = error instanceof Error ? error.message : String(error);
195
+ LogStatusEx({
196
+ message: `Auth provider '${registration.Key}' failed to build a configuration from environment variables: ${message}`,
197
+ verboseOnly: true
198
+ });
199
+ }
200
+ }
201
+ return Array.from(configs.values());
202
+ }
157
203
  /**
158
204
  * Checks if a provider type is registered
159
205
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AuthProviderFactory.js","sourceRoot":"","sources":["../src/AuthProviderFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE7E,gDAAgD;AAChD,OAAO,8BAA8B,CAAC;AACtC,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AACrC,OAAO,gCAAgC,CAAC;AACxC,OAAO,+BAA+B,CAAC;AACvC,OAAO,+BAA+B,CAAC;AACvC,OAAO,kCAAkC,CAAC;AAE1C;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAkC;IAezE;QACE,KAAK,EAAE,CAAC;QAfF,cAAS,GAA+B,IAAI,GAAG,EAAE,CAAC;QAC1D;;;;;;WAMG;QACK,gBAAW,GAAsC,IAAI,UAAU,CAAwB,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QAChH;;WAEG;QACK,qBAAgB,GAAwC,IAAI,UAAU,CAA0B,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IAIzH,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,QAAQ;QACxB,OAAO,mBAAmB,CAAC,WAAW,EAAuB,CAAC;IAChE,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,MAA0B;QAC9C,IAAI,CAAC;YACH,4DAA4D;YAC5D,0EAA0E;YAC1E,0EAA0E;YAC1E,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAC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;gBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,WAAW,CAAC;oBACV,OAAO,EAAE,kBAAkB,YAAY,CAAC,GAAG,iEAAiE,OAAO,EAAE;oBACrH,WAAW,EAAE,IAAI;iBAClB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,wBAAwB,CAAC,IAAY;QAC1C,IAAI,CAAC;YACH,qDAAqD;YACrD,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,eAAe,CAAC,gBAAgB,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YAC1G,OAAO,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,SAAS,CAAC;QAC7D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,51 @@
1
+ import type { AuthProviderConfig } from '@memberjunction/core';
2
+ /**
3
+ * Optional static contract a provider class implements to configure itself from environment
4
+ * variables.
5
+ *
6
+ * **Why this is a hook and not a list.** MJServer used to derive env-based providers from a
7
+ * hard-coded block that enumerated Entra, Auth0 and Cognito inline. That block was a closed
8
+ * domain in the one place the architecture is otherwise open: a third-party provider could
9
+ * register a class and take a metadata row or a `mj.config.cjs` entry, but it could never offer
10
+ * the "set two environment variables and you are done" experience the built-ins got, because
11
+ * the enumeration lived in core. Moving the mapping onto the provider class puts every provider
12
+ * — shipped or third-party — on the same footing.
13
+ *
14
+ * A provider that has no meaningful env-var form simply omits the static, and discovery skips it.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * @RegisterClass(BaseAuthProvider, 'my-idp')
19
+ * export class MyIdpProvider extends BaseAuthProvider {
20
+ * static ConfigFromEnvironment(env: NodeJS.ProcessEnv): AuthProviderConfig | null {
21
+ * if (!env.MY_IDP_DOMAIN || !env.MY_IDP_CLIENT_ID) return null;
22
+ * return {
23
+ * name: 'my-idp',
24
+ * type: 'my-idp',
25
+ * issuer: `https://${env.MY_IDP_DOMAIN}/`,
26
+ * audience: env.MY_IDP_CLIENT_ID,
27
+ * jwksUri: `https://${env.MY_IDP_DOMAIN}/.well-known/jwks.json`,
28
+ * clientId: env.MY_IDP_CLIENT_ID
29
+ * };
30
+ * }
31
+ * }
32
+ * ```
33
+ */
34
+ export interface IEnvironmentConfigurableProvider {
35
+ /**
36
+ * Builds this provider's configuration from environment variables.
37
+ *
38
+ * MUST return `null` — not a partial config — when its variables are absent or incomplete.
39
+ * A half-populated config would fail `validateConfig()` at registration and surface as a
40
+ * startup error on every deployment that simply does not use this provider.
41
+ *
42
+ * @param env The environment to read (injected rather than read from `process.env` directly
43
+ * so the mapping is testable without mutating global state).
44
+ */
45
+ ConfigFromEnvironment(env: NodeJS.ProcessEnv): AuthProviderConfig | null;
46
+ }
47
+ /**
48
+ * Narrows an unknown provider class to one that offers env-var configuration.
49
+ */
50
+ export declare function isEnvironmentConfigurable(subject: unknown): subject is IEnvironmentConfigurableProvider;
51
+ //# sourceMappingURL=IEnvironmentConfigurableProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEnvironmentConfigurableProvider.d.ts","sourceRoot":"","sources":["../src/IEnvironmentConfigurableProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,WAAW,gCAAgC;IAC/C;;;;;;;;;OASG;IACH,qBAAqB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,kBAAkB,GAAG,IAAI,CAAC;CAC1E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,gCAAgC,CAEvG"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Narrows an unknown provider class to one that offers env-var configuration.
3
+ */
4
+ export function isEnvironmentConfigurable(subject) {
5
+ return typeof subject?.ConfigFromEnvironment === 'function';
6
+ }
7
+ //# sourceMappingURL=IEnvironmentConfigurableProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEnvironmentConfigurableProvider.js","sourceRoot":"","sources":["../src/IEnvironmentConfigurableProvider.ts"],"names":[],"mappings":"AAgDA;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACxD,OAAO,OAAQ,OAAwD,EAAE,qBAAqB,KAAK,UAAU,CAAC;AAChH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { IAuthProvider } from './IAuthProvider.js';
2
2
  export { BaseAuthProvider } from './BaseAuthProvider.js';
3
3
  export { AuthProviderFactory } from './AuthProviderFactory.js';
4
4
  export { TokenExpiredError } from './tokenExpiredError.js';
5
+ export { type IEnvironmentConfigurableProvider, isEnvironmentConfigurable } from './IEnvironmentConfigurableProvider.js';
5
6
  export { MagicLinkProvider } from './providers/MagicLinkProvider.js';
6
7
  export { HostIdentityProvider, type HostAssertionVerifyResult, type HostAssertionError, } from './providers/HostIdentityProvider.js';
7
8
  export type { AuthProviderConfig, AuthUserInfo } from '@memberjunction/core';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CA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AA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { BaseAuthProvider } from './BaseAuthProvider.js';
2
2
  export { AuthProviderFactory } from './AuthProviderFactory.js';
3
3
  export { TokenExpiredError } from './tokenExpiredError.js';
4
+ export { isEnvironmentConfigurable } from './IEnvironmentConfigurableProvider.js';
4
5
  export { MagicLinkProvider } from './providers/MagicLinkProvider.js';
5
6
  export { HostIdentityProvider, } from './providers/HostIdentityProvider.js';
6
7
  // Concrete auth providers. These are @RegisterClass plugins resolved by key at runtime, so
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,oBAAoB,GAGrB,MAAM,qCAAqC,CAAC;AAK7C,2FAA2F;AAC3F,sFAAsF;AACtF,yFAAyF;AACzF,6DAA6D;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAyC,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AACzH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,oBAAoB,GAGrB,MAAM,qCAAqC,CAAC;AAK7C,2FAA2F;AAC3F,sFAAsF;AACtF,yFAAyF;AACzF,6DAA6D;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC"}
@@ -6,6 +6,13 @@ import { BaseAuthProvider } from '../BaseAuthProvider.js';
6
6
  */
7
7
  export declare class Auth0Provider extends BaseAuthProvider {
8
8
  constructor(config: AuthProviderConfig);
9
+ /**
10
+ * Configures Auth0 from AUTH0_DOMAIN + AUTH0_CLIENT_ID (AUTH0_CLIENT_SECRET optional).
11
+ *
12
+ * Mapping preserved byte-for-byte from the env block that previously lived in MJServer's
13
+ * config, so a deployment upgrading to the hook-based discovery sees no change.
14
+ */
15
+ static ConfigFromEnvironment(env: NodeJS.ProcessEnv): AuthProviderConfig | null;
9
16
  /**
10
17
  * Extracts user information from Auth0 JWT payload
11
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Auth0Provider.d.ts","sourceRoot":"","sources":["../../src/providers/Auth0Provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;GAEG;AACH,qBACa,aAAc,SAAQ,gBAAgB;gBACrC,MAAM,EAAE,kBAAkB;IAItC;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,YAAY;IAiBlD;;OAEG;IACH,cAAc,IAAI,OAAO;CAO1B"}
1
+ {"version":3,"file":"Auth0Provider.d.ts","sourceRoot":"","sources":["../../src/providers/Auth0Provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;GAEG;AACH,qBACa,aAAc,SAAQ,gBAAgB;gBACrC,MAAM,EAAE,kBAAkB;IAItC;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,kBAAkB,GAAG,IAAI;IAgB/E;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,YAAY;IAiBlD;;OAEG;IACH,cAAc,IAAI,OAAO;CAO1B"}