refactor(auth): replace dashboard sessions with stateless tokens and session control (#6329)

* refactor(auth): replace dashboard sessions with stateless tokens

* feat(auth): harden session issuance and distributed enforcement

* fix(proxy): preserve trusted proxy compatibility defaults

* refactor: address dashboard auth review feedback

* refactor: remove classic frontend and flatten web app
This commit is contained in:
Calcium-Ion
2026-07-20 16:48:43 +08:00
committed by GitHub
parent 5a6c53d496
commit 31d70fca39
1605 changed files with 17511 additions and 147913 deletions
+48
View File
@@ -0,0 +1,48 @@
/*
Copyright (C) 2023-2026 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useNavigate, useRouter } from '@tanstack/react-router'
import { useTranslation } from 'react-i18next'
import { Button } from '@/components/ui/button'
export function ForbiddenError() {
const { t } = useTranslation()
const navigate = useNavigate()
const { history } = useRouter()
return (
<div className='h-svh'>
<div className='m-auto flex h-full w-full flex-col items-center justify-center gap-2'>
<h1 className='text-[7rem] leading-tight font-bold'>403</h1>
<span className='font-medium'>{t('Access Forbidden')}</span>
<p className='text-muted-foreground text-center'>
{t("You don't have necessary permission")} <br />
{t('to view this resource.')}
</p>
<div className='mt-6 flex gap-4'>
<Button variant='outline' onClick={() => history.go(-1)}>
{t('Go Back')}
</Button>
<Button onClick={() => navigate({ to: '/' })}>
{t('Back to Home')}
</Button>
</div>
</div>
</div>
)
}
+99
View File
@@ -0,0 +1,99 @@
/*
Copyright (C) 2023-2026 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useNavigate, useRouter } from '@tanstack/react-router'
import { useTranslation } from 'react-i18next'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
const FEEDBACK_URL = 'https://github.com/QuantumNous/new-api/issues'
type GeneralErrorProps = React.HTMLAttributes<HTMLDivElement> & {
minimal?: boolean
error?: unknown
}
function getHttpStatus(error: unknown): number | undefined {
if (typeof error !== 'object' || error === null) return undefined
const response = (error as Record<string, unknown>).response
if (typeof response !== 'object' || response === null) return undefined
const status = (response as Record<string, unknown>).status
return typeof status === 'number' ? status : undefined
}
export function GeneralError({
className,
minimal = false,
error,
}: GeneralErrorProps) {
const { t } = useTranslation()
const navigate = useNavigate()
const { history } = useRouter()
const status = getHttpStatus(error)
const isRateLimited = status === 429
const title = isRateLimited
? t('Too many requests')
: `${t('Oops! Something went wrong')} ${`:')`}`
const description = isRateLimited
? t('Please wait a moment before trying again.')
: t('Please try again later.')
return (
<div className={cn('h-svh w-full', className)}>
<div className='m-auto flex h-full w-full flex-col items-center justify-center gap-2'>
{!minimal && (
<h1 className='text-[7rem] leading-tight font-bold'>
{status ?? 500}
</h1>
)}
<span className='font-medium'>{title}</span>
<p className='text-muted-foreground text-center'>
{t('We apologize for the inconvenience.')} <br /> {description}
</p>
{!minimal && (
<p className='text-muted-foreground text-center text-sm'>
{t('If this keeps happening, please report it on GitHub Issues.')}
</p>
)}
{!minimal && (
<div className='mt-6 flex flex-wrap justify-center gap-4'>
<Button variant='outline' onClick={() => history.go(-1)}>
{t('Go Back')}
</Button>
<Button
variant='outline'
render={
<a
href={FEEDBACK_URL}
target='_blank'
rel='noopener noreferrer'
/>
}
>
{t('Report an issue')}
</Button>
<Button onClick={() => navigate({ to: '/' })}>
{t('Back to Home')}
</Button>
</div>
)}
</div>
</div>
)
}
+42
View File
@@ -0,0 +1,42 @@
/*
Copyright (C) 2023-2026 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useTranslation } from 'react-i18next'
import { Button } from '@/components/ui/button'
export function MaintenanceError() {
const { t } = useTranslation()
return (
<div className='h-svh'>
<div className='m-auto flex h-full w-full flex-col items-center justify-center gap-2'>
<h1 className='text-[7rem] leading-tight font-bold'>503</h1>
<span className='font-medium'>
{t('Website is under maintenance!')}
</span>
<p className='text-muted-foreground text-center'>
{t('The site is not available at the moment.')} <br />
{t("We'll be back online shortly.")}
</p>
<div className='mt-6 flex gap-4'>
<Button variant='outline'>{t('Learn more')}</Button>
</div>
</div>
</div>
)
}
+48
View File
@@ -0,0 +1,48 @@
/*
Copyright (C) 2023-2026 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useNavigate, useRouter } from '@tanstack/react-router'
import { useTranslation } from 'react-i18next'
import { Button } from '@/components/ui/button'
export function NotFoundError() {
const { t } = useTranslation()
const navigate = useNavigate()
const { history } = useRouter()
return (
<div className='h-svh'>
<div className='m-auto flex h-full w-full flex-col items-center justify-center gap-2'>
<h1 className='text-[7rem] leading-tight font-bold'>404</h1>
<span className='font-medium'>{t('Oops! Page Not Found!')}</span>
<p className='text-muted-foreground text-center'>
{t("It seems like the page you're looking for")} <br />
{t('does not exist or might have been removed.')}
</p>
<div className='mt-6 flex gap-4'>
<Button variant='outline' onClick={() => history.go(-1)}>
{t('Go Back')}
</Button>
<Button onClick={() => navigate({ to: '/' })}>
{t('Back to Home')}
</Button>
</div>
</div>
</div>
)
}
+48
View File
@@ -0,0 +1,48 @@
/*
Copyright (C) 2023-2026 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useNavigate, useRouter } from '@tanstack/react-router'
import { useTranslation } from 'react-i18next'
import { Button } from '@/components/ui/button'
export function UnauthorisedError() {
const { t } = useTranslation()
const navigate = useNavigate()
const { history } = useRouter()
return (
<div className='h-svh'>
<div className='m-auto flex h-full w-full flex-col items-center justify-center gap-2'>
<h1 className='text-[7rem] leading-tight font-bold'>401</h1>
<span className='font-medium'>{t('Unauthorized Access')}</span>
<p className='text-muted-foreground text-center'>
{t('Please log in with the appropriate credentials')} <br />{' '}
{t('to access this resource.')}
</p>
<div className='mt-6 flex gap-4'>
<Button variant='outline' onClick={() => history.go(-1)}>
{t('Go Back')}
</Button>
<Button onClick={() => navigate({ to: '/' })}>
{t('Back to Home')}
</Button>
</div>
</div>
</div>
)
}