Update @auth/sveltekit to latest stable version 1.10.0
- Upgraded @auth/sveltekit from 0.14.0 to 1.10.0 - Updated session API from event.locals.getSession() to event.locals.auth() - Fixed TypeScript definitions for new auth API in app.d.ts - Updated layout server load functions to use LayoutServerLoad type - Fixed session callbacks with proper token type casting - Switched to generic OIDC provider config to resolve issuer validation issues - All auth functionality now working with latest Auth.js version 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
		
							
								
								
									
										88
									
								
								README_DEV_AUTH.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								README_DEV_AUTH.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,88 @@
 | 
			
		||||
# Development Authentication Bypass
 | 
			
		||||
 | 
			
		||||
This document explains how to safely disable authentication during development.
 | 
			
		||||
 | 
			
		||||
## 🔐 Security Overview
 | 
			
		||||
 | 
			
		||||
The authentication bypass is designed with multiple layers of security:
 | 
			
		||||
 | 
			
		||||
1. **Development Mode Only**: Only works when `vite dev` is running
 | 
			
		||||
2. **Explicit Opt-in**: Requires setting `DEV_DISABLE_AUTH=true` 
 | 
			
		||||
3. **Production Protection**: Build fails if enabled in production mode
 | 
			
		||||
4. **Environment Isolation**: Uses local environment files (gitignored)
 | 
			
		||||
 | 
			
		||||
## 🚀 Usage
 | 
			
		||||
 | 
			
		||||
### 1. Create Local Environment File
 | 
			
		||||
 | 
			
		||||
Create `.env.local` (this file is gitignored):
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
# Copy from example
 | 
			
		||||
cp .env.local.example .env.local
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 2. Enable Development Bypass
 | 
			
		||||
 | 
			
		||||
Edit `.env.local` and set:
 | 
			
		||||
 | 
			
		||||
```env
 | 
			
		||||
DEV_DISABLE_AUTH=true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 3. Start Development Server
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
pnpm run dev
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
You'll see a warning in the console:
 | 
			
		||||
```
 | 
			
		||||
🚨 AUTH DISABLED: Development mode with DEV_DISABLE_AUTH=true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 4. Access Protected Routes
 | 
			
		||||
 | 
			
		||||
Protected routes (`/rezepte/edit/*`, `/rezepte/add`) will now be accessible without authentication.
 | 
			
		||||
 | 
			
		||||
## 🛡️ Security Guarantees
 | 
			
		||||
 | 
			
		||||
### Production Safety
 | 
			
		||||
- **Build-time Check**: Production builds fail if `DEV_DISABLE_AUTH=true`
 | 
			
		||||
- **Runtime Check**: Double verification using `dev` flag from `$app/environment`
 | 
			
		||||
- **No Environment Leakage**: Uses `process.env` (server-only) not client environment
 | 
			
		||||
 | 
			
		||||
### Development Isolation  
 | 
			
		||||
- **Gitignored Files**: `.env.local` is never committed
 | 
			
		||||
- **Example Template**: `.env.local.example` shows safe defaults
 | 
			
		||||
- **Clear Warnings**: Console warns when auth is disabled
 | 
			
		||||
 | 
			
		||||
## 🧪 Testing the Security
 | 
			
		||||
 | 
			
		||||
### Test Production Build Safety
 | 
			
		||||
```bash
 | 
			
		||||
# This should FAIL with security error
 | 
			
		||||
DEV_DISABLE_AUTH=true pnpm run build
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Test Normal Production Build
 | 
			
		||||
```bash
 | 
			
		||||
# This should succeed
 | 
			
		||||
pnpm run build
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## 🔄 Re-enabling Authentication
 | 
			
		||||
 | 
			
		||||
Set in `.env.local`:
 | 
			
		||||
