[PR #1227] [CLOSED] move auth redirect to middleware #1766

Closed
opened 2026-03-02 11:59:05 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/karakeep-app/karakeep/pull/1227
Author: @jaworek
Created: 4/9/2025
Status: Closed

Base: mainHead: move-auth-redirect-to-middleware


📝 Commits (6)

📊 Changes

9 files changed (+23 additions, -43 deletions)

View changed files

📝 apps/web/app/admin/layout.tsx (+1 -1)
📝 apps/web/app/dashboard/layout.tsx (+0 -7)
📝 apps/web/app/page.tsx (+1 -7)
📝 apps/web/components/dashboard/bookmarks/Bookmarks.tsx (+0 -7)
📝 apps/web/components/dashboard/header/Header.tsx (+0 -7)
📝 apps/web/components/dashboard/header/ProfileOptions.tsx (+5 -7)
apps/web/lib/pages.ts (+6 -0)
apps/web/middleware.ts (+7 -0)
📝 apps/web/server/auth.ts (+3 -7)

📄 Description

Add middleware and setup next-auth to avoid having multiple places in the app to protect against unauthorized access.

https://next-auth.js.org/configuration/nextjs#middleware

Test steps:

  1. Open app at "localhost:3000"
  2. Verify that you get redirected to "/signin" page
  3. Login with your credentials or singup with new account
  4. Verify that you get redirected to "/dashboard/bookmarks"
  5. Try to access "/signin" page and verify that you get redirected to "/dashboard/bookmarks" while logged it
  6. Logout and verify that you're redirected to "/signin" page

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/karakeep-app/karakeep/pull/1227 **Author:** [@jaworek](https://github.com/jaworek) **Created:** 4/9/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `move-auth-redirect-to-middleware` --- ### 📝 Commits (6) - [`bcdf265`](https://github.com/karakeep-app/karakeep/commit/bcdf265e9b4bee798f115de310d179a245e9142e) move auth redirect to middleware - [`67cae81`](https://github.com/karakeep-app/karakeep/commit/67cae814378c86062c623382783e4a7c0564c07d) fix formatting - [`4df1367`](https://github.com/karakeep-app/karakeep/commit/4df13676d6314bfe9e8119bd2d5a4ebf36b52899) fix build error - [`b5bf13d`](https://github.com/karakeep-app/karakeep/commit/b5bf13d2d8d9bc86dc835ff5a27e219a0269635a) move pages to lib - [`e459957`](https://github.com/karakeep-app/karakeep/commit/e45995714135aa2ce4769ff4c9e9f93789aec03a) try updating session for trpc - [`7b4093f`](https://github.com/karakeep-app/karakeep/commit/7b4093f4b2d99ee8efe4e2c68b6a0fdc2b8dbfa1) fix ### 📊 Changes **9 files changed** (+23 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `apps/web/app/admin/layout.tsx` (+1 -1) 📝 `apps/web/app/dashboard/layout.tsx` (+0 -7) 📝 `apps/web/app/page.tsx` (+1 -7) 📝 `apps/web/components/dashboard/bookmarks/Bookmarks.tsx` (+0 -7) 📝 `apps/web/components/dashboard/header/Header.tsx` (+0 -7) 📝 `apps/web/components/dashboard/header/ProfileOptions.tsx` (+5 -7) ➕ `apps/web/lib/pages.ts` (+6 -0) ➕ `apps/web/middleware.ts` (+7 -0) 📝 `apps/web/server/auth.ts` (+3 -7) </details> ### 📄 Description Add middleware and setup next-auth to avoid having multiple places in the app to protect against unauthorized access. https://next-auth.js.org/configuration/nextjs#middleware Test steps: 1. Open app at "localhost:3000" 2. Verify that you get redirected to "/signin" page 3. Login with your credentials or singup with new account 4. Verify that you get redirected to "/dashboard/bookmarks" 5. Try to access "/signin" page and verify that you get redirected to "/dashboard/bookmarks" while logged it 6. Logout and verify that you're redirected to "/signin" page --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 11:59:05 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#1766
No description provided.