mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-10 19:29:50 +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:
@@ -16,10 +16,11 @@ const router = createRouter({
|
||||
})
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
const authStore = useAuthStore()
|
||||
const moduleStore = useModuleStore()
|
||||
const requiresAuth = to.matched.some(record => record.meta.requiresAuth !== false)
|
||||
|
||||
try {
|
||||
const authStore = useAuthStore()
|
||||
const moduleStore = useModuleStore()
|
||||
const isAuthenticated = await ensureUserLoaded(authStore)
|
||||
|
||||
// 首页重定向
|
||||
@@ -27,7 +28,6 @@ router.beforeEach(async (to, from, next) => {
|
||||
if (homeRedirect !== null) return next(homeRedirect === '' ? undefined : homeRedirect)
|
||||
|
||||
// 需要认证但未认证
|
||||
const requiresAuth = to.matched.some(record => record.meta.requiresAuth !== false)
|
||||
if (requiresAuth && !isAuthenticated) {
|
||||
sessionStorage.setItem('redirectPath', to.fullPath)
|
||||
log.debug('No valid token found, redirecting to home')
|
||||
@@ -50,7 +50,10 @@ router.beforeEach(async (to, from, next) => {
|
||||
next()
|
||||
} catch (error) {
|
||||
log.error('Router guard error', error)
|
||||
// 发生错误时,直接放行,不要乱跳转
|
||||
if (requiresAuth) {
|
||||
sessionStorage.setItem('redirectPath', to.fullPath)
|
||||
return next('/')
|
||||
}
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user