Compare commits

...

2 Commits

Author SHA1 Message Date
ba30ad4bc7 tidy up docker-compose.yml 2025-08-16 22:15:52 -04:00
1fdc20ee0c fix random auth errors
idk how i did it
2025-08-16 22:15:22 -04:00
3 changed files with 30 additions and 40 deletions

View File

@@ -1,16 +1,8 @@
services: services:
ical-pwa: local-ical:
build: . build: .
container_name: ical-pwa container_name: local-ical
restart: unless-stopped restart: unless-stopped
# ports:
# - "3000:3000"
# environment:
# NODE_ENV: production
# OPENROUTER_API_KEY: ${OPENROUTER_API_KEY}
# volumes:
# - .:/app
# - /app/node_modules
networks: networks:
- traefik - traefik
- internal - internal
@@ -27,4 +19,4 @@ networks:
external: true external: true
internal: internal:
external: false external: false
name: ical-local-network name: local-ical-network

View File

@@ -1,4 +1,4 @@
import NextAuth, { NextAuthConfig } from "next-auth"; import NextAuth, { NextAuthConfig, NextAuthResult } from "next-auth";
import Authentik from "next-auth/providers/authentik"; import Authentik from "next-auth/providers/authentik";
import type { Provider } from "next-auth/providers"; import type { Provider } from "next-auth/providers";
@@ -7,19 +7,6 @@ const providers: Provider[] = [
clientId: process.env.AUTH_AUTHENTIK_CLIENT_ID, clientId: process.env.AUTH_AUTHENTIK_CLIENT_ID,
clientSecret: process.env.AUTH_AUTHENTIK_CLIENT_SECRET, clientSecret: process.env.AUTH_AUTHENTIK_CLIENT_SECRET,
issuer: process.env.AUTH_AUTHENTIK_ISSUER, issuer: process.env.AUTH_AUTHENTIK_ISSUER,
authorization: {
params: {
scope: "openid email profile",
},
},
profile(profile) {
return {
id: profile.sub,
name: profile.name,
email: profile.email,
image: profile.picture,
};
},
}), }),
]; ];
@@ -39,19 +26,5 @@ const config = {
signOut: "/signout", signOut: "/signout",
}, },
trustHost: true, trustHost: true,
// callbacks: {
// authorized({ auth, request: { nextUrl } }) {
// const isLoggedIn = !!auth?.user;
// const isOnProtectedRoute = nextUrl.pathname.startsWith("/api/ai-event");
//
// if (isOnProtectedRoute) {
// if (isLoggedIn) return true;
// return false;
// } else if (isLoggedIn) {
// return Response.redirect(new URL("/api/ai-event", nextUrl));
// }
// return true;
// },
// },
} satisfies NextAuthConfig; } satisfies NextAuthConfig;
export const { handlers, signIn, signOut, auth } = NextAuth(config); export const { handlers, signIn, signOut, auth }: NextAuthResult = NextAuth(config);

25
src/middleware.ts Normal file
View File

@@ -0,0 +1,25 @@
import { auth } from "@/auth"
export default auth((req) => {
const { nextUrl } = req
const isLoggedIn = !!req.auth
// Protect dashboard routes
// if (nextUrl.pathname.startsWith('/api') && !isLoggedIn) {
// return Response.redirect(new URL('/signin', nextUrl))
// }
// Redirect logged-in users from sign-in page
if (nextUrl.pathname.startsWith('/signin') && isLoggedIn) {
return Response.redirect(new URL('/', nextUrl))
}
})
export const config = {
matcher: [
// Skip Next.js internals and all static files
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
// Always run for API routes
'/(api|trpc)(.*)',
],
}