mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
Remove plugin center login without url (#1978)
This removes the "login" button for the plugin center, when the authentication url is not set.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
- type: fixed
|
||||
description: Remove plugin center login without url ([#1978](https://github.com/scm-manager/scm-manager/pull/1978))
|
||||
@@ -46,6 +46,7 @@ export const useUpdateConfig = () => {
|
||||
onSuccess: async () => {
|
||||
await queryClient.invalidateQueries("config");
|
||||
await queryClient.invalidateQueries("index");
|
||||
await queryClient.invalidateQueries("pluginCenterAuth");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
"authenticate": "Authentifizieren",
|
||||
"authenticated": "Das Plugin Center ist als <0 /> authentifiziert",
|
||||
"subjectTooltip": "Authentifiziert als {{ principal }} {{ ago }}",
|
||||
"logout": "Abmelden"
|
||||
"logout": "Abmelden",
|
||||
"notConfiguredHint": "Authentifizierungs URL ist nicht gesetzt"
|
||||
}
|
||||
},
|
||||
"proxySettings": {
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
"authenticate": "Authenticate",
|
||||
"authenticated": "Plugin Center is authenticated as <0 />",
|
||||
"subjectTooltip": "Authenticated by {{ principal }} {{ ago }}",
|
||||
"logout": "Logout"
|
||||
"logout": "Logout",
|
||||
"notConfiguredHint": "Authentication URL is not configured"
|
||||
}
|
||||
},
|
||||
"proxySettings": {
|
||||
|
||||
@@ -26,7 +26,6 @@ import React, { FC } from "react";
|
||||
import { usePluginCenterAuthInfo, usePluginCenterLogout } from "@scm-manager/ui-api";
|
||||
import { Button, ErrorNotification, Notification, Tooltip, useDateFormatter } from "@scm-manager/ui-components";
|
||||
import { Link, PluginCenterAuthenticationInfo } from "@scm-manager/ui-types";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
|
||||
@@ -83,9 +82,17 @@ const AuthenticatedInfo: FC<Props> = ({ authenticationInfo }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const LoginButton: FC<{ link: Link }> = ({ link }) => {
|
||||
const [t] = useTranslation("config");
|
||||
return (
|
||||
<Button color="primary" link={link.href}>
|
||||
{t("pluginSettings.auth.authenticate")}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
const PluginCenterAuthentication: FC = () => {
|
||||
const { data, isLoading, error } = usePluginCenterAuthInfo();
|
||||
const location = useLocation();
|
||||
const [t] = useTranslation("config");
|
||||
|
||||
if (isLoading) {
|
||||
@@ -109,16 +116,16 @@ const PluginCenterAuthentication: FC = () => {
|
||||
return <AuthenticatedInfo authenticationInfo={data} />;
|
||||
}
|
||||
|
||||
if (data._links.login) {
|
||||
return (
|
||||
<Notification type="inherit" className="is-flex is-justify-content-space-between is-align-content-center">
|
||||
<Message>{t("pluginSettings.auth.notAuthenticated")}</Message>
|
||||
{data._links.login ? (
|
||||
<Button color="primary" link={(data._links.login as Link).href + "?source=" + location.pathname}>
|
||||
{t("pluginSettings.auth.authenticate")}
|
||||
</Button>
|
||||
) : null}
|
||||
<LoginButton link={data._links.login as Link} />
|
||||
</Notification>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export default PluginCenterAuthentication;
|
||||
|
||||
@@ -263,7 +263,7 @@ public class PluginCenterAuthResource {
|
||||
.toASCIIString();
|
||||
builder.single(Link.link("reconnect", reconnectLink));
|
||||
}
|
||||
} else {
|
||||
} else if (!Strings.isNullOrEmpty(configuration.getPluginAuthUrl())) {
|
||||
builder.single(Link.link(METHOD_LOGIN, uriInfo.getAbsolutePathBuilder().path(METHOD_LOGIN).build().toASCIIString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +147,16 @@ class PluginCenterAuthResourceTest {
|
||||
assertThat(root.get("_links").get("login").get("href").asText()).isEqualTo("/v2/plugins/auth/login");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SubjectAware(value = "marvin", permissions = "plugin:write")
|
||||
void shouldNotReturnLoginLinkIfPermittedButNotConfigured() throws URISyntaxException, IOException {
|
||||
scmConfiguration.setPluginAuthUrl(null);
|
||||
|
||||
JsonNode root = getJson("/v2/plugins/auth");
|
||||
|
||||
assertThat(root.get("_links").get("login")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SubjectAware(value = "marvin", permissions = "plugin:write")
|
||||
void shouldReturnReconnectAndLogoutLinkForFailedAuthentication() throws URISyntaxException, IOException {
|
||||
|
||||
Reference in New Issue
Block a user