feat: oidc based authentication

This commit is contained in:
Aarnav Tale
2024-03-25 17:51:11 -04:00
parent 025cc4f6f1
commit 58992efa2e
10 changed files with 494 additions and 62 deletions
+40
View File
@@ -0,0 +1,40 @@
import { CpuChipIcon, ServerStackIcon } from '@heroicons/react/24/outline'
import { type LoaderFunctionArgs, redirect } from '@remix-run/node'
import { Outlet } from '@remix-run/react'
import TabLink from '~/components/TabLink'
import { getSession } from '~/utils/sessions'
export async function loader({ request }: LoaderFunctionArgs) {
const session = await getSession(request.headers.get('Cookie'))
if (!session.has('hsApiKey')) {
return redirect('/login')
}
// eslint-disable-next-line unicorn/no-null
return null
}
export default function Layout() {
return (
<>
<header className='bg-gray-800 text-white mb-16'>
<nav className='container mx-auto'>
<div className='flex items-center gap-x-2 mb-8 pt-4'>
<CpuChipIcon className='w-8 h-8'/>
<h1 className='text-2xl'>Headplane</h1>
</div>
<div className='flex items-center gap-x-4'>
<TabLink to='/machines' name='Machines' icon={<ServerStackIcon className='w-4 h-4'/>}/>
</div>
</nav>
</header>
<main className='container mx-auto overscroll-contain'>
<Outlet/>
</main>
</>
)
}