Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-32585 ECL Watch v9 redirect security routes non-admin #19068

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions esp/src/src-react/hooks/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useConst, useForceUpdate } from "@fluentui/react-hooks";
import { AccessService, AccountService, WsAccount } from "@hpcc-js/comms";
import { cookieKeyValStore } from "src/KeyValStore";

declare const dojoConfig;

const defaults = {
ESPSessionTimeout: 7200,
ESPAuthenticated: false,
Expand Down Expand Up @@ -97,12 +99,15 @@ export function useMyAccount(): { currentUser: WsAccount.MyAccountResponse, isAd
const adminGroupNames = ["Administrator", "Directory Administrators"];
if (response.isLDAPAdmin || groups.filter(group => !adminGroupNames.indexOf(group.name)).length > 0) {
setIsAdmin(true);
dojoConfig.isAdmin = true;
} else {
setIsAdmin(account.accountType === "Administrator");
dojoConfig.isAdmin = account.accountType === "Administrator";
}
});
} else {
setIsAdmin(true);
dojoConfig.isAdmin = true;
}
setCurrentUser(account);
});
Expand Down
4 changes: 4 additions & 0 deletions esp/src/src-react/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as React from "react";
import { Route, RouterContext } from "universal-router";
import { initialize, parsePage, parseSearch, parseSort, pushUrl, replaceUrl } from "./util/history";

declare const dojoConfig;

export type MainNav = "activities" | "workunits" | "files" | "queries" | "topology" | "operations";

export interface RouteEx<R = any, C extends RouterContext = RouterContext> extends Route<R, C> {
Expand Down Expand Up @@ -327,6 +329,7 @@ export const routes: RoutesEx = [
},
{
path: "/security",
action: () => { if (!dojoConfig.isAdmin) { replaceUrl("/topology"); } },
children: [
{
path: "", action: (ctx, params) => import("./components/Security").then(_ => {
Expand Down Expand Up @@ -462,6 +465,7 @@ export const routes: RoutesEx = [
{

path: "/security",
action: () => { if (!dojoConfig.isAdmin) { replaceUrl("/operations"); } },
children: [
{
path: "", action: (ctx, params) => import("./components/Security").then(_ => {
Expand Down
Loading