Remove plugin center authentication

Squash commits of branch feature/remove_plugin_center_auth:

- Remove plugin center authentication

- Fix i18n file

- Fix tests

- Changelog entry
This commit is contained in:
Florian Scholdei
2025-06-05 09:31:55 +02:00
parent 60b672cf59
commit a2afc40432
89 changed files with 76 additions and 3135 deletions

View File

@@ -43,7 +43,6 @@ describe("Test config hooks", () => {
namespaceStrategy: "",
emergencyContacts: [],
pluginUrl: "",
pluginAuthUrl: "",
proxyExcludes: [],
proxyPassword: null,
proxyPort: 0,

View File

@@ -55,7 +55,6 @@ export * from "./annotations";
export * from "./search";
export * from "./loginInfo";
export * from "./useInvalidation";
export * from "./usePluginCenterAuthInfo";
export * from "./compare";
export * from "./utils";
export * from "./links";

View File

@@ -40,7 +40,6 @@ describe("Test plugin hooks", () => {
pending: false,
dependencies: [],
optionalDependencies: [],
type: "SCM",
_links: {
install: { href: "/plugins/available/heart-of-gold-plugin/install" },
installWithRestart: {
@@ -59,7 +58,6 @@ describe("Test plugin hooks", () => {
markedForUninstall: false,
dependencies: [],
optionalDependencies: [],
type: "SCM",
_links: {
self: {
href: "/plugins/installed/heart-of-gold-plugin",
@@ -87,7 +85,6 @@ describe("Test plugin hooks", () => {
name: "heart-of-gold-core-plugin",
pending: false,
markedForUninstall: false,
type: "SCM",
dependencies: [],
optionalDependencies: [],
_links: {

View File

@@ -1,83 +0,0 @@
/*
* Copyright (c) 2020 - present Cloudogu GmbH
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
import { ApiResult, useIndexLink } from "./base";
import { Link, PluginCenterAuthenticationInfo } from "@scm-manager/ui-types";
import { useMutation, useQuery, useQueryClient } from "react-query";
import { apiClient } from "./apiclient";
import { useLocation } from "react-router-dom";
const appendQueryParam = (link: Link, name: string, value: string) => {
let href = link.href;
if (href.includes("?")) {
href += "&";
} else {
href += "?";
}
link.href = href + name + "=" + value;
};
export const usePluginCenterAuthInfo = (): ApiResult<PluginCenterAuthenticationInfo> => {
const link = useIndexLink("pluginCenterAuth");
const location = useLocation();
return useQuery<PluginCenterAuthenticationInfo, Error>(
["pluginCenterAuth"],
() => {
if (!link) {
throw new Error("no such plugin center auth link");
}
return apiClient
.get(link)
.then(response => response.json())
.then((result: PluginCenterAuthenticationInfo) => {
if (result._links?.login) {
appendQueryParam(result._links.login as Link, "source", location.pathname);
}
if (result._links?.reconnect) {
appendQueryParam(result._links.reconnect as Link, "source", location.pathname);
}
return result;
});
},
{
enabled: !!link
}
);
};
export const usePluginCenterLogout = (authenticationInfo: PluginCenterAuthenticationInfo) => {
const queryClient = useQueryClient();
const { mutate, isLoading, error } = useMutation<unknown, Error>(
() => {
if (!authenticationInfo._links.logout) {
throw new Error("authenticationInfo has no logout link");
}
const logout = authenticationInfo._links.logout as Link;
return apiClient.delete(logout.href);
},
{
onSuccess: () => queryClient.invalidateQueries("pluginCenterAuth")
}
);
return {
logout: () => {
mutate();
},
isLoading,
error
};
};