diff --git a/dashboard/src/app/(inside)/page.tsx b/dashboard/src/app/(inside)/page.tsx
index 604a7e2..778d24a 100644
--- a/dashboard/src/app/(inside)/page.tsx
+++ b/dashboard/src/app/(inside)/page.tsx
@@ -1,40 +1,20 @@
-import { getHydraMetadataApi, getKetoMetadataApi, getKratosMetadataApi } from '@/ory/sdk/server';
-import { MetadataApiReady, StatusCard } from '@/components/status-card';
+import { StatusCard } from '@/components/status-card';
+import { hydraMetadata, ketoMetadata, kratosMetadata } from '@/lib/action/metadata';
+import { checkPermission, requireRole, requireSession } from '@/lib/action/authentication';
+import InsufficientPermission from '@/components/insufficient-permission';
export default async function RootPage() {
- const kratosMetadataApi = await getKratosMetadataApi();
- const kratosVersion = await kratosMetadataApi.getVersion()
- .then(res => res.data.version)
- .catch(() => undefined);
- const kratosStatus = await fetch(process.env.ORY_KRATOS_ADMIN_URL + '/health/ready')
- .then((response) => response.json() as MetadataApiReady)
- .catch(() => {
- return { errors: ['No instance running'] } as MetadataApiReady;
- });
+ const session = await requireSession();
+ const identityId = session.identity!.id;
+ await requireRole('admin', identityId);
- const hydraMetadataApi = await getHydraMetadataApi();
- const hydraVersion = await hydraMetadataApi.getVersion()
- .then(res => res.data.version)
- .catch(() => undefined);
- const hydraStatus = await fetch(process.env.ORY_HYDRA_ADMIN_URL + '/health/ready')
- .then((response) => response.json() as MetadataApiReady)
- .catch(() => {
- return { errors: ['No instance running'] } as MetadataApiReady;
- });
-
-
- const ketoMetadataApi = await getKetoMetadataApi();
- const ketoVersion = await ketoMetadataApi.getVersion()
- .then(res => res.data.version)
- .catch(() => undefined);
- const ketoStatus = await fetch(process.env.ORY_KETO_ADMIN_URL + '/health/ready')
- .then((response) => response.json() as MetadataApiReady)
- .catch(() => {
- return { errors: ['No instance running'] } as MetadataApiReady;
- });
+ const pmAccessStackStatus = await checkPermission('admin.stack.status', 'access', identityId);
+ const kratos = pmAccessStackStatus && await kratosMetadata();
+ const hydra = pmAccessStackStatus && await hydraMetadata();
+ const keto = pmAccessStackStatus && await ketoMetadata();
return (
@@ -43,25 +23,46 @@ export default async function RootPage() {
See the list of all applications in your stack
-
-
-
-
+ {
+ !pmAccessStackStatus && (
+
+ )
+ }
+ {
+ kratos && (
+
+ )
+ }
+ {
+ hydra && (
+
+ )
+ }
+ {
+ keto && (
+
+ )
+ }
);
diff --git a/dashboard/src/components/status-card.tsx b/dashboard/src/components/status-card.tsx
index d6d4038..e12bf53 100644
--- a/dashboard/src/components/status-card.tsx
+++ b/dashboard/src/components/status-card.tsx
@@ -50,7 +50,7 @@ export function StatusCard({ title, version, name, status, className }: StatusCa
{
- status.errors.map((error) => {error})
+ status.errors.map((error) => {error})
}
diff --git a/dashboard/src/lib/action/metadata.ts b/dashboard/src/lib/action/metadata.ts
new file mode 100644
index 0000000..03d5768
--- /dev/null
+++ b/dashboard/src/lib/action/metadata.ts
@@ -0,0 +1,83 @@
+'use server';
+
+import { getHydraMetadataApi, getKetoMetadataApi, getKratosMetadataApi } from '@/ory/sdk/server';
+import { MetadataApiReady } from '@/components/status-card';
+import { checkPermission, requireSession } from '@/lib/action/authentication';
+
+export async function kratosMetadata() {
+
+ const session = await requireSession();
+ const allowed = await checkPermission('admin.stack.status', 'access', session.identity!.id);
+ if (!allowed) {
+ return;
+ }
+
+ const api = await getKratosMetadataApi();
+
+ const version = await api.getVersion()
+ .then(res => res.data.version)
+ .catch(() => undefined);
+
+ const status = await fetch(process.env.ORY_KRATOS_ADMIN_URL + '/health/ready')
+ .then((response) => response.json() as MetadataApiReady)
+ .catch(() => {
+ return { errors: ['No instance running'] } as MetadataApiReady;
+ });
+
+ return {
+ version,
+ status,
+ };
+}
+
+export async function hydraMetadata() {
+
+ const session = await requireSession();
+ const allowed = await checkPermission('admin.stack.status', 'access', session.identity!.id);
+ if (!allowed) {
+ return;
+ }
+
+ const api = await getHydraMetadataApi();
+
+ const version = await api.getVersion()
+ .then(res => res.data.version)
+ .catch(() => undefined);
+
+ const status = await fetch(process.env.ORY_HYDRA_ADMIN_URL + '/health/ready')
+ .then((response) => response.json() as MetadataApiReady)
+ .catch(() => {
+ return { errors: ['No instance running'] } as MetadataApiReady;
+ });
+
+ return {
+ version,
+ status,
+ };
+}
+
+export async function ketoMetadata() {
+
+ const session = await requireSession();
+ const allowed = await checkPermission('admin.stack.status', 'access', session.identity!.id);
+ if (!allowed) {
+ return;
+ }
+
+ const api = await getKetoMetadataApi();
+
+ const version = await api.getVersion()
+ .then(res => res.data.version)
+ .catch(() => undefined);
+
+ const status = await fetch(process.env.ORY_KETO_ADMIN_URL + '/health/ready')
+ .then((response) => response.json() as MetadataApiReady)
+ .catch(() => {
+ return { errors: ['No instance running'] } as MetadataApiReady;
+ });
+
+ return {
+ version,
+ status,
+ };
+}