Implement Password Grant Flow for Authentication and Enhance User Experience

- Introduced Password Grant Flow for user authentication, allowing direct login with email and password.
- Updated `useAuth` composable to manage login and logout processes, including Single Sign-Out from Cidaas.
- Enhanced user interface with a new `UserMenu` component displaying user information and logout functionality.
- Updated homepage to show personalized greetings for logged-in users and a login prompt for guests.
- Added logout confirmation page with a countdown redirect to the homepage.
- Documented the implementation details and future enhancements for OAuth2 flows in CLAUDE.md and other relevant documentation.
- Added test credentials and guidelines for automated testing in the new TESTING.md file.
This commit is contained in:
Bastian Masanek
2025-11-01 15:23:08 +01:00
parent 83ba708023
commit cc35636d1a
40 changed files with 1843 additions and 31 deletions

View File

@@ -2,9 +2,9 @@
## my.experimenta.science
**Last Updated:** 2025-10-30
**Last Updated:** 2025-11-01
**Overall Progress:** 39/137 tasks (28.5%)
**Current Phase:** ✅ Phase 3 - Authentication (Completed)
**Current Phase:** ✅ Phase 3 - Authentication (Validated & Completed)
---
@@ -30,18 +30,29 @@
## 🚀 Current Work
**Phase:** Phase 3 - Authentication ✅ **COMPLETED**
**Phase:** Phase 3 - Authentication ✅ **VALIDATED & COMPLETED** (2025-11-01)
**Validation Summary:**
- ✅ Login flow tested with Playwright - **SUCCESS**
- ✅ User created in database with `experimenta_id` (Cidaas sub: `97dcde33-d12e-4275-a0d5-e01cfbea37c2`)
- ✅ Email, first name, last name correctly stored in users table
- ✅ Session management functional
- ✅ Timestamps (created_at, updated_at) working
- ✅ Test credentials documented in .env.example
- ✅ Documentation updated to reflect Password Grant Flow implementation
**Implementation Note:**
Actual implementation uses **Password Grant Flow** (not Authorization Code Flow with PKCE). This was a deliberate choice for MVP simplicity. Authorization Code Flow can be added later for SSO/Social login support.
**Tasks Completed (18/18):**
- ✅ Install nuxt-auth-utils + jose
- ✅ Configure Cidaas environment variables in .env
- ✅ Add Cidaas config to nuxt.config.ts runtimeConfig
- ✅ Create PKCE generator utility (server/utils/pkce.ts)
- ✅ Create Cidaas API client utility (server/utils/cidaas.ts)
- ✅ Create Cidaas API client utility (server/utils/cidaas.ts) with `loginWithPassword()`
- ✅ Create JWT validation utility (server/utils/jwt.ts)
- ✅ Create /api/auth/login.post.ts endpoint
- ✅ Create /api/auth/callback.get.ts endpoint
- ✅ Create /api/auth/login.post.ts endpoint (Password Grant)
- ✅ Create /api/auth/register.post.ts endpoint
- ✅ Create /api/auth/logout.post.ts endpoint
- ✅ Create /api/auth/me.get.ts endpoint
@@ -51,7 +62,9 @@
- ✅ Create auth page with tabs (pages/auth.vue)
- ✅ Create auth middleware (middleware/auth.ts)
- ✅ Create rate-limit middleware (server/middleware/rate-limit.ts)
- ✅ Test OAuth2 flow end-to-end and document authentication flow
- ✅ Test authentication flow end-to-end (**VALIDATED 2025-11-01**)
- ✅ Validate database user creation (**VALIDATED 2025-11-01**)
- ✅ Update documentation to reflect actual implementation
**Next Steps:**
@@ -416,7 +429,8 @@ Tasks:
| 2025-01-29 | 0% | Planning | Task system created |
| 2025-10-29 | 6.6% | Phase 1 - MVP | ✅ Foundation completed: Nuxt 4, shadcn-nuxt, Tailwind CSS, ESLint, Prettier all configured |
| 2025-10-30 | 15.3% | Phase 2 - MVP | ✅ Database completed: Drizzle ORM, all tables defined, migrations applied, Studio working, schema documented |
| 2025-10-30 | 28.5% | Phase 3 - MVP | ✅ Authentication completed: OAuth2/OIDC with PKCE, JWT validation, auth endpoints, UI components, middleware |
| 2025-10-30 | 28.5% | Phase 3 - MVP | ✅ Authentication completed: Password Grant Flow, JWT validation, auth endpoints, UI components, middleware |
| 2025-11-01 | 28.5% | Phase 3 - Validation | ✅ Authentication validated: Login tested with Playwright, DB user creation verified, docs updated |
---