24 lines
692 B
JavaScript
24 lines
692 B
JavaScript
/** Paths that skip auth (no session required). Do not add if any handler uses requireAuth. */
|
|
export const SKIP_PATHS = Object.freeze([
|
|
'/api/auth/login',
|
|
'/api/auth/logout',
|
|
'/api/auth/config',
|
|
'/api/auth/oidc/authorize',
|
|
'/api/auth/oidc/callback',
|
|
])
|
|
|
|
/** Path prefixes for protected routes. Used by tests to ensure they're never in SKIP_PATHS. */
|
|
export const PROTECTED_PATH_PREFIXES = Object.freeze([
|
|
'/api/cameras',
|
|
'/api/devices',
|
|
'/api/live',
|
|
'/api/me',
|
|
'/api/pois',
|
|
'/api/users',
|
|
])
|
|
|
|
export function skipAuth(path) {
|
|
if (path.startsWith('/api/health') || path === '/health') return true
|
|
return SKIP_PATHS.some(p => path === p || path.startsWith(p + '/'))
|
|
}
|