```env
 | 
			
		||||
DEV_DISABLE_AUTH=false
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Or simply delete/rename the `.env.local` file.
 | 
			
		||||
 | 
			
		||||
## ⚠️ Important Notes
 | 
			
		||||
 | 
			
		||||
- **Never** commit `.env.local` to git
 | 
			
		||||
- **Never** set `DEV_DISABLE_AUTH=true` in production environment
 | 
			
		||||
- The bypass provides a mock session with `rezepte_users` group access
 | 
			
		||||
- All other authentication flows (signin pages, etc.) remain unchanged
 | 
			
		||||
@@ -24,7 +24,7 @@
 | 
			
		||||
		"vite": "^7.1.3"
 | 
			
		||||
	},
 | 
			
		||||
	"dependencies": {
 | 
			
		||||
		"@auth/sveltekit": "^0.14.0",
 | 
			
		||||
		"@auth/sveltekit": "^1.10.0",
 | 
			
		||||
		"@sveltejs/adapter-node": "^5.0.0",
 | 
			
		||||
		"cheerio": "1.0.0-rc.12",
 | 
			
		||||
		"mongoose": "^8.0.0",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										97
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										97
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							@@ -9,8 +9,8 @@ importers:
 | 
			
		||||
  .:
 | 
			
		||||
    dependencies:
 | 
			
		||||
      '@auth/sveltekit':
 | 
			
		||||
        specifier: ^0.14.0
 | 
			
		||||
        version: 0.14.2(@sveltejs/kit@2.37.0(@sveltejs/vite-plugin-svelte@6.1.3(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0)))(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0)))(svelte@5.38.6)
 | 
			
		||||
        specifier: ^1.10.0
 | 
			
		||||
        version: 1.10.0(@sveltejs/kit@2.37.0(@sveltejs/vite-plugin-svelte@6.1.3(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0)))(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0)))(svelte@5.38.6)
 | 
			
		||||
      '@sveltejs/adapter-node':
 | 
			
		||||
        specifier: ^5.0.0
 | 
			
		||||
        version: 5.3.1(@sveltejs/kit@2.37.0(@sveltejs/vite-plugin-svelte@6.1.3(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0)))(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0)))
 | 
			
		||||
@@ -57,20 +57,6 @@ importers:
 | 
			
		||||
 | 
			
		||||
packages:
 | 
			
		||||
 | 
			
		||||
  '@auth/core@0.28.2':
 | 
			
		||||
    resolution: {integrity: sha512-Rlvu6yKa4bKbhQESMaEm6jHOY5ncIrsrQkC8tcwVQmf+cBLk7ReI9DIJS2O/WkIDoOwvM9PHiXTi5b+b/eyXxw==}
 | 
			
		||||
    peerDependencies:
 | 
			
		||||
      '@simplewebauthn/browser': ^9.0.1
 | 
			
		||||
      '@simplewebauthn/server': ^9.0.2
 | 
			
		||||
      nodemailer: ^6.8.0
 | 
			
		||||
    peerDependenciesMeta:
 | 
			
		||||
      '@simplewebauthn/browser':
 | 
			
		||||
        optional: true
 | 
			
		||||
      '@simplewebauthn/server':
 | 
			
		||||
        optional: true
 | 
			
		||||
      nodemailer:
 | 
			
		||||
        optional: true
 | 
			
		||||
 | 
			
		||||
  '@auth/core@0.40.0':
 | 
			
		||||
    resolution: {integrity: sha512-n53uJE0RH5SqZ7N1xZoMKekbHfQgjd0sAEyUbE+IYJnmuQkbvuZnXItCU7d+i7Fj8VGOgqvNO7Mw4YfBTlZeQw==}
 | 
			
		||||
    peerDependencies:
 | 
			
		||||
@@ -85,11 +71,21 @@ packages:
 | 
			
		||||
      nodemailer:
 | 
			
		||||
        optional: true
 | 
			
		||||
 | 
			
		||||
  '@auth/sveltekit@0.14.2':
 | 
			
		||||
    resolution: {integrity: sha512-HCVCCdOOk3KvobUJrMIyAGoKTCNPT18rXL2RiQbM9mTtkvvSlbmwf7ELzMlh6RK7k5SkMD8D4f3WHUfdXIFF0A==}
 | 
			
		||||
  '@auth/sveltekit@1.10.0':
 | 
			
		||||
    resolution: {integrity: sha512-nTKS3FoFvgdqUwb7a8HZpLxDlx+pHndygcodM16J/iFHbe/0wha0MUCuTkVeUYZuKwL63L2ujmMAC1WEoki2+g==}
 | 
			
		||||
    peerDependencies:
 | 
			
		||||
      '@simplewebauthn/browser': ^9.0.1
 | 
			
		||||
      '@simplewebauthn/server': ^9.0.3
 | 
			
		||||
      '@sveltejs/kit': ^1.0.0 || ^2.0.0
 | 
			
		||||
      svelte: ^3.54.0 || ^4.0.0 || ^5
 | 
			
		||||
      nodemailer: ^6.6.5
 | 
			
		||||
      svelte: ^3.54.0 || ^4.0.0 || ^5.0.0-0
 | 
			
		||||
    peerDependenciesMeta:
 | 
			
		||||
      '@simplewebauthn/browser':
 | 
			
		||||
        optional: true
 | 
			
		||||
      '@simplewebauthn/server':
 | 
			
		||||
        optional: true
 | 
			
		||||
      nodemailer:
 | 
			
		||||
        optional: true
 | 
			
		||||
 | 
			
		||||
  '@emnapi/runtime@1.5.0':
 | 
			
		||||
    resolution: {integrity: sha512-97/BJ3iXHww3djw6hYIfErCZFee7qCtrneuLa20UXFCOTCfBM2cvQHjWJ2EG0s0MtdNwInarqCTz35i4wWXHsQ==}
 | 
			
		||||
@@ -747,8 +743,8 @@ packages:
 | 
			
		||||
  htmlparser2@8.0.2:
 | 
			
		||||
    resolution: {integrity: sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==}
 | 
			
		||||
 | 
			
		||||
  ip@2.0.0:
 | 
			
		||||
    resolution: {integrity: sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==}
 | 
			
		||||
  ip@2.0.1:
 | 
			
		||||
    resolution: {integrity: sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==}
 | 
			
		||||
 | 
			
		||||
  is-arrayish@0.3.2:
 | 
			
		||||
    resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==}
 | 
			
		||||
@@ -765,9 +761,6 @@ packages:
 | 
			
		||||
  is-reference@3.0.3:
 | 
			
		||||
    resolution: {integrity: sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==}
 | 
			
		||||
 | 
			
		||||
  jose@5.10.0:
 | 
			
		||||
    resolution: {integrity: sha512-s+3Al/p9g32Iq+oqXxkW//7jk2Vig6FF1CFqzVXoTUXt2qz89YWbL+OwS17NFYEvxC35n0FKeGO2LGYSxeM2Gg==}
 | 
			
		||||
 | 
			
		||||
  jose@6.1.0:
 | 
			
		||||
    resolution: {integrity: sha512-TTQJyoEoKcC1lscpVDCSsVgYzUDg/0Bt3WE//WiTPK6uOCQC2KZS4MpugbMWt/zyjkopgZoXhZuCi00gLudfUA==}
 | 
			
		||||
 | 
			
		||||
@@ -852,9 +845,6 @@ packages:
 | 
			
		||||
  nth-check@2.1.1:
 | 
			
		||||
    resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==}
 | 
			
		||||
 | 
			
		||||
  oauth4webapi@2.17.0:
 | 
			
		||||
    resolution: {integrity: sha512-lbC0Z7uzAFNFyzEYRIC+pkSVvDHJTbEW+dYlSBAlCYDe6RxUkJ26bClhk8ocBZip1wfI9uKTe0fm4Ib4RHn6uQ==}
 | 
			
		||||
 | 
			
		||||
  oauth4webapi@3.8.1:
 | 
			
		||||
    resolution: {integrity: sha512-olkZDELNycOWQf9LrsELFq8n05LwJgV8UkrS0cburk6FOwf8GvLam+YB+Uj5Qvryee+vwWOfQVeI5Vm0MVg7SA==}
 | 
			
		||||
 | 
			
		||||
@@ -885,25 +875,14 @@ packages:
 | 
			
		||||
    resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==}
 | 
			
		||||
    engines: {node: ^10 || ^12 || >=14}
 | 
			
		||||
 | 
			
		||||
  preact-render-to-string@5.2.3:
 | 
			
		||||
    resolution: {integrity: sha512-aPDxUn5o3GhWdtJtW0svRC2SS/l8D9MAgo2+AWml+BhDImb27ALf04Q2d+AHqUUOc6RdSXFIBVa2gxzgMKgtZA==}
 | 
			
		||||
    peerDependencies:
 | 
			
		||||
      preact: '>=10'
 | 
			
		||||
 | 
			
		||||
  preact-render-to-string@6.5.11:
 | 
			
		||||
    resolution: {integrity: sha512-ubnauqoGczeGISiOh6RjX0/cdaF8v/oDXIjO85XALCQjwQP+SB4RDXXtvZ6yTYSjG+PC1QRP2AhPgCEsM2EvUw==}
 | 
			
		||||
    peerDependencies:
 | 
			
		||||
      preact: '>=10'
 | 
			
		||||
 | 
			
		||||
  preact@10.11.3:
 | 
			
		||||
    resolution: {integrity: sha512-eY93IVpod/zG3uMF22Unl8h9KkrcKIRs2EGar8hwLZZDU1lkjph303V9HZBwufh2s736U6VXuhD109LYqPoffg==}
 | 
			
		||||
 | 
			
		||||
  preact@10.24.3:
 | 
			
		||||
    resolution: {integrity: sha512-Z2dPnBnMUfyQfSQ+GBdsGa16hz35YmLmtTLhM169uW944hYL6xzTYkJjC07j+Wosz733pMWx0fgON3JNw1jJQA==}
 | 
			
		||||
 | 
			
		||||
  pretty-format@3.8.0:
 | 
			
		||||
    resolution: {integrity: sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew==}
 | 
			
		||||
 | 
			
		||||
  punycode@2.3.1:
 | 
			
		||||
    resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
 | 
			
		||||
    engines: {node: '>=6'}
 | 
			
		||||
@@ -933,6 +912,9 @@ packages:
 | 
			
		||||
  set-cookie-parser@2.6.0:
 | 
			
		||||
    resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==}
 | 
			
		||||
 | 
			
		||||
  set-cookie-parser@2.7.1:
 | 
			
		||||
    resolution: {integrity: sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==}
 | 
			
		||||
 | 
			
		||||
  sharp@0.33.5:
 | 
			
		||||
    resolution: {integrity: sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==}
 | 
			
		||||
    engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
 | 
			
		||||
@@ -1062,16 +1044,6 @@ packages:
 | 
			
		||||
 | 
			
		||||
snapshots:
 | 
			
		||||
 | 
			
		||||
  '@auth/core@0.28.2':
 | 
			
		||||
    dependencies:
 | 
			
		||||
      '@panva/hkdf': 1.2.1
 | 
			
		||||
      '@types/cookie': 0.6.0
 | 
			
		||||
      cookie: 0.6.0
 | 
			
		||||
      jose: 5.10.0
 | 
			
		||||
      oauth4webapi: 2.17.0
 | 
			
		||||
      preact: 10.11.3
 | 
			
		||||
      preact-render-to-string: 5.2.3(preact@10.11.3)
 | 
			
		||||
 | 
			
		||||
  '@auth/core@0.40.0':
 | 
			
		||||
    dependencies:
 | 
			
		||||
      '@panva/hkdf': 1.2.1
 | 
			
		||||
@@ -1080,16 +1052,12 @@ snapshots:
 | 
			
		||||
      preact: 10.24.3
 | 
			
		||||
      preact-render-to-string: 6.5.11(preact@10.24.3)
 | 
			
		||||
 | 
			
		||||
  '@auth/sveltekit@0.14.2(@sveltejs/kit@2.37.0(@sveltejs/vite-plugin-svelte@6.1.3(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0)))(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0)))(svelte@5.38.6)':
 | 
			
		||||
  '@auth/sveltekit@1.10.0(@sveltejs/kit@2.37.0(@sveltejs/vite-plugin-svelte@6.1.3(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0)))(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0)))(svelte@5.38.6)':
 | 
			
		||||
    dependencies:
 | 
			
		||||
      '@auth/core': 0.28.2
 | 
			
		||||
      '@auth/core': 0.40.0
 | 
			
		||||
      '@sveltejs/kit': 2.37.0(@sveltejs/vite-plugin-svelte@6.1.3(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0)))(svelte@5.38.6)(vite@7.1.3(@types/node@22.18.0))
 | 
			
		||||
      set-cookie-parser: 2.6.0
 | 
			
		||||
      set-cookie-parser: 2.7.1
 | 
			
		||||
      svelte: 5.38.6
 | 
			
		||||
    transitivePeerDependencies:
 | 
			
		||||
      - '@simplewebauthn/browser'
 | 
			
		||||
      - '@simplewebauthn/server'
 | 
			
		||||
      - nodemailer
 | 
			
		||||
 | 
			
		||||
  '@emnapi/runtime@1.5.0':
 | 
			
		||||
    dependencies:
 | 
			
		||||
@@ -1618,7 +1586,7 @@ snapshots:
 | 
			
		||||
      domutils: 3.1.0
 | 
			
		||||
      entities: 4.5.0
 | 
			
		||||
 | 
			
		||||
  ip@2.0.0:
 | 
			
		||||
  ip@2.0.1:
 | 
			
		||||
    optional: true
 | 
			
		||||
 | 
			
		||||
  is-arrayish@0.3.2: {}
 | 
			
		||||
@@ -1637,8 +1605,6 @@ snapshots:
 | 
			
		||||
    dependencies:
 | 
			
		||||
      '@types/estree': 1.0.8
 | 
			
		||||
 | 
			
		||||
  jose@5.10.0: {}
 | 
			
		||||
 | 
			
		||||
  jose@6.1.0: {}
 | 
			
		||||
 | 
			
		||||
  kareem@2.6.3: {}
 | 
			
		||||
@@ -1707,8 +1673,6 @@ snapshots:
 | 
			
		||||
    dependencies:
 | 
			
		||||
      boolbase: 1.0.0
 | 
			
		||||
 | 
			
		||||
  oauth4webapi@2.17.0: {}
 | 
			
		||||
 | 
			
		||||
  oauth4webapi@3.8.1: {}
 | 
			
		||||
 | 
			
		||||
  parse5-htmlparser2-tree-adapter@7.0.0:
 | 
			
		||||
@@ -1736,21 +1700,12 @@ snapshots:
 | 
			
		||||
      picocolors: 1.1.1
 | 
			
		||||
      source-map-js: 1.2.1
 | 
			
		||||
 | 
			
		||||
  preact-render-to-string@5.2.3(preact@10.11.3):
 | 
			
		||||
    dependencies:
 | 
			
		||||
      preact: 10.11.3
 | 
			
		||||
      pretty-format: 3.8.0
 | 
			
		||||
 | 
			
		||||
  preact-render-to-string@6.5.11(preact@10.24.3):
 | 
			
		||||
    dependencies:
 | 
			
		||||
      preact: 10.24.3
 | 
			
		||||
 | 
			
		||||
  preact@10.11.3: {}
 | 
			
		||||
 | 
			
		||||
  preact@10.24.3: {}
 | 
			
		||||
 | 
			
		||||
  pretty-format@3.8.0: {}
 | 
			
		||||
 | 
			
		||||
  punycode@2.3.1: {}
 | 
			
		||||
 | 
			
		||||
  readdirp@4.1.2: {}
 | 
			
		||||
@@ -1796,6 +1751,8 @@ snapshots:
 | 
			
		||||
 | 
			
		||||
  set-cookie-parser@2.6.0: {}
 | 
			
		||||
 | 
			
		||||
  set-cookie-parser@2.7.1: {}
 | 
			
		||||
 | 
			
		||||
  sharp@0.33.5:
 | 
			
		||||
    dependencies:
 | 
			
		||||
      color: 4.2.3
 | 
			
		||||
@@ -1839,7 +1796,7 @@ snapshots:
 | 
			
		||||
 | 
			
		||||
  socks@2.7.1:
 | 
			
		||||
    dependencies:
 | 
			
		||||
      ip: 2.0.0
 | 
			
		||||
      ip: 2.0.1
 | 
			
		||||
      smart-buffer: 4.2.0
 | 
			
		||||
    optional: true
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										18
									
								
								src/app.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								src/app.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -1,12 +1,28 @@
 | 
			
		||||
// See https://kit.svelte.dev/docs/types#app
 | 
			
		||||
// for information about these interfaces
 | 
			
		||||
import type { Session } from "@auth/sveltekit";
 | 
			
		||||
 | 
			
		||||
declare global {
 | 
			
		||||
	namespace App {
 | 
			
		||||
		// interface Error {}
 | 
			
		||||
		// interface Locals {}
 | 
			
		||||
		interface Locals {
 | 
			
		||||
			auth(): Promise<Session | null>;
 | 
			
		||||
		}
 | 
			
		||||
		// interface PageData {}
 | 
			
		||||
		// interface Platform {}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
declare module "@auth/sveltekit" {
 | 
			
		||||
	interface Session {
 | 
			
		||||
		user?: {
 | 
			
		||||
			name?: string | null;
 | 
			
		||||
			email?: string | null;
 | 
			
		||||
			image?: string | null;
 | 
			
		||||
			nickname?: string;
 | 
			
		||||
			groups?: string[];
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export {};
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								src/auth.ts
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/auth.ts
									
									
									
									
									
								
							@@ -4,11 +4,17 @@ import { AUTHENTIK_ID, AUTHENTIK_SECRET, AUTHENTIK_ISSUER } from "$env/static/pr
 | 
			
		||||
 | 
			
		||||
export const { handle, signIn, signOut } = SvelteKitAuth({
 | 
			
		||||
	providers: [
 | 
			
		||||
		Authentik({
 | 
			
		||||
		{
 | 
			
		||||
			id: "authentik",
 | 
			
		||||
			name: "Authentik",
 | 
			
		||||
			type: "oidc",
 | 
			
		||||
			clientId: AUTHENTIK_ID,
 | 
			
		||||
			clientSecret: AUTHENTIK_SECRET,
 | 
			
		||||
			issuer: AUTHENTIK_ISSUER,
 | 
			
		||||
		})],
 | 
			
		||||
			checks: ["state"],
 | 
			
		||||
		}],
 | 
			
		||||
	trustHost: true,
 | 
			
		||||
	debug: process.env.NODE_ENV === "development",
 | 
			
		||||
	callbacks: {
 | 
			
		||||
		// this feels like an extremely hacky way to get nickname and groups into the session object
 | 
			
		||||
		// TODO: investigate if there's a better way to do this
 | 
			
		||||
@@ -20,8 +26,8 @@ export const { handle, signIn, signOut } = SvelteKitAuth({
 | 
			
		||||
			return token;
 | 
			
		||||
		},
 | 
			
		||||
		session: async ({session, token}) => {
 | 
			
		||||
			session.user.nickname = token.nickname;
 | 
			
		||||
			session.user.groups = token.groups;
 | 
			
		||||
			session.user.nickname = token.nickname as string;
 | 
			
		||||
			session.user.groups = token.groups as string[];
 | 
			
		||||
			return session;
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ import * as auth from "./auth"
 | 
			
		||||
async function authorization({ event, resolve }) {
 | 
			
		||||
	// Protect any routes under /authenticated
 | 
			
		||||
	if (event.url.pathname.startsWith('/rezepte/edit') || event.url.pathname.startsWith('/rezepte/add')) {
 | 
			
		||||
   const session = await event.locals.getSession();
 | 
			
		||||
   const session = await event.locals.auth();
 | 
			
		||||
		if (!session) {
 | 
			
		||||
			redirect(303, '/auth/signin');
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
import type { PageServerLoad } from "./$types"
 | 
			
		||||
import type { LayoutServerLoad } from "./$types"
 | 
			
		||||
 | 
			
		||||
export const load : PageServerLoad = (async ({locals}) => {
 | 
			
		||||
export const load : LayoutServerLoad = (async ({locals}) => {
 | 
			
		||||
	return {
 | 
			
		||||
		session: await locals.auth(),
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
import type { PageServerLoad } from "./$types"
 | 
			
		||||
import type { LayoutServerLoad } from "./$types"
 | 
			
		||||
 | 
			
		||||
export const load : PageServerLoad = (async ({locals}) => {
 | 
			
		||||
export const load : LayoutServerLoad = (async ({locals}) => {
 | 
			
		||||
	return {
 | 
			
		||||
		session: await locals.auth(),
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,6 @@
 | 
			
		||||
import Header from '$lib/components/Header.svelte'
 | 
			
		||||
import UserHeader from '$lib/components/UserHeader.svelte';
 | 
			
		||||
export let data
 | 
			
		||||
let username = ""
 | 
			
		||||
if(data.user){
 | 
			
		||||
	username = data.user.username
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<Header>
 | 
			
		||||
	<ul class=site_header slot=links>
 | 
			
		||||
@@ -13,6 +9,6 @@ if(data.user){
 | 
			
		||||
	<li><a href="/glaube/rosenkranz">Rosenkranz</a></li>
 | 
			
		||||
	<li><a href="/glaube/predigten">Predigten</a></li>
 | 
			
		||||
	</ul>
 | 
			
		||||
	<UserHeader {username} slot=right_side></UserHeader>
 | 
			
		||||
	<UserHeader user={data.session?.user} slot=right_side></UserHeader>
 | 
			
		||||
	<slot></slot>
 | 
			
		||||
</Header>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
import type { PageServerLoad } from "./$types"
 | 
			
		||||
import type { LayoutServerLoad } from "./$types"
 | 
			
		||||
 | 
			
		||||
export const load : PageServerLoad = async ({locals}) => {
 | 
			
		||||
export const load : LayoutServerLoad = async ({locals}) => {
 | 
			
		||||
	return {
 | 
			
		||||
		session: await locals.auth()
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
export async function load({locals}) {
 | 
			
		||||
    const session = await locals.auth();
 | 
			
		||||
    return {
 | 
			
		||||
	user: locals.user
 | 
			
		||||
	user: session?.user
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,11 @@
 | 
			
		||||
import type { PageLoad } from "./$types";
 | 
			
		||||
import type { PageServerLoad } from "./$types";
 | 
			
		||||
 | 
			
		||||
export async function load({ fetch, params, locals}) {
 | 
			
		||||
    let current_month = new Date().getMonth() + 1
 | 
			
		||||
    const res = await fetch(`/api/rezepte/items/${params.name}`);
 | 
			
		||||
    const recipe = await res.json();
 | 
			
		||||
    const session = await locals.auth();
 | 
			
		||||
    return {recipe: recipe,
 | 
			
		||||
	user: locals.user
 | 
			
		||||
	user: session?.user
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user