strapi-plugin-oidc 1.0.17 → 1.0.18

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.
@@ -54,7 +54,7 @@ const index = {
54
54
  defaultMessage: "Configuration"
55
55
  },
56
56
  Component: async () => {
57
- return await import("./index-Uf8y9MCa.mjs");
57
+ return await import("./index-BpfwqZXc.mjs");
58
58
  },
59
59
  permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
60
60
  }
@@ -66,6 +66,19 @@ const index = {
66
66
  });
67
67
  },
68
68
  bootstrap() {
69
+ let isLogoutInProgress = false;
70
+ const isAuthRoute = (path) => {
71
+ const match = path.match(/\/auth\/(login|register|forgot-password|reset-password)/);
72
+ return match !== null;
73
+ };
74
+ const initialPath = window.location.pathname;
75
+ let styleElem = null;
76
+ if (isAuthRoute(initialPath) && !isLogoutInProgress) {
77
+ styleElem = document.createElement("style");
78
+ styleElem.innerHTML = "body { display: none !important; }";
79
+ document.head.appendChild(styleElem);
80
+ }
81
+ let willRedirect = false;
69
82
  const checkEnforceOIDC = async () => {
70
83
  try {
71
84
  const response = await window.fetch("/strapi-plugin-oidc/settings/public");
@@ -73,15 +86,17 @@ const index = {
73
86
  const data = await response.json();
74
87
  if (data.enforceOIDC) {
75
88
  const currentPath = window.location.pathname;
76
- if (currentPath.endsWith("/auth/login")) {
89
+ if (isAuthRoute(currentPath) && !isLogoutInProgress) {
90
+ willRedirect = true;
77
91
  window.location.href = "/strapi-plugin-oidc/oidc";
92
+ return;
78
93
  }
79
94
  const interceptHistory = (originalMethod) => {
80
95
  return function(...args) {
81
96
  const url = args[2];
82
97
  if (url && typeof url === "string") {
83
98
  const urlWithoutQuery = url.split("?")[0].split("#")[0];
84
- if (urlWithoutQuery.endsWith("/auth/login")) {
99
+ if (isAuthRoute(urlWithoutQuery) && !isLogoutInProgress) {
85
100
  window.location.href = "/strapi-plugin-oidc/oidc";
86
101
  return;
87
102
  }
@@ -95,6 +110,10 @@ const index = {
95
110
  }
96
111
  } catch (error) {
97
112
  console.error("Failed to check OIDC enforcement setting:", error);
113
+ } finally {
114
+ if (!willRedirect && styleElem && styleElem.parentNode) {
115
+ styleElem.parentNode.removeChild(styleElem);
116
+ }
98
117
  }
99
118
  };
100
119
  checkEnforceOIDC();
@@ -102,9 +121,14 @@ const index = {
102
121
  window.fetch = async (...args) => {
103
122
  const url = typeof args[0] === "string" ? args[0] : args[0].url;
104
123
  const isLogout = url && url.endsWith("/admin/logout") && args[1]?.method?.toUpperCase() === "POST";
124
+ if (isLogout) {
125
+ isLogoutInProgress = true;
126
+ }
105
127
  const response = await originalFetch(...args);
106
128
  if (isLogout && response.ok) {
107
129
  window.location.href = "/strapi-plugin-oidc/logout";
130
+ } else if (isLogout) {
131
+ isLogoutInProgress = false;
108
132
  }
109
133
  return response;
110
134
  };
@@ -5,7 +5,7 @@ import { useState, useCallback, useEffect, memo } from "react";
5
5
  import { Typography, Flex, Box, MultiSelect, MultiSelectOption, Field, Button, Divider, Thead, Tr, Th, Tbody, Td, Dialog, IconButton, Pagination, PreviousLink, PageLink, NextLink, Table, Alert } from "@strapi/design-system";
6
6
  import { Plus, Trash, WarningCircle } from "@strapi/icons";
7
7
  import { useIntl } from "react-intl";
8
- import { p as pluginId } from "./index-CaPOaw8Q.mjs";
8
+ import { p as pluginId } from "./index-BBRKt8XS.mjs";
9
9
  import en from "./en-DInn-mdh.mjs";
10
10
  import styled from "styled-components";
11
11
  function getTrad(id) {
@@ -55,7 +55,7 @@ const index = {
55
55
  defaultMessage: "Configuration"
56
56
  },
57
57
  Component: async () => {
58
- return await Promise.resolve().then(() => require("./index-Dc3dS0bs.js"));
58
+ return await Promise.resolve().then(() => require("./index-Dw-jQQYI.js"));
59
59
  },
60
60
  permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
61
61
  }
@@ -67,6 +67,19 @@ const index = {
67
67
  });
68
68
  },
69
69
  bootstrap() {
70
+ let isLogoutInProgress = false;
71
+ const isAuthRoute = (path) => {
72
+ const match = path.match(/\/auth\/(login|register|forgot-password|reset-password)/);
73
+ return match !== null;
74
+ };
75
+ const initialPath = window.location.pathname;
76
+ let styleElem = null;
77
+ if (isAuthRoute(initialPath) && !isLogoutInProgress) {
78
+ styleElem = document.createElement("style");
79
+ styleElem.innerHTML = "body { display: none !important; }";
80
+ document.head.appendChild(styleElem);
81
+ }
82
+ let willRedirect = false;
70
83
  const checkEnforceOIDC = async () => {
71
84
  try {
72
85
  const response = await window.fetch("/strapi-plugin-oidc/settings/public");
@@ -74,15 +87,17 @@ const index = {
74
87
  const data = await response.json();
75
88
  if (data.enforceOIDC) {
76
89
  const currentPath = window.location.pathname;
77
- if (currentPath.endsWith("/auth/login")) {
90
+ if (isAuthRoute(currentPath) && !isLogoutInProgress) {
91
+ willRedirect = true;
78
92
  window.location.href = "/strapi-plugin-oidc/oidc";
93
+ return;
79
94
  }
80
95
  const interceptHistory = (originalMethod) => {
81
96
  return function(...args) {
82
97
  const url = args[2];
83
98
  if (url && typeof url === "string") {
84
99
  const urlWithoutQuery = url.split("?")[0].split("#")[0];
85
- if (urlWithoutQuery.endsWith("/auth/login")) {
100
+ if (isAuthRoute(urlWithoutQuery) && !isLogoutInProgress) {
86
101
  window.location.href = "/strapi-plugin-oidc/oidc";
87
102
  return;
88
103
  }
@@ -96,6 +111,10 @@ const index = {
96
111
  }
97
112
  } catch (error) {
98
113
  console.error("Failed to check OIDC enforcement setting:", error);
114
+ } finally {
115
+ if (!willRedirect && styleElem && styleElem.parentNode) {
116
+ styleElem.parentNode.removeChild(styleElem);
117
+ }
99
118
  }
100
119
  };
101
120
  checkEnforceOIDC();
@@ -103,9 +122,14 @@ const index = {
103
122
  window.fetch = async (...args) => {
104
123
  const url = typeof args[0] === "string" ? args[0] : args[0].url;
105
124
  const isLogout = url && url.endsWith("/admin/logout") && args[1]?.method?.toUpperCase() === "POST";
125
+ if (isLogout) {
126
+ isLogoutInProgress = true;
127
+ }
106
128
  const response = await originalFetch(...args);
107
129
  if (isLogout && response.ok) {
108
130
  window.location.href = "/strapi-plugin-oidc/logout";
131
+ } else if (isLogout) {
132
+ isLogoutInProgress = false;
109
133
  }
110
134
  return response;
111
135
  };
@@ -7,7 +7,7 @@ const react = require("react");
7
7
  const designSystem = require("@strapi/design-system");
8
8
  const icons = require("@strapi/icons");
9
9
  const reactIntl = require("react-intl");
10
- const index = require("./index-CnfUHUlY.js");
10
+ const index = require("./index-D-EIdjjQ.js");
11
11
  const en = require("./en-8UlbiAHW.js");
12
12
  const styled = require("styled-components");
13
13
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const index = require("./index-CnfUHUlY.js");
3
+ const index = require("./index-D-EIdjjQ.js");
4
4
  exports.default = index.index;
@@ -1,4 +1,4 @@
1
- import { i } from "./index-CaPOaw8Q.mjs";
1
+ import { i } from "./index-BBRKt8XS.mjs";
2
2
  export {
3
3
  i as default
4
4
  };
@@ -12,7 +12,8 @@ function register$1() {
12
12
  }
13
13
  async function bootstrap({ strapi: strapi2 }) {
14
14
  strapi2.server.use(async (ctx, next) => {
15
- if (ctx.request.path === "/admin/login" && ctx.request.method === "POST") {
15
+ const adminUrl = strapi2.config.get("admin.url", "/admin");
16
+ if (ctx.request.path === `${adminUrl}/login` && ctx.request.method === "POST") {
16
17
  try {
17
18
  const whitelistService2 = strapi2.plugin("strapi-plugin-oidc").service("whitelist");
18
19
  const settings = await whitelistService2.getSettings();
@@ -33,6 +34,18 @@ async function bootstrap({ strapi: strapi2 }) {
33
34
  strapi2.log.error("Error checking OIDC enforcement in middleware:", err);
34
35
  }
35
36
  }
37
+ if (ctx.request.method === "GET" && (ctx.request.path.startsWith(`${adminUrl}/auth/login`) || ctx.request.path.startsWith(`${adminUrl}/auth/register`) || ctx.request.path.startsWith(`${adminUrl}/auth/forgot-password`) || ctx.request.path.startsWith(`${adminUrl}/auth/reset-password`))) {
38
+ try {
39
+ const whitelistService2 = strapi2.plugin("strapi-plugin-oidc").service("whitelist");
40
+ const settings = await whitelistService2.getSettings();
41
+ if (settings && settings.enforceOIDC) {
42
+ ctx.redirect("/strapi-plugin-oidc/oidc");
43
+ return;
44
+ }
45
+ } catch (err) {
46
+ strapi2.log.error("Error checking OIDC enforcement in GET middleware:", err);
47
+ }
48
+ }
36
49
  await next();
37
50
  });
38
51
  const actions = [
@@ -6,7 +6,8 @@ function register$1() {
6
6
  }
7
7
  async function bootstrap({ strapi: strapi2 }) {
8
8
  strapi2.server.use(async (ctx, next) => {
9
- if (ctx.request.path === "/admin/login" && ctx.request.method === "POST") {
9
+ const adminUrl = strapi2.config.get("admin.url", "/admin");
10
+ if (ctx.request.path === `${adminUrl}/login` && ctx.request.method === "POST") {
10
11
  try {
11
12
  const whitelistService2 = strapi2.plugin("strapi-plugin-oidc").service("whitelist");
12
13
  const settings = await whitelistService2.getSettings();
@@ -27,6 +28,18 @@ async function bootstrap({ strapi: strapi2 }) {
27
28
  strapi2.log.error("Error checking OIDC enforcement in middleware:", err);
28
29
  }
29
30
  }
31
+ if (ctx.request.method === "GET" && (ctx.request.path.startsWith(`${adminUrl}/auth/login`) || ctx.request.path.startsWith(`${adminUrl}/auth/register`) || ctx.request.path.startsWith(`${adminUrl}/auth/forgot-password`) || ctx.request.path.startsWith(`${adminUrl}/auth/reset-password`))) {
32
+ try {
33
+ const whitelistService2 = strapi2.plugin("strapi-plugin-oidc").service("whitelist");
34
+ const settings = await whitelistService2.getSettings();
35
+ if (settings && settings.enforceOIDC) {
36
+ ctx.redirect("/strapi-plugin-oidc/oidc");
37
+ return;
38
+ }
39
+ } catch (err) {
40
+ strapi2.log.error("Error checking OIDC enforcement in GET middleware:", err);
41
+ }
42
+ }
30
43
  await next();
31
44
  });
32
45
  const actions = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-oidc",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
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",