Files
familienarchiv/docs/architecture/c4/l3-frontend-3a-middleware-auth.puml

2.4 KiB

Component Diagram: Web Frontend — Middleware, Auth & LayoutComponent Diagram: Web Frontend — Middleware, Auth & LayoutWeb Frontend (SvelteKit / SSR)[system]«component»hooks.server.ts[SvelteKit Server Hook] Four handle layers: (1)handleAuth â€” redirectsunauthenticated users to/login; (2) userGroup â€”reads auth_token cookie,fetches /api/users/me,stores user in event.locals;(3) handleFetch â€” injectsAuthorization header on alloutgoing /api/ calls; (4)handleLocaleDetection â€”sets language cookie fromAccept-Language header.«component»hooks.ts (Paraglide)[SvelteKit Client Hook] Client-side i18nmiddleware. Detectslanguage from URL and setsthe active locale forParaglide.js translationfunctions.«component»+layout.server.ts[SvelteKit Layout Loader] Passes event.locals.userdown to all child pages soevery route has access tothe authenticated user.«component»/login[SvelteKit Route] Form action: encodesemail:password as Base64Basic Auth token, POSTs to/api/users/me to validate,sets auth_token httpOnlycookie (SameSite=strict,maxAge=86400), redirectsto /.«component»/logout[SvelteKit Route (server-only)] Clears the auth_tokencookie and redirects to/login.«component»/register[SvelteKit Route] Loader validates invite codevia GET/api/auth/invite/{code}.Form action: POST/api/auth/register to createthe user account.«component»/forgot-password[SvelteKit Route] Form action: POST/api/auth/forgot-password.Always responds withsuccess to prevent emailenumeration.«component»/reset-password[SvelteKit Route] Form action: POST/api/auth/reset-passwordwith the token from thequery string.«person»User«container»API Backend[Spring Boot]Every browserrequest[HTTPS]GET /api/users/me(session check)[HTTP / Basic Auth]Redirect if no tokenStores authenticateduser in event.localsPOST /api/users/me(auth check)[HTTP / Basic Auth]GET/api/auth/invite/{code},POST/api/auth/register[HTTP / JSON]POST/api/auth/forgot-password[HTTP / JSON]POST/api/auth/reset-password[HTTP / JSON]