How newsand/janus works
Janus is a JWT identity service. Clients call its HTTP API to authenticate, manage users, accept invites, recover accounts, and configure 2FA; successful authentication returns access and refresh tokens. main.go initializes configuration and PostgreSQL, then registers feature routes. Feature handlers use shared middleware and GORM-backed models. The README documents password recovery and mail delivery behavior, but the password handler was not sampled, so its internal calls are not asserted.
Main entry points: main.go HTTP server · auth/handler.go Authentication · users/handler.go User management · db.go Database access
Components 15
HTTP features
- HTTP server
main.go - Authentication
features/auth/handler.go - User management
features/users/handler.go - Password recovery
features/password - Two-factor auth
features/twofa/handler.go - Health checks
features/health/handler.go
Identity security
- JWT and keys
internal/middleware/auth.go - Rate limits
internal/middleware/ratelimit.go
Persistence
- Database access
internal/db/db.go - Identity records
internal/models/models.go
Runtime services
- Configuration
internal/config/config.go - Logging
internal/logger/logger.go
Other components
- API clients
- PostgreSQL
- Email delivery
Connections 33
- API clients → HTTP server: HTTP requests
README.md - HTTP server → Authentication: registers routes
main.go - HTTP server → User management: registers routes
main.go - HTTP server → Password recovery: registers routes
main.go - HTTP server → Two-factor auth: registers routes
main.go - HTTP server → Health checks: registers routes
main.go - HTTP server → Configuration: loads settings
main.go - HTTP server → Database access: initializes
main.go - HTTP server → Logging: initializes
main.go - Authentication → Database access: reads and writes
features/auth/handler.go - User management → Database access: reads and writes
features/users/handler.go - Two-factor auth → Database access: reads and writes
features/twofa/handler.go - Health checks → Database access: checks connection
features/health/handler.go - Database access → PostgreSQL: connects
internal/db/db.go - Authentication → Identity records: uses token records
features/auth/handler.go - User management → Identity records: uses user records
features/users/handler.go - Two-factor auth → Identity records: uses challenge records
features/twofa/handler.go - Authentication → JWT and keys: applies JWT auth
features/auth/handler.go - User management → JWT and keys: applies service-key auth
features/users/handler.go - Two-factor auth → JWT and keys: applies JWT auth
features/twofa/handler.go - Authentication → Rate limits: applies rate limits
features/auth/handler.go - User management → Rate limits: limits invite acceptance
features/users/handler.go - Authentication → Configuration: reads token settings
features/auth/handler.go - Two-factor auth → Configuration: reads token settings
features/twofa/handler.go - User management → Configuration: reads invite settings
features/users/handler.go - Health checks → Configuration: reads version
features/health/handler.go - Authentication → Logging: logs events
features/auth/handler.go - User management → Logging: logs events
features/users/handler.go - Two-factor auth → Logging: logs events
features/twofa/handler.go - Password recovery → Database access: stores recovery state
- Password recovery → Email delivery: sends recovery email
README.md - Authentication → Email delivery: delivers magic links
README.md - User management → Email delivery: delivers invites
README.md