strapi-plugin-oidc 1.8.1 → 1.8.3

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.
@@ -12,6 +12,58 @@ const strapiUtils__default = /* @__PURE__ */ _interopDefault(strapiUtils);
12
12
  const generator__default = /* @__PURE__ */ _interopDefault(generator);
13
13
  function register$1() {
14
14
  }
15
+ const errorCodes = {
16
+ TOKEN_EXCHANGE_FAILED: "TOKEN_EXCHANGE_FAILED",
17
+ USERINFO_FETCH_FAILED: "USERINFO_FETCH_FAILED",
18
+ ID_TOKEN_PARSE_FAILED: "ID_TOKEN_PARSE_FAILED",
19
+ NONCE_MISMATCH: "NONCE_MISMATCH",
20
+ ROLE_UPDATE_FAILED: "ROLE_UPDATE_FAILED",
21
+ USER_CREATION_FAILED: "USER_CREATION_FAILED",
22
+ WHITELIST_CHECK_FAILED: "WHITELIST_CHECK_FAILED",
23
+ EMAIL_NOT_VERIFIED: "EMAIL_NOT_VERIFIED",
24
+ ID_TOKEN_INVALID: "ID_TOKEN_INVALID"
25
+ };
26
+ const ERROR_DETAIL_TEMPLATES = {
27
+ token_exchange_failed: "Token exchange failed with HTTP status {status}",
28
+ userinfo_fetch_failed: "UserInfo endpoint returned HTTP {status}",
29
+ role_update_failed: "Role update failed for user {userId}: {error}",
30
+ user_creation_failed: "User creation failed for {email}: {error}",
31
+ id_token_parse_failed: "ID token parse failed: {error}",
32
+ sign_in_unknown: "Unknown sign-in error: {error}",
33
+ invalid_email: "Invalid email address received from OIDC provider",
34
+ email_not_verified: "Email address has not been verified by the OIDC provider",
35
+ id_token_invalid: "ID token verification failed: {error}",
36
+ whitelist_not_present: "Email not present in whitelist",
37
+ session_manager_unsupported: "sessionManager is not supported. Please upgrade to Strapi v5.24.1 or later."
38
+ };
39
+ function interpolate$1(template, params) {
40
+ if (!params) return template;
41
+ return template.replace(/\{(\w+)\}/g, (_, key) => String(params[key] ?? `{${key}}`));
42
+ }
43
+ function getErrorDetail(key, params) {
44
+ const template = ERROR_DETAIL_TEMPLATES[key];
45
+ if (!template) return void 0;
46
+ return interpolate$1(template, params);
47
+ }
48
+ const errorMessages = {
49
+ TOKEN_EXCHANGE_FAILED: "Token exchange failed",
50
+ USERINFO_FETCH_FAILED: "Failed to fetch user info",
51
+ ID_TOKEN_PARSE_FAILED: "Failed to parse ID token",
52
+ NONCE_MISMATCH: "Nonce mismatch",
53
+ INVALID_EMAIL: "Invalid email address received from OIDC provider",
54
+ EMAIL_NOT_VERIFIED: "Email address has not been verified by the OIDC provider",
55
+ ID_TOKEN_INVALID: "ID token verification failed",
56
+ WHITELIST_NOT_PRESENT: "Not present in whitelist",
57
+ SESSION_MANAGER_UNSUPPORTED: "sessionManager is not supported. Please upgrade to Strapi v5.24.1 or later.",
58
+ JWKS_URI_NOT_CONFIGURED: "[OIDC] OIDC_JWKS_URI is not configured — ID token signature verification is disabled. Set OIDC_JWKS_URI and OIDC_ISSUER from your provider's discovery document.",
59
+ ENFORCE_MIDDLEWARE_ERROR: "Error checking OIDC enforcement in middleware:",
60
+ ENFORCE_SYNC_ERROR: "[strapi-plugin-oidc] Failed to sync OIDC_ENFORCE to database:",
61
+ DEFAULT_ROLE_INIT_ERROR: "Could not initialize default OIDC role:",
62
+ AUDIT_LOG_CLEANUP_ERROR: "[strapi-plugin-oidc] Audit log cleanup failed:",
63
+ AUDIT_LOG_EXPORT_ERROR: "NDJSON export stream failed",
64
+ DISCOVERY_FETCH_ERROR: (url, reason) => `[strapi-plugin-oidc] Failed to fetch OIDC discovery document from ${url}: ${reason}`,
65
+ MISSING_CONFIG: (keys) => `Missing required config keys: ${keys}`
66
+ };
15
67
  function getEnforceOIDCConfig(strapi2) {
16
68
  const config2 = strapi2.config.get("plugin::strapi-plugin-oidc");
17
69
  const val = config2.OIDC_ENFORCE;
@@ -64,7 +116,7 @@ async function applyDiscovery(strapi2) {
64
116
  doc = await res.json();
65
117
  } catch (e) {
66
118
  strapi2.log.error(
67
- `[strapi-plugin-oidc] Failed to fetch OIDC discovery document from ${discoveryUrl}: ${e instanceof Error ? e.message : String(e)}`
119
+ errorMessages.DISCOVERY_FETCH_ERROR(discoveryUrl, e instanceof Error ? e.message : String(e))
68
120
  );
69
121
  return;
70
122
  }
@@ -121,7 +173,7 @@ async function bootstrap({ strapi: strapi2 }) {
121
173
  return;
122
174
  }
123
175
  } catch (err) {
124
- strapi2.log.error("Error checking OIDC enforcement in middleware:", err);
176
+ strapi2.log.error(errorMessages.ENFORCE_MIDDLEWARE_ERROR, err);
125
177
  }
