-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f676228
commit 2aea532
Showing
54 changed files
with
2,355 additions
and
2,627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export const LIB_VERSION = "1.1.0";export const LIB_LICENSE = undefined; | ||
export const LIB_VERSION = '1.1.0'; | ||
export const LIB_LICENSE = undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { Box, Title } from "@mantine/core"; | ||
import { Box, Title } from '@mantine/core'; | ||
|
||
export default async function Page() { | ||
return ( | ||
<Box ml="md" maw="50vw"> | ||
<Title order={1} mt="xl" mb="md"> | ||
SSO Configuration and Security | ||
</Title> | ||
</Box> | ||
); | ||
return ( | ||
<Box ml="md" maw="50vw"> | ||
<Title order={1} mt="xl" mb="md"> | ||
SSO Configuration and Security | ||
</Title> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,160 +1,148 @@ | ||
import { | ||
Badge, | ||
Box, | ||
Button, | ||
Card, | ||
Code, | ||
NumberFormatter, | ||
SimpleGrid, | ||
Stack, | ||
Table, | ||
TableTbody, | ||
TableTd, | ||
TableTh, | ||
TableThead, | ||
TableTr, | ||
Tabs, | ||
TabsList, | ||
TabsPanel, | ||
TabsTab, | ||
Text, | ||
Title, | ||
} from "@mantine/core"; | ||
Badge, | ||
Box, | ||
Card, | ||
Code, | ||
NumberFormatter, | ||
SimpleGrid, | ||
Stack, | ||
Table, | ||
TableTbody, | ||
TableTd, | ||
TableTh, | ||
TableThead, | ||
TableTr, | ||
Tabs, | ||
TabsList, | ||
TabsPanel, | ||
TabsTab, | ||
Text, | ||
Title, | ||
} from '@mantine/core'; | ||
|
||
import Anchor from "@/components/core/Anchor"; | ||
import { getSession } from "@/util/auth"; | ||
import { globalFetcher } from "@/util/data"; | ||
import Anchor from '@/components/core/Anchor'; | ||
import { getSession } from '@/util/auth'; | ||
import { globalFetcher } from '@/util/data'; | ||
|
||
export default async function Page() { | ||
const session = await getSession(); | ||
const realm = (await globalFetcher<[any]>( | ||
`${process.env.NEXT_PUBLIC_KEYCLOAK_URL?.replace( | ||
"/realms/website", | ||
"" | ||
)}/admin/realms`, | ||
{ headers: { Authorization: `Bearer ${session?.accessToken}` } } | ||
))[0]; | ||
const adminEvents = await globalFetcher<any[]>( | ||
`${process.env.NEXT_PUBLIC_KEYCLOAK_URL?.replace( | ||
"/realms/website", | ||
"" | ||
)}/admin/realms/website/admin-events`, | ||
{ headers: { Authorization: `Bearer ${session?.accessToken}` } } | ||
); | ||
const userEvents = await globalFetcher<any[]>( | ||
`${process.env.NEXT_PUBLIC_KEYCLOAK_URL?.replace( | ||
"/realms/website", | ||
"" | ||
)}/admin/realms/website/events`, | ||
{ headers: { Authorization: `Bearer ${session?.accessToken}` } } | ||
); | ||
const clientStats = await globalFetcher<any[]>( | ||
`${process.env.NEXT_PUBLIC_KEYCLOAK_URL?.replace( | ||
"/realms/website", | ||
"" | ||
)}/admin/realms/website/client-session-stats`, | ||
{ headers: { Authorization: `Bearer ${session?.accessToken}` } }); | ||
const session = await getSession(); | ||
const realm = ( | ||
await globalFetcher<[any]>(`${process.env.NEXT_PUBLIC_KEYCLOAK_URL?.replace('/realms/website', '')}/admin/realms`, { | ||
headers: { Authorization: `Bearer ${session?.accessToken}` }, | ||
}) | ||
)[0]; | ||
const adminEvents = await globalFetcher<any[]>( | ||
`${process.env.NEXT_PUBLIC_KEYCLOAK_URL?.replace('/realms/website', '')}/admin/realms/website/admin-events`, | ||
{ headers: { Authorization: `Bearer ${session?.accessToken}` } }, | ||
); | ||
const userEvents = await globalFetcher<any[]>( | ||
`${process.env.NEXT_PUBLIC_KEYCLOAK_URL?.replace('/realms/website', '')}/admin/realms/website/events`, | ||
{ headers: { Authorization: `Bearer ${session?.accessToken}` } }, | ||
); | ||
const clientStats = await globalFetcher<any[]>( | ||
`${process.env.NEXT_PUBLIC_KEYCLOAK_URL?.replace('/realms/website', '')}/admin/realms/website/client-session-stats`, | ||
{ headers: { Authorization: `Bearer ${session?.accessToken}` } }, | ||
); | ||
|
||
return ( | ||
<Box ml="md" maw="90vw"> | ||
<Title order={1} mt="xl" mb="md"> | ||
SSO Configuration and Security | ||
</Title> | ||
<Tabs defaultValue="realm"> | ||
<TabsList> | ||
<TabsTab value="realm">Realm Info</TabsTab> | ||
<TabsTab value="adminEvents">Admin Events</TabsTab> | ||
<TabsTab value="userEvents">User Events</TabsTab> | ||
<TabsTab value="sessionStats">Session Stats</TabsTab> | ||
</TabsList> | ||
return ( | ||
<Box ml="md" maw="90vw"> | ||
<Title order={1} mt="xl" mb="md"> | ||
SSO Configuration and Security | ||
</Title> | ||
<Tabs defaultValue="realm"> | ||
<TabsList> | ||
<TabsTab value="realm">Realm Info</TabsTab> | ||
<TabsTab value="adminEvents">Admin Events</TabsTab> | ||
<TabsTab value="userEvents">User Events</TabsTab> | ||
<TabsTab value="sessionStats">Session Stats</TabsTab> | ||
</TabsList> | ||
|
||
<TabsPanel value="realm"> | ||
<Stack mt="md"> | ||
{Object.keys(realm) | ||
.map((key) => ( | ||
<Card key={key}> | ||
<Text> | ||
<b>{key}:</b> {typeof realm[key] === "number" ? (<NumberFormatter thousandSeparator value={realm[key]} />) : typeof realm[key] == "string"? realm[key]: <Code>{JSON.stringify(realm[key])}</Code>} | ||
</Text> | ||
</Card> | ||
))} | ||
</Stack> | ||
</TabsPanel> | ||
<TabsPanel value="adminEvents"> | ||
<Table mt="md"> | ||
<TableThead> | ||
<TableTr> | ||
<TableTh>Time</TableTh> | ||
<TableTh>Operation</TableTh> | ||
<TableTh>Resource Type</TableTh> | ||
<TableTh>Resource</TableTh> | ||
</TableTr> | ||
</TableThead> | ||
<TableTbody> | ||
{adminEvents?.map((event) => ( | ||
<TableTr key={event.time}> | ||
<TableTd>{new Date(event.time).toUTCString()}</TableTd> | ||
<TableTd>{event.operationType}</TableTd> | ||
<TableTd> | ||
<Badge variant="gradient">{event.resourceType}</Badge> | ||
</TableTd> | ||
<TableTd> | ||
<Anchor | ||
href={`/am/${event.resourcePath | ||
.split("/") | ||
.slice(0, 2) | ||
.join("/")}`} | ||
> | ||
{event.resourcePath} | ||
</Anchor> | ||
</TableTd> | ||
</TableTr> | ||
))} | ||
</TableTbody> | ||
</Table> | ||
</TabsPanel> | ||
<TabsPanel value="userEvents"> | ||
<Table mt="md"> | ||
<TableThead> | ||
<TableTr> | ||
<TableTh>Time</TableTh> | ||
<TableTh>Operation</TableTh> | ||
<TableTh>Client</TableTh> | ||
<TableTh>User</TableTh> | ||
</TableTr> | ||
</TableThead> | ||
<TableTbody> | ||
{userEvents?.map((event) => ( | ||
<TableTr key={event.time}> | ||
<TableTd>{new Date(event.time).toUTCString()}</TableTd> | ||
<TableTd>{event.type}</TableTd> | ||
<TableTd> | ||
<Badge variant="gradient">{event.clientId}</Badge> | ||
</TableTd> | ||
<TableTd>{event.userId}</TableTd> | ||
</TableTr> | ||
))} | ||
</TableTbody> | ||
</Table> | ||
</TabsPanel> | ||
<TabsPanel value="sessionStats"> | ||
<SimpleGrid cols={{ md: 2, sm: 1 }} mt="md"> | ||
{clientStats?.map((client) => ( | ||
<Card key={client.id}> | ||
<Title order={4}>{client.clientId}</Title> | ||
<Text> | ||
<b>Active: </b>{" "} | ||
<NumberFormatter thousandSeparator value={client.active} /> | ||
</Text> | ||
<Text> | ||
<b>Offline: </b>{" "} | ||
<NumberFormatter thousandSeparator value={client.offline} /> | ||
</Text> | ||
</Card> | ||
))} | ||
</SimpleGrid> | ||
</TabsPanel> | ||
</Tabs> | ||
</Box> | ||
); | ||
<TabsPanel value="realm"> | ||
<Stack mt="md"> | ||
{Object.keys(realm).map((key) => ( | ||
<Card key={key}> | ||
<Text> | ||
<b>{key}:</b>{' '} | ||
{typeof realm[key] === 'number' ? ( | ||
<NumberFormatter thousandSeparator value={realm[key]} /> | ||
) : typeof realm[key] == 'string' ? ( | ||
realm[key] | ||
) : ( | ||
<Code>{JSON.stringify(realm[key])}</Code> | ||
)} | ||
</Text> | ||
</Card> | ||
))} | ||
</Stack> | ||
</TabsPanel> | ||
<TabsPanel value="adminEvents"> | ||
<Table mt="md"> | ||
<TableThead> | ||
<TableTr> | ||
<TableTh>Time</TableTh> | ||
<TableTh>Operation</TableTh> | ||
<TableTh>Resource Type</TableTh> | ||
<TableTh>Resource</TableTh> | ||
</TableTr> | ||
</TableThead> | ||
<TableTbody> | ||
{adminEvents?.map((event) => ( | ||
<TableTr key={event.time}> | ||
<TableTd>{new Date(event.time).toUTCString()}</TableTd> | ||
<TableTd>{event.operationType}</TableTd> | ||
<TableTd> | ||
<Badge variant="gradient">{event.resourceType}</Badge> | ||
</TableTd> | ||
<TableTd> | ||
<Anchor href={`/am/${event.resourcePath.split('/').slice(0, 2).join('/')}`}> | ||
{event.resourcePath} | ||
</Anchor> | ||
</TableTd> | ||
</TableTr> | ||
))} | ||
</TableTbody> | ||
</Table> | ||
</TabsPanel> | ||
<TabsPanel value="userEvents"> | ||
<Table mt="md"> | ||
<TableThead> | ||
<TableTr> | ||
<TableTh>Time</TableTh> | ||
<TableTh>Operation</TableTh> | ||
<TableTh>Client</TableTh> | ||
<TableTh>User</TableTh> | ||
</TableTr> | ||
</TableThead> | ||
<TableTbody> | ||
{userEvents?.map((event) => ( | ||
<TableTr key={event.time}> | ||
<TableTd>{new Date(event.time).toUTCString()}</TableTd> | ||
<TableTd>{event.type}</TableTd> | ||
<TableTd> | ||
<Badge variant="gradient">{event.clientId}</Badge> | ||
</TableTd> | ||
<TableTd>{event.userId}</TableTd> | ||
</TableTr> | ||
))} | ||
</TableTbody> | ||
</Table> | ||
</TabsPanel> | ||
<TabsPanel value="sessionStats"> | ||
<SimpleGrid cols={{ md: 2, sm: 1 }} mt="md"> | ||
{clientStats?.map((client) => ( | ||
<Card key={client.id}> | ||
<Title order={4}>{client.clientId}</Title> | ||
<Text> | ||
<b>Active: </b> <NumberFormatter thousandSeparator value={client.active} /> | ||
</Text> | ||
<Text> | ||
<b>Offline: </b> <NumberFormatter thousandSeparator value={client.offline} /> | ||
</Text> | ||
</Card> | ||
))} | ||
</SimpleGrid> | ||
</TabsPanel> | ||
</Tabs> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import { authOptions } from "@/util/auth"; | ||
import NextAuth from "next-auth"; | ||
import { authOptions } from '@/util/auth'; | ||
import NextAuth from 'next-auth'; | ||
|
||
const handler = NextAuth(authOptions); | ||
|
||
export { handler as GET, handler as POST }; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
"use client" | ||
'use client'; | ||
|
||
import { signIn, useSession } from "next-auth/react"; | ||
import { signIn, useSession } from 'next-auth/react'; | ||
|
||
import { useRouter } from "next/navigation"; | ||
import { useEffect } from "react"; | ||
import { useRouter } from 'next/navigation'; | ||
import { useEffect } from 'react'; | ||
|
||
export default function SigninPage() { | ||
const router = useRouter(); | ||
const { status } = useSession(); | ||
const router = useRouter(); | ||
const { status } = useSession(); | ||
|
||
useEffect(() => { | ||
if (status === "unauthenticated") { | ||
console.log("No JWT"); | ||
console.log(status); | ||
void signIn("keycloak", { callbackUrl: "/",redirect:true }); | ||
} else if (status === "authenticated") { | ||
void router.push("/"); | ||
} | ||
}, [status,router]); | ||
useEffect(() => { | ||
if (status === 'unauthenticated') { | ||
console.log('No JWT'); | ||
console.log(status); | ||
void signIn('keycloak', { callbackUrl: '/', redirect: true }); | ||
} else if (status === 'authenticated') { | ||
void router.push('/'); | ||
} | ||
}, [status, router]); | ||
|
||
return <p>Redirecting...</p>; | ||
return <p>Redirecting...</p>; | ||
} |
Oops, something went wrong.