Skip to content

Commit 24234a1

Browse files
460 rbac apply policy checks (#13)
* 460 Adds policy checks for the navigation and its pages * 460 Applies Pages policies * 460 Updates env vars in the example files
1 parent 98dadd7 commit 24234a1

File tree

6 files changed

+56
-11
lines changed

6 files changed

+56
-11
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ NEXTAUTH_ISSUER="http://localhost:8085/realms/orchestrator"
1616
NEXTAUTH_WELL_KNOWN_OVERRIDE="http://localhost:8085/auth/.well-known/openid-configuration"
1717
NEXTAUTH_URL=http://localhost:3000/api/auth
1818

19+
OPA_PUBLIC_BUNDLE_URL="https://localhost/api/v1/opa/public-bundle"
20+
OPA_CLIENT_ID="orchestrator-client"
21+
1922
# docker-compose variables
2023
KEYCLOAK_ADMIN=admin
2124
KEYCLOAK_ADMIN_PASSWORD=admin

pages/metadata/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1+
import React from 'react';
2+
13
import { useRouter } from 'next/router';
24

5+
import {
6+
PolicyResource,
7+
WfoPageUnauthorized,
8+
usePolicy,
9+
} from '@orchestrator-ui/orchestrator-ui-components';
10+
311
export const IndexPage = () => {
412
const router = useRouter();
13+
const { isAllowed } = usePolicy();
14+
15+
if (!isAllowed(PolicyResource.NAVIGATION_METADATA)) {
16+
return <WfoPageUnauthorized />;
17+
}
18+
519
router.push('/metadata/products');
620
};
721

pages/subscriptions/index.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
import React from 'react';
22

3-
import { WfoSubscriptionsListPage } from '@orchestrator-ui/orchestrator-ui-components';
3+
import {
4+
PolicyResource,
5+
WfoPolicyRenderPageFallback,
6+
WfoSubscriptionsListPage,
7+
} from '@orchestrator-ui/orchestrator-ui-components';
48

59
export default function SubscriptionsPage() {
6-
return <WfoSubscriptionsListPage />;
10+
return (
11+
<WfoPolicyRenderPageFallback
12+
resource={PolicyResource.NAVIGATION_SUBSCRIPTIONS}
13+
>
14+
<WfoSubscriptionsListPage />
15+
</WfoPolicyRenderPageFallback>
16+
);
717
}

pages/tasks/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import React from 'react';
22

3-
import { WfoTasksListPage } from '@orchestrator-ui/orchestrator-ui-components';
3+
import {
4+
PolicyResource,
5+
WfoPolicyRenderPageFallback,
6+
WfoTasksListPage,
7+
} from '@orchestrator-ui/orchestrator-ui-components';
48

59
export function TasksPage() {
6-
return <WfoTasksListPage />;
10+
return (
11+
<WfoPolicyRenderPageFallback resource={PolicyResource.NAVIGATION_TASKS}>
12+
<WfoTasksListPage />
13+
</WfoPolicyRenderPageFallback>
14+
);
715
}
816

917
export default TasksPage;

pages/workflows/index.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
import React from 'react';
22

3-
import { WfoWorkflowsListPage } from '@orchestrator-ui/orchestrator-ui-components';
3+
import {
4+
PolicyResource,
5+
WfoPolicyRenderPageFallback,
6+
WfoWorkflowsListPage,
7+
} from '@orchestrator-ui/orchestrator-ui-components';
48

59
export default function WorkflowsPage() {
6-
return <WfoWorkflowsListPage />;
10+
return (
11+
<WfoPolicyRenderPageFallback
12+
resource={PolicyResource.NAVIGATION_WORKFLOWS}
13+
>
14+
<WfoWorkflowsListPage />
15+
</WfoPolicyRenderPageFallback>
16+
);
717
}

tsconfig.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
"compilerOptions": {
44
"baseUrl": ".",
55
"paths": {
6-
"@/*": ["./*"],
6+
"@/*": ["./*"]
77
},
88
"plugins": [
99
{
10-
"name": "next",
11-
},
10+
"name": "next"
11+
}
1212
],
1313
"strictNullChecks": true,
14-
"jsx": "preserve",
14+
"jsx": "preserve"
1515
},
1616
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
17-
"exclude": ["node_modules"],
17+
"exclude": ["node_modules"]
1818
}

0 commit comments

Comments
 (0)