mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-07 18:07:47 +08:00
feat(security): harden gateway boundaries and usage policies
Consolidate subscription usage policy enforcement, privacy-safe persistence, and gateway security hardening into one reviewable change. Includes bounded HTTP and execution envelopes, header and protocol guards, DNS and relay validation, authentication and secret projection hardening, secure backup/install paths, and regression coverage.
This commit is contained in:
@@ -38,6 +38,16 @@ async function createAbortedNavigationFailure(path: string) {
|
||||
}
|
||||
|
||||
describe('navigateAfterLogin', () => {
|
||||
it('never passes a cross-origin target to router or document navigation', async () => {
|
||||
const push = vi.fn<Router['push']>().mockResolvedValue(undefined)
|
||||
const documentNavigate = vi.fn()
|
||||
|
||||
await navigateAfterLogin(createRouterMock(push), '//attacker.example/steal', documentNavigate)
|
||||
|
||||
expect(push).toHaveBeenCalledWith('/')
|
||||
expect(documentNavigate).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('treats duplicated Vue Router navigation as a completed login navigation', async () => {
|
||||
const push = vi.fn<Router['push']>().mockResolvedValue(await createDuplicatedNavigationFailure('/dashboard'))
|
||||
const documentNavigate = vi.fn()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { isNavigationFailure, NavigationFailureType, type Router } from 'vue-router'
|
||||
import { safeInternalNavigationPath } from '@/utils/navigationSecurity'
|
||||
|
||||
export type LoginNavigationResult = 'router' | 'already-there' | 'document'
|
||||
|
||||
@@ -13,21 +14,22 @@ export async function navigateAfterLogin(
|
||||
targetPath: string,
|
||||
documentNavigate: DocumentNavigate = defaultDocumentNavigate,
|
||||
): Promise<LoginNavigationResult> {
|
||||
const safeTargetPath = safeInternalNavigationPath(targetPath) ?? '/'
|
||||
try {
|
||||
const navigationFailure = await router.push(targetPath)
|
||||
const navigationFailure = await router.push(safeTargetPath)
|
||||
|
||||
if (isNavigationFailure(navigationFailure, NavigationFailureType.duplicated)) {
|
||||
return 'already-there'
|
||||
}
|
||||
|
||||
if (navigationFailure) {
|
||||
documentNavigate(targetPath)
|
||||
documentNavigate(safeTargetPath)
|
||||
return 'document'
|
||||
}
|
||||
|
||||
return 'router'
|
||||
} catch {
|
||||
documentNavigate(targetPath)
|
||||
documentNavigate(safeTargetPath)
|
||||
return 'document'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user