126
178
  }
127
179
  await next();
@@ -158,7 +210,7 @@ async function bootstrap({ strapi: strapi2 }) {
158
210
  );
159
211
  }
160
212
  } catch (err) {
161
- strapi2.log.error("[strapi-plugin-oidc] Failed to sync OIDC_ENFORCE to database:", err);
213
+ strapi2.log.error(errorMessages.ENFORCE_SYNC_ERROR, err);
162
214
  }
163
215
  }
164
216
  try {
@@ -172,7 +224,7 @@ async function bootstrap({ strapi: strapi2 }) {
172
224
  }
173
225
  }
174
226
  } catch (err) {
175
- strapi2.log.warn("Could not initialize default OIDC role:", err.message);
227
+ strapi2.log.warn(errorMessages.DEFAULT_ROLE_INIT_ERROR, err.message);
176
228
  }
177
229
  strapi2.cron.add({
178
230
  "strapi-plugin-oidc-audit-log-cleanup": {
@@ -181,7 +233,7 @@ async function bootstrap({ strapi: strapi2 }) {
181
233
  const retentionDays = getRetentionDays();
182
234
  await getAuditLogService().cleanup(retentionDays);
183
235
  } catch (err) {
184
- strapi2.log.warn("[strapi-plugin-oidc] Audit log cleanup failed:", err.message);
236
+ strapi2.log.warn(errorMessages.AUDIT_LOG_CLEANUP_ERROR, err.message);
185
237
  }
186
238
  },
187
239
  options: { rule: "0 0 * * *" }
@@ -297,52 +349,6 @@ const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
297
349
  function isValidEmail(email) {
298
350
  return EMAIL_REGEX.test(email);
299
351
  }
300
- const errorCodes = {
301
- TOKEN_EXCHANGE_FAILED: "TOKEN_EXCHANGE_FAILED",
302
- USERINFO_FETCH_FAILED: "USERINFO_FETCH_FAILED",
303
- ID_TOKEN_PARSE_FAILED: "ID_TOKEN_PARSE_FAILED",
304
- NONCE_MISMATCH: "NONCE_MISMATCH",
305
- ROLE_UPDATE_FAILED: "ROLE_UPDATE_FAILED",
306
- USER_CREATION_FAILED: "USER_CREATION_FAILED",
307
- WHITELIST_CHECK_FAILED: "WHITELIST_CHECK_FAILED",
308
- EMAIL_NOT_VERIFIED: "EMAIL_NOT_VERIFIED",
309
- ID_TOKEN_INVALID: "ID_TOKEN_INVALID"
310
- };
311
- const ERROR_DETAIL_TEMPLATES = {
312
- token_exchange_failed: "Token exchange failed with HTTP status {status}",
313
- userinfo_fetch_failed: "UserInfo endpoint returned HTTP {status}",
314
- role_update_failed: "Role update failed for user {userId}: {error}",
315
- user_creation_failed: "User creation failed for {email}: {error}",
316
- id_token_parse_failed: "ID token parse failed: {error}",
317
- sign_in_unknown: "Unknown sign-in error: {error}",
318
- invalid_email: "Invalid email address received from OIDC provider",
319
- email_not_verified: "Email address has not been verified by the OIDC provider",
320
- id_token_invalid: "ID token verification failed: {error}",
321
- whitelist_not_present: "Email not present in whitelist",
322
- session_manager_unsupported: "sessionManager is not supported. Please upgrade to Strapi v5.24.1 or later.",
323
- missing_config: "Missing required config keys: {keys}"
324
- };
325
- function interpolate$1(template, params) {
326
- if (!params) return template;
327
- return template.replace(/\{(\w+)\}/g, (_, key) => String(params[key] ?? `{${key}}`));
328
- }
329
- function getErrorDetail(key, params) {
330
- const template = ERROR_DETAIL_TEMPLATES[key];
331
- if (!template) return void 0;
332
- return interpolate$1(template, params);
333
- }
334
- const errorMessages = {
335
- TOKEN_EXCHANGE_FAILED: "Token exchange failed",
336
- USERINFO_FETCH_FAILED: "Failed to fetch user info",
337
- ID_TOKEN_PARSE_FAILED: "Failed to parse ID token",
338
- NONCE_MISMATCH: "Nonce mismatch",
339
- INVALID_EMAIL: "Invalid email address received from OIDC provider",
340
- EMAIL_NOT_VERIFIED: "Email address has not been verified by the OIDC provider",
341
- ID_TOKEN_INVALID: "ID token verification failed",
342
- WHITELIST_NOT_PRESENT: "Not present in whitelist",
343
- SESSION_MANAGER_UNSUPPORTED: "sessionManager is not supported. Please upgrade to Strapi v5.24.1 or later.",
344
- MISSING_CONFIG: (keys) => `Missing required config keys: ${keys}`
345
- };
346
352
  const en = {
347
353
  "global.plugins.strapi-plugin-oidc": "OIDC Plugin",
348
354
  "page.title": "Configure OIDC default role(s) and access controls.",
@@ -617,9 +623,7 @@ async function verifyIdToken(idToken, config2) {
617
623
  if (!jwksUri) {
618
624
  if (!jwksDisabledWarned) {
619
625
  jwksDisabledWarned = true;
620
- strapi.log.warn(
621
- "[OIDC] OIDC_JWKS_URI is not configured — ID token signature verification is disabled. Set OIDC_JWKS_URI and OIDC_ISSUER from your provider's discovery document."
622
- );
626
+ strapi.log.warn(errorMessages.JWKS_URI_NOT_CONFIGURED);
623
627
  }
624
628
  return null;
625
629
  }
@@ -1391,7 +1395,7 @@ function errorAwareNdjsonStream(strapi2, service, filters) {
1391
1395
  const gen = ndjsonRowStream(service, filters);
1392
1396
  const readable = node_stream.Readable.from(gen);
1393
1397
  readable.on("error", (err) => {
1394
- strapi2.log.error({ phase: "audit_log_export", err }, "NDJSON export stream failed");
1398
+ strapi2.log.error({ phase: "audit_log_export", err }, errorMessages.AUDIT_LOG_EXPORT_ERROR);
1395
1399
  });
1396
1400
  return readable;
1397
1401
  }
@@ -6,6 +6,58 @@ import strapiUtils from "@strapi/utils";
6
6
  import generator from "generate-password";
7
7
  function register$1() {
8
8
  }
9
+ const errorCodes = {
10
+ TOKEN_EXCHANGE_FAILED: "TOKEN_EXCHANGE_FAILED",
11
+ USERINFO_FETCH_FAILED: "USERINFO_FETCH_FAILED",
12
+ ID_TOKEN_PARSE_FAILED: "ID_TOKEN_PARSE_FAILED",
13
+ NONCE_MISMATCH: "NONCE_MISMATCH",
14
+ ROLE_UPDATE_FAILED: "ROLE_UPDATE_FAILED",
15
+ USER_CREATION_FAILED: "USER_CREATION_FAILED",
16
+ WHITELIST_CHECK_FAILED: "WHITELIST_CHECK_FAILED",
17
+ EMAIL_NOT_VERIFIED: "EMAIL_NOT_VERIFIED",
18
+ ID_TOKEN_INVALID: "ID_TOKEN_INVALID"
19
+ };
20
+ const ERROR_DETAIL_TEMPLATES = {
21
+ token_exchange_failed: "Token exchange failed with HTTP status {status}",
22
+ userinfo_fetch_failed: "UserInfo endpoint returned HTTP {status}",
23
+ role_update_failed: "Role update failed for user {userId}: {error}",
24
+ user_creation_failed: "User creation failed for {email}: {error}",
25
+ id_token_parse_failed: "ID token parse failed: {error}",
26
+ sign_in_unknown: "Unknown sign-in error: {error}",
27
+ invalid_email: "Invalid email address received from OIDC provider",
28
+ email_not_verified: "Email address has not been verified by the OIDC provider",
29
+ id_token_invalid: "ID token verification failed: {error}",
30
+ whitelist_not_present: "Email not present in whitelist",
31
+ session_manager_unsupported: "sessionManager is not supported. Please upgrade to Strapi v5.24.1 or later."
32
+ };
33
+ function interpolate$1(template, params) {
34
+ if (!params) return template;
35
+ return template.replace(/\{(\w+)\}/g, (_, key) => String(params[key] ?? `{${key}}`));
36
+ }
37
+ function getErrorDetail(key, params) {
38
+ const template = ERROR_DETAIL_TEMPLATES[key];
39
+ if (!template) return void 0;
40
+ return interpolate$1(template, params);
41
+ }
42
+ const errorMessages = {
43
+ TOKEN_EXCHANGE_FAILED: "Token exchange failed",
44
+ USERINFO_FETCH_FAILED: "Failed to fetch user info",
45
+ ID_TOKEN_PARSE_FAILED: "Failed to parse ID token",
46
+ NONCE_MISMATCH: "Nonce mismatch",
47
+ INVALID_EMAIL: "Invalid email address received from OIDC provider",
48
+ EMAIL_NOT_VERIFIED: "Email address has not been verified by the OIDC provider",
49
+ ID_TOKEN_INVALID: "ID token verification failed",
50
+ WHITELIST_NOT_PRESENT: "Not present in whitelist",
51
+ SESSION_MANAGER_UNSUPPORTED: "sessionManager is not supported. Please upgrade to Strapi v5.24.1 or later.",
52
+ JWKS_URI_NOT_CONFIGURED: "[OIDC] OIDC_JWKS_URI is not configured — ID token signature verification is disabled. Set OIDC_JWKS_URI and OIDC_ISSUER from your provider's discovery document.",
53
+ ENFORCE_MIDDLEWARE_ERROR: "Error checking OIDC enforcement in middleware:",
54
+ ENFORCE_SYNC_ERROR: "[strapi-plugin-oidc] Failed to sync OIDC_ENFORCE to database:",
55
+ DEFAULT_ROLE_INIT_ERROR: "Could not initialize default OIDC role:",
56
+ AUDIT_LOG_CLEANUP_ERROR: "[strapi-plugin-oidc] Audit log cleanup failed:",
57
+ AUDIT_LOG_EXPORT_ERROR: "NDJSON export stream failed",
58
+ DISCOVERY_FETCH_ERROR: (url, reason) => `[strapi-plugin-oidc] Failed to fetch OIDC discovery document from ${url}: ${reason}`,
59
+ MISSING_CONFIG: (keys) => `Missing required config keys: ${keys}`
60
+ };
9
61
  function getEnforceOIDCConfig(strapi2) {
10
62
  const config2 = strapi2.config.get("plugin::strapi-plugin-oidc");
11
63
  const val = config2.OIDC_ENFORCE;
@@ -58,7 +110,7 @@ async function applyDiscovery(strapi2) {
58
110
  doc = await res.json();
59
111
  } catch (e) {
60
112
  strapi2.log.error(
61
- `[strapi-plugin-oidc] Failed to fetch OIDC discovery document from ${discoveryUrl}: ${e instanceof Error ? e.message : String(e)}`
113
+ errorMessages.DISCOVERY_FETCH_ERROR(discoveryUrl, e instanceof Error ? e.message : String(e))
62
114
  );
63
115
  return;
64
116
  }
@@ -115,7 +167,7 @@ async function bootstrap({ strapi: strapi2 }) {
115
167
  return;
116
168
  }
117
169
  } catch (err) {
118
- strapi2.log.error("Error checking OIDC enforcement in middleware:", err);
170
+ strapi2.log.error(errorMessages.ENFORCE_MIDDLEWARE_ERROR, err);
119
171
  }
120
172
  }
121
173
  await next();
@@ -152,7 +204,7 @@ async function bootstrap({ strapi: strapi2 }) {
152
204
  );
153
205
  }
154
206
  } catch (err) {
155
- strapi2.log.error("[strapi-plugin-oidc] Failed to sync OIDC_ENFORCE to database:", err);
207
+ strapi2.log.error(errorMessages.ENFORCE_SYNC_ERROR, err);
156
208
  }
157
209
  }
158
210
  try {
@@ -166,7 +218,7 @@ async function bootstrap({ strapi: strapi2 }) {
166
218
  }
167
219
  }
168
220
  } catch (err) {
169
- strapi2.log.warn("Could not initialize default OIDC role:", err.message);
221
+ strapi2.log.warn(errorMessages.DEFAULT_ROLE_INIT_ERROR, err.message);
170
222
  }
171
223
  strapi2.cron.add({
172
224
  "strapi-plugin-oidc-audit-log-cleanup": {
@@ -175,7 +227,7 @@ async function bootstrap({ strapi: strapi2 }) {
175
227
  const retentionDays = getRetentionDays();
176
228
  await getAuditLogService().cleanup(retentionDays);
177
229
  } catch (err) {
178
- strapi2.log.warn("[strapi-plugin-oidc] Audit log cleanup failed:", err.message);
230
+ strapi2.log.warn(errorMessages.AUDIT_LOG_CLEANUP_ERROR, err.message);
179
231
  }
180
232
  },
181
233
  options: { rule: "0 0 * * *" }
@@ -291,52 +343,6 @@ const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
291
343
  function isValidEmail(email) {
292
344
  return EMAIL_REGEX.test(email);
293
345
  }
294
- const errorCodes = {
295
- TOKEN_EXCHANGE_FAILED: "TOKEN_EXCHANGE_FAILED",
296
- USERINFO_FETCH_FAILED: "USERINFO_FETCH_FAILED",
297
- ID_TOKEN_PARSE_FAILED: "ID_TOKEN_PARSE_FAILED",
298
- NONCE_MISMATCH: "NONCE_MISMATCH",
299
- ROLE_UPDATE_FAILED: "ROLE_UPDATE_FAILED",
300
- USER_CREATION_FAILED: "USER_CREATION_FAILED",
301
- WHITELIST_CHECK_FAILED: "WHITELIST_CHECK_FAILED",
302
- EMAIL_NOT_VERIFIED: "EMAIL_NOT_VERIFIED",
303
- ID_TOKEN_INVALID: "ID_TOKEN_INVALID"
304
- };
305
- const ERROR_DETAIL_TEMPLATES = {
306
- token_exchange_failed: "Token exchange failed with HTTP status {status}",
307
- userinfo_fetch_failed: "UserInfo endpoint returned HTTP {status}",
308
- role_update_failed: "Role update failed for user {userId}: {error}",
309
- user_creation_failed: "User creation failed for {email}: {error}",
310
- id_token_parse_failed: "ID token parse failed: {error}",
311
- sign_in_unknown: "Unknown sign-in error: {error}",
312
- invalid_email: "Invalid email address received from OIDC provider",
313
- email_not_verified: "Email address has not been verified by the OIDC provider",
314
- id_token_invalid: "ID token verification failed: {error}",
315
- whitelist_not_present: "Email not present in whitelist",
316
- session_manager_unsupported: "sessionManager is not supported. Please upgrade to Strapi v5.24.1 or later.",
317
- missing_config: "Missing required config keys: {keys}"
318
- };
319
- function interpolate$1(template, params) {
320
- if (!params) return template;
321
- return template.replace(/\{(\w+)\}/g, (_, key) => String(params[key] ?? `{${key}}`));
322
- }
323
- function getErrorDetail(key, params) {
324
- const template = ERROR_DETAIL_TEMPLATES[key];
325
- if (!template) return void 0;
326
- return interpolate$1(template, params);
327
- }
328
- const errorMessages = {
329
- TOKEN_EXCHANGE_FAILED: "Token exchange failed",
330
- USERINFO_FETCH_FAILED: "Failed to fetch user info",
331
- ID_TOKEN_PARSE_FAILED: "Failed to parse ID token",
332
- NONCE_MISMATCH: "Nonce mismatch",
333
- INVALID_EMAIL: "Invalid email address received from OIDC provider",
334
- EMAIL_NOT_VERIFIED: "Email address has not been verified by the OIDC provider",
335
- ID_TOKEN_INVALID: "ID token verification failed",
336
- WHITELIST_NOT_PRESENT: "Not present in whitelist",
337
- SESSION_MANAGER_UNSUPPORTED: "sessionManager is not supported. Please upgrade to Strapi v5.24.1 or later.",
338
- MISSING_CONFIG: (keys) => `Missing required config keys: ${keys}`
339
- };
340
346
  const en = {
341
347
  "global.plugins.strapi-plugin-oidc": "OIDC Plugin",
342
348
  "page.title": "Configure OIDC default role(s) and access controls.",
@@ -611,9 +617,7 @@ async function verifyIdToken(idToken, config2) {
611
617
  if (!jwksUri) {
612
618
  if (!jwksDisabledWarned) {
613
619
  jwksDisabledWarned = true;
614
- strapi.log.warn(
615
- "[OIDC] OIDC_JWKS_URI is not configured — ID token signature verification is disabled. Set OIDC_JWKS_URI and OIDC_ISSUER from your provider's discovery document."
616
- );
620
+ strapi.log.warn(errorMessages.JWKS_URI_NOT_CONFIGURED);
617
621
  }
618
622
  return null;
619
623
  }
@@ -1385,7 +1389,7 @@ function errorAwareNdjsonStream(strapi2, service, filters) {
1385
1389
  const gen = ndjsonRowStream(service, filters);
1386
1390
  const readable = Readable.from(gen);
1387
1391
  readable.on("error", (err) => {
1388
- strapi2.log.error({ phase: "audit_log_export", err }, "NDJSON export stream failed");
1392
+ strapi2.log.error({ phase: "audit_log_export", err }, errorMessages.AUDIT_LOG_EXPORT_ERROR);
1389
1393
  });
1390
1394
  return readable;
1391
1395
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-oidc",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "A Strapi plugin that provides OpenID Connect (OIDC) authentication functionality for the Strapi Admin Panel.",
5
5
  "strapi": {
6
6
  "displayName": "OIDC Plugin",