strapi-plugin-oidc 1.1.1 → 1.1.2

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.
@@ -55,7 +55,7 @@ const index = {
55
55
  defaultMessage: "Configuration"
56
56
  },
57
57
  Component: async () => {
58
- return await Promise.resolve().then(() => require("./index-B2lPDW7A.js"));
58
+ return await Promise.resolve().then(() => require("./index-aBuEmqza.js"));
59
59
  },
60
60
  permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
61
61
  }
@@ -80,7 +80,10 @@ const index = {
80
80
  const url = args[2];
81
81
  if (url && typeof url === "string") {
82
82
  const urlWithoutQuery = url.split("?")[0].split("#")[0];
83
- if (isAuthRoute(urlWithoutQuery) && !isLogoutInProgress) {
83
+ if (isAuthRoute(urlWithoutQuery)) {
84
+ if (isLogoutInProgress) {
85
+ return;
86
+ }
84
87
  window.location.href = "/strapi-plugin-oidc/oidc";
85
88
  return;
86
89
  }
@@ -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-BsP7WM7b.mjs";
8
+ import { p as pluginId } from "./index-DxsqJhUk.mjs";
9
9
  import en from "./en-DInn-mdh.mjs";
10
10
  import styled from "styled-components";
11
11
  function getTrad(id) {
@@ -54,7 +54,7 @@ const index = {
54
54
  defaultMessage: "Configuration"
55
55
  },
56
56
  Component: async () => {
57
- return await import("./index-CxxsmBsC.mjs");
57
+ return await import("./index-DDUvU8_H.mjs");
58
58
  },
59
59
  permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }]
60
60
  }
@@ -79,7 +79,10 @@ const index = {
79
79
  const url = args[2];
80
80
  if (url && typeof url === "string") {
81
81
  const urlWithoutQuery = url.split("?")[0].split("#")[0];
82
- if (isAuthRoute(urlWithoutQuery) && !isLogoutInProgress) {
82
+ if (isAuthRoute(urlWithoutQuery)) {
83
+ if (isLogoutInProgress) {
84
+ return;
85
+ }
83
86
  window.location.href = "/strapi-plugin-oidc/oidc";
84
87
  return;
85
88
  }
@@ -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-Dj2m6xLY.js");
10
+ const index = require("./index-Csm9fJS0.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-Dj2m6xLY.js");
3
+ const index = require("./index-Csm9fJS0.js");
4
4
  exports.default = index.index;
@@ -1,4 +1,4 @@
1
- import { i } from "./index-BsP7WM7b.mjs";
1
+ import { i } from "./index-DxsqJhUk.mjs";
2
2
  export {
3
3
  i as default
4
4
  };
@@ -11,7 +11,7 @@ const generator__default = /* @__PURE__ */ _interopDefault(generator);
11
11
  function register$1() {
12
12
  }
13
13
  async function bootstrap({ strapi: strapi2 }) {
14
- strapi2.server.use(async (ctx, next) => {
14
+ const enforceOidcMiddleware = async (ctx, next) => {
15
15
  const adminUrl = strapi2.config.get("admin.url", "/admin");
16
16
  const authRoutes = [
17
17
  `${adminUrl}/login`,
@@ -20,7 +20,7 @@ async function bootstrap({ strapi: strapi2 }) {
20
20
  `${adminUrl}/reset-password`
21
21
  ];
22
22
  const isPostAuth = authRoutes.includes(ctx.request.path) && ctx.request.method === "POST";
23
- const isHtmlRequest = ctx.request.accepts("html") && !ctx.request.path.match(/\.[a-zA-Z0-9]+$/);
23
+ const isHtmlRequest = ctx.request.accepts("html", "json") === "html" && !ctx.request.path.match(/\.[a-zA-Z0-9]+$/);
24
24
  const isGetAdminHtml = ctx.request.method === "GET" && ctx.request.path.startsWith(adminUrl) && isHtmlRequest;
25
25
  if (isPostAuth || isGetAdminHtml) {
26
26
  try {
@@ -53,7 +53,12 @@ async function bootstrap({ strapi: strapi2 }) {
53
53
  }
54
54
  }
55
55
  await next();
56
- });
56
+ };
57
+ if (strapi2.server.app && Array.isArray(strapi2.server.app.middleware)) {
58
+ strapi2.server.app.middleware.unshift(enforceOidcMiddleware);
59
+ } else {
60
+ strapi2.server.use(enforceOidcMiddleware);
61
+ }
57
62
  const actions = [
58
63
  {
59
64
  section: "plugins",
@@ -5,7 +5,7 @@ import generator from "generate-password";
5
5
  function register$1() {
6
6
  }
7
7
  async function bootstrap({ strapi: strapi2 }) {
8
- strapi2.server.use(async (ctx, next) => {
8
+ const enforceOidcMiddleware = async (ctx, next) => {
9
9
  const adminUrl = strapi2.config.get("admin.url", "/admin");
10
10
  const authRoutes = [
11
11
  `${adminUrl}/login`,
@@ -14,7 +14,7 @@ async function bootstrap({ strapi: strapi2 }) {
14
14
  `${adminUrl}/reset-password`
15
15
  ];
16
16
  const isPostAuth = authRoutes.includes(ctx.request.path) && ctx.request.method === "POST";
17
- const isHtmlRequest = ctx.request.accepts("html") && !ctx.request.path.match(/\.[a-zA-Z0-9]+$/);
17
+ const isHtmlRequest = ctx.request.accepts("html", "json") === "html" && !ctx.request.path.match(/\.[a-zA-Z0-9]+$/);
18
18
  const isGetAdminHtml = ctx.request.method === "GET" && ctx.request.path.startsWith(adminUrl) && isHtmlRequest;
19
19
  if (isPostAuth || isGetAdminHtml) {
20
20
  try {
@@ -47,7 +47,12 @@ async function bootstrap({ strapi: strapi2 }) {
47
47
  }
48
48
  }
49
49
  await next();
50
- });
50
+ };
51
+ if (strapi2.server.app && Array.isArray(strapi2.server.app.middleware)) {
52
+ strapi2.server.app.middleware.unshift(enforceOidcMiddleware);
53
+ } else {
54
+ strapi2.server.use(enforceOidcMiddleware);
55
+ }
51
56
  const actions = [
52
57
  {
53
58
  section: "plugins",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-oidc",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
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",