5 Commits

Author SHA1 Message Date
Lane
cf66219986
fix: configurable JWT TTL with working refresh endpoint (#800) (#801)
* fix: configurable JWT TTL with working refresh endpoint (#800)

Replace the hardcoded 24h JWT expiration with configurable TTL (default 30d)
resolvable via JWT_EXPIRES_IN env var (ceiling) or admin Settings โ†’ Security
UI. Rewrite /auth/refresh to accept valid-or-recently-expired tokens within a
configurable grace window (default 7d), re-verifying the HS256 signature via
Web Crypto (since hono/jwt checks exp before signature) and re-validating the
user against the database before issuing a fresh token.

Updates every token-minting call site (auth routes, OTP plugin, magic-link
plugin, OAuth providers) to read the TTL from the DB-aware helper. Adds a
live Session / JWT card to Admin โ†’ Settings โ†’ Security with save/load and
matching persistence via SettingsService. Updates repo docs and the doc site
authentication page to describe the new configuration surface and refresh
semantics.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: keep /auth/refresh 401 message and flex cookie Max-Age assertion

- Restore "Authentication required" as the error message when /auth/refresh is
  called without a token, matching the prior behavior the E2E contract expects.
- Update the cookie E2E to assert Max-Age is present (any positive value)
  instead of the old hardcoded 86400, since JWT TTL is now configurable.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-21 18:42:51 -07:00
Lane
968399b5f4
docs: add HS256 algorithm to JWT sign/verify examples (#554)
Update authentication docs to match the fix from PR #505.
The examples now correctly show the 'HS256' algorithm parameter
required for proper JWT token handling.

Relates to: #500

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 16:41:26 -08:00
Lane Campbell
c47d4b3d60 security: change default admin password from admin123 to sonicjs!
Updated all references to the default admin password across the codebase:

- Changed seed script to use 'sonicjs!' instead of 'admin123'
- Updated demo-login plugin to prefill new password
- Updated all documentation (docs/, www/)
- Updated test helpers and e2e test utilities
- Updated migration SQL files with new password
- Updated auth routes to hash new password
- Updated all source code comments
- Updated database admin user password via seed-admin endpoint

Admin credentials are now:
- Email: admin@sonicjs.com
- Password: sonicjs!

๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 09:45:58 -08:00
Lane Campbell
1eb938be0d docs: comprehensive developer documentation update
Complete rewrite and expansion of all developer documentation with detailed
technical content, code examples, and real-world usage patterns.

๐Ÿ“š New Documentation Files (3):
- architecture.md (996 lines) - Complete system architecture, request lifecycle,
  middleware pipeline, plugin system, caching, database, and data flow patterns
- caching.md (1,785 lines) - Three-tier cache system, invalidation strategies,
  event-driven invalidation, warming, monitoring, and best practices
- routing-middleware.md (1,507 lines) - Complete routing structure, middleware
  pipeline, auth/permissions, logging, bootstrap, and custom middleware

๐Ÿ“ Updated Documentation Files (9):
- getting-started.md (856 lines) - Comprehensive setup guide with core concepts,
  project structure, troubleshooting, and next steps
- plugin-development-guide.md (3,234 lines) - Complete plugin system guide with
  real examples from cache, auth, and media plugins
- api-reference.md (1,200 lines) - All API endpoints with request/response
  examples, cache headers, pagination, and code examples in 3 languages
- database.md (2,110 lines) - Complete D1 setup, all migrations, Drizzle ORM,
  query patterns, performance optimization, and backup procedures
- authentication.md (1,696 lines) - JWT auth, KV caching, RBAC, permissions,
  session management, and security best practices
- collections-config.md (2,146 lines) - All 30+ field types, collection sync,
  validation, relationships, and advanced features
- templating.md (2,016 lines) - HTMX patterns, Alpine.js, TailwindCSS, dark mode,
  component library, and real-world examples
- testing.md (2,124 lines) - Complete testing setup, unit tests, E2E tests with
  real examples from test suite, coverage, and CI/CD
- deployment.md (1,750 lines) - Complete Cloudflare Workers deployment, D1/R2/KV
  setup, environments, CI/CD, monitoring, and production checklist

๐Ÿ“Š Documentation Statistics:
- Total: 17,653+ lines of new/updated documentation
- 12 comprehensive guides covering all aspects of SonicJS
- 100+ code examples from actual implementation
- Complete API reference with 3 language examples
- Real-world patterns and best practices throughout

โœจ Key Features:
- All code examples pulled from actual source files
- File paths referenced for easy navigation (e.g., src/plugins/cache/services/cache.ts)
- Step-by-step tutorials and guides
- Architecture diagrams and flow charts
- Troubleshooting sections with solutions
- Best practices for every major system
- Production-ready deployment instructions

๐ŸŽฏ Coverage:
- Complete architecture and system design
- Plugin development from basics to advanced
- Authentication and authorization (JWT, RBAC, permissions)
- Three-tier caching system with event-driven invalidation
- Database migrations, ORM, and performance
- Template system with HTMX and Alpine.js
- Complete testing strategy (unit + E2E)
- Production deployment and monitoring

๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-06 10:10:29 -07:00
Lane Campbell
7a2c0ab704 fix: major e2e test improvements
- Fixed collections name field display issue in table template
- Added more default collections (pages, news) to migration
- Fixed h1 selector issues across multiple test files
- Improved admin dropdown menu from hover to click-based
- Enhanced database query processing for collections
- Updated test selectors to use .first() for multiple h1 elements

Tests now passing:
- Health: 4/4 tests โœ…
- Authentication: 6/6 tests โœ…
- Admin Dashboard: 5/7 tests โœ…
- Content Management: Starting to pass โœ…

Major fixes:
- Collections table now shows proper collection names
- Admin user seeding works correctly
- UI dropdown interference resolved
- Multiple h1 element selection fixed
2025-06-25 09:19:29 -07:00