- Expand plan to cover Identity Provider (IdP) functionality - Introduce user onboarding via email invites - Implement user-centric permissions management - Enhance SMTP configuration details - Outline phases for backend and frontend implementation
4.3 KiB
4.3 KiB
📋 Plan: Security Hardening, User Gateway & Identity
🧐 UX & Context Analysis
This plan expands on the initial security hardening to include a full Identity Provider (IdP) feature set. This allows Charon to manage users, invite them via email, and let them log in using external providers (SSO), while providing seamless access to downstream apps.
1. The User Gateway (Forward Auth)
- Scenario: Admin shares
jellyseerr.example.comwith a friend. - Flow:
- Friend visits
jellyseerr.example.com. - Redirected to Charon Login.
- Logs in via Plex / Google / GitHub OR Local Account.
- Charon verifies access.
- Charon redirects back to Jellyseerr, injecting
X-Forwarded-User: friend@email.com. - Magic: Jellyseerr (configured for header auth) sees the header and logs the friend in automatically. No second login.
- Friend visits
2. User Onboarding (SMTP & Invites)
- Problem: Admin shouldn't set passwords manually.
- Solution: Admin enters email -> Charon sends Invite Link -> User clicks link -> User sets Password & Name.
3. User-Centric Permissions (Allow/Block Lists)
- Concept: Instead of managing groups, Admin manages permissions per user.
- UX:
- Go to Users -> Edit User -> Permissions Tab.
- Mode: Toggle between "Allow All (Blacklist)" or "Deny All (Whitelist)".
- Exceptions: Multi-select list of Proxy Hosts.
- Example: Set Mode to "Deny All", select "Jellyseerr". User can ONLY access Jellyseerr.
- Example: Set Mode to "Allow All", select "Home Assistant". User can access everything EXCEPT Home Assistant.
🤝 Handoff Contract (The Truth)
1. Auth Verification (Internal API for Caddy)
- Endpoint:
GET /api/auth/verify - Response Headers:
X-Forwarded-User: The user's email or username.X-Forwarded-Groups: (Future) User roles/groups.
2. SMTP Configuration
// POST /api/settings/smtp
{
"host": "smtp.gmail.com",
"port": 587,
"username": "admin@example.com",
"password": "app-password",
"from_address": "Charon <no-reply@example.com>",
"encryption": "starttls" // none, ssl, starttls
}
3. User Permissions
// POST /api/users
{
"email": "friend@example.com",
"role": "user",
"permission_mode": "deny_all", // or "allow_all"
"permitted_hosts": [1, 4, 5] // List of ProxyHost IDs to treat as exceptions
}
🏗️ Phase 1: Security Hardening (Quick Wins)
- Secure Headers:
Content-Security-Policy,Strict-Transport-Security,X-Frame-Options. - Cookie Security:
HttpOnly,Secure,SameSite=Strict.
🏗️ Phase 2: Backend Core (User & SMTP)
- Models:
User: AddInviteToken,InviteExpires,PermissionMode(string),Permissions(Many-to-Many with ProxyHost).ProxyHost: AddForwardAuthEnabled(bool).Setting: Add keys forsmtp_host,smtp_port, etc.
- Logic:
internal/services/mail: Implement SMTP sender.internal/api/handlers/user.go: AddInviteUserhandler and Permission logic.
🏗️ Phase 3: SSO Implementation
- Library: Use
github.com/markbates/gothorgolang.org/x/oauth2. - Models:
SocialAccount(UserID, Provider, ProviderID, Email). - Routes:
GET /auth/:provider: Start OAuth flow.GET /auth/:provider/callback: Handle return, create/link user, set session.
🏗️ Phase 4: Forward Auth Integration
- Caddy: Configure
forward_authdirective to point to Charon API. - Logic:
VerifyAccesshandler:- Check if User is logged in.
- Fetch User's
PermissionModeandPermissions. - If
allow_all: Grant access UNLESS host is inPermissions. - If
deny_all: Deny access UNLESS host is inPermissions.
🎨 Phase 5: Frontend Implementation
- Settings: New "SMTP" and "SSO" tabs in Settings page.
- User List: "Invite User" button.
- User Edit: New "Permissions" tab with "Allow/Block" toggle and Host selector.
- Login Page: Add "Sign in with Google/Plex/GitHub" buttons.
📚 Phase 6: Documentation
- SSO Guides: How to get Client IDs from Google/GitHub.
- Header Auth: Guide on configuring Jellyseerr/Grafana to trust Charon.