Compare commits
1 commit
develop
...
feat/oidc-
Author | SHA1 | Date | |
---|---|---|---|
|
1788c9c848 |
5 changed files with 2544 additions and 15 deletions
|
@ -57,6 +57,7 @@
|
|||
"next-client-cookies": "^1.0.6",
|
||||
"next-intl": "^2.22.1",
|
||||
"next-safe-action": "^5.0.2",
|
||||
"oidc-provider": "^8.4.1",
|
||||
"pg": "^8.11.3",
|
||||
"qrcode.react": "^3.1.0",
|
||||
"react": "18.2.0",
|
||||
|
@ -96,6 +97,7 @@
|
|||
"@types/jest": "^29.5.7",
|
||||
"@types/lodash.merge": "^4.6.8",
|
||||
"@types/node": "20.8.10",
|
||||
"@types/oidc-provider": "^8.4.1",
|
||||
"@types/pg": "^8.10.7",
|
||||
"@types/react": "18.2.34",
|
||||
"@types/react-dom": "18.2.14",
|
||||
|
|
2516
pnpm-lock.yaml
2516
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
'use client';
|
||||
|
||||
import { IconCircuitResistor, IconCpu, IconDatabase } from '@tabler/icons-react';
|
||||
import React from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { SystemStat } from '../SystemStat';
|
||||
|
||||
|
@ -18,6 +18,15 @@ export const DashboardContainer: React.FC<IProps> = (props) => {
|
|||
const { diskUsed, diskSize, percentUsed, cpuLoad, memoryTotal, percentUsedMemory } = props;
|
||||
const t = useTranslations('dashboard');
|
||||
|
||||
useEffect(() => {
|
||||
const authorize = async () => {
|
||||
const res = await fetch('/api/auth/authorize');
|
||||
console.log(res);
|
||||
};
|
||||
|
||||
authorize();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="row row-deck row-cards">
|
||||
<SystemStat title={t('cards.disk.title')} metric={`${diskUsed} GB`} subtitle={t('cards.disk.subtitle', { total: diskSize })} icon={IconDatabase} progress={percentUsed} />
|
||||
|
|
14
src/app/api/auth/authorize/route.ts
Normal file
14
src/app/api/auth/authorize/route.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { oidc } from '@/lib/oidc/provider';
|
||||
import { getUserFromCookie } from '@/server/common/session.helpers';
|
||||
|
||||
export async function GET(req: Request, res: Response) {
|
||||
const user = await getUserFromCookie();
|
||||
|
||||
const res = await oidc.interactionResult(req, res, {
|
||||
login: { account: user?.id },
|
||||
});
|
||||
|
||||
console.log(res);
|
||||
|
||||
return new Response('OK', { status: 200 });
|
||||
}
|
16
src/lib/oidc/provider.ts
Normal file
16
src/lib/oidc/provider.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import Provider from 'oidc-provider';
|
||||
|
||||
const configuration = {
|
||||
// Define your OIDC provider configuration here.
|
||||
clients: [
|
||||
{
|
||||
client_id: 'dashboard-client',
|
||||
client_secret: 'your-secret',
|
||||
grant_types: ['refresh_token', 'authorization_code'],
|
||||
redirect_uris: ['https://your-redirect-uri/callback'],
|
||||
},
|
||||
],
|
||||
// ...other configuration settings
|
||||
};
|
||||
|
||||
export const oidc = new Provider('http://localhost:3000', configuration);
|
Loading…
Reference in a new issue