mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 09:25:43 +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 () => {
|
onSuccess: async () => {
|
||||||
await queryClient.invalidateQueries("config");
|
await queryClient.invalidateQueries("config");
|
||||||
await queryClient.invalidateQueries("index");
|
await queryClient.invalidateQueries("index");
|
||||||
|
await queryClient.invalidateQueries("pluginCenterAuth");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
"authenticate": "Authentifizieren",
|
"authenticate": "Authentifizieren",
|
||||||
"authenticated": "Das Plugin Center ist als <0 /> authentifiziert",
|
"authenticated": "Das Plugin Center ist als <0 /> authentifiziert",
|
||||||
"subjectTooltip": "Authentifiziert als {{ principal }} {{ ago }}",
|
"subjectTooltip": "Authentifiziert als {{ principal }} {{ ago }}",
|
||||||
"logout": "Abmelden"
|
"logout": "Abmelden",
|
||||||
|
"notConfiguredHint": "Authentifizierungs URL ist nicht gesetzt"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"proxySettings": {
|
"proxySettings": {
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
"authenticate": "Authenticate",
|
"authenticate": "Authenticate",
|
||||||
"authenticated": "Plugin Center is authenticated as <0 />",
|
"authenticated": "Plugin Center is authenticated as <0 />",
|
||||||
"subjectTooltip": "Authenticated by {{ principal }} {{ ago }}",
|
"subjectTooltip": "Authenticated by {{ principal }} {{ ago }}",
|
||||||
"logout": "Logout"
|
"logout": "Logout",
|
||||||
|
"notConfiguredHint": "Authentication URL is not configured"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"proxySettings": {
|
"proxySettings": {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import React, { FC } from "react";
|
|||||||
import { usePluginCenterAuthInfo, usePluginCenterLogout } from "@scm-manager/ui-api";
|
import { usePluginCenterAuthInfo, usePluginCenterLogout } from "@scm-manager/ui-api";
|
||||||
import { Button, ErrorNotification, Notification, Tooltip, useDateFormatter } from "@scm-manager/ui-components";
|
import { Button, ErrorNotification, Notification, Tooltip, useDateFormatter } from "@scm-manager/ui-components";
|
||||||
import { Link, PluginCenterAuthenticationInfo } from "@scm-manager/ui-types";
|
import { Link, PluginCenterAuthenticationInfo } from "@scm-manager/ui-types";
|
||||||
import { useLocation } from "react-router-dom";
|
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { Trans, useTranslation } from "react-i18next";
|
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 PluginCenterAuthentication: FC = () => {
|
||||||
const { data, isLoading, error } = usePluginCenterAuthInfo();
|
const { data, isLoading, error } = usePluginCenterAuthInfo();
|
||||||
const location = useLocation();
|
|
||||||
const [t] = useTranslation("config");
|
const [t] = useTranslation("config");
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
@@ -109,16 +116,16 @@ const PluginCenterAuthentication: FC = () => {
|
|||||||
return <AuthenticatedInfo authenticationInfo={data} />;
|
return <AuthenticatedInfo authenticationInfo={data} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data._links.login) {
|
||||||
return (
|
return (
|
||||||
<Notification type="inherit" className="is-flex is-justify-content-space-between is-align-content-center">
|
<Notification type="inherit" className="is-flex is-justify-content-space-between is-align-content-center">
|
||||||
<Message>{t("pluginSettings.auth.notAuthenticated")}</Message>
|
<Message>{t("pluginSettings.auth.notAuthenticated")}</Message>
|
||||||
{data._links.login ? (
|
<LoginButton link={data._links.login as Link} />
|
||||||
<Button color="primary" link={(data._links.login as Link).href + "?source=" + location.pathname}>
|
|
||||||
{t("pluginSettings.auth.authenticate")}
|
|
||||||
</Button>
|
|
||||||
) : null}
|
|
||||||
</Notification>
|
</Notification>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default PluginCenterAuthentication;
|
export default PluginCenterAuthentication;
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ public class PluginCenterAuthResource {
|
|||||||
.toASCIIString();
|
.toASCIIString();
|
||||||
builder.single(Link.link("reconnect", reconnectLink));
|
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()));
|
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");
|
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
|
@Test
|
||||||
@SubjectAware(value = "marvin", permissions = "plugin:write")
|
@SubjectAware(value = "marvin", permissions = "plugin:write")
|
||||||
void shouldReturnReconnectAndLogoutLinkForFailedAuthentication() throws URISyntaxException, IOException {
|
void shouldReturnReconnectAndLogoutLinkForFailedAuthentication() throws URISyntaxException, IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user