Authentication System
Zerobyte’s authentication is built on better-auth and includes:- Email and password - Traditional username/email + password authentication
- SSO - SAML 2.0 and OIDC-based single sign-on
- Two-factor authentication - TOTP-based 2FA with backup codes
- Organizations - Multi-tenant organization support
- Session management - Secure, encrypted sessions
- Account linking - Link multiple auth methods to one account
First User Setup
When you first access Zerobyte, you’ll be prompted to create an account. First user privileges:- Automatically assigned admin role
- Can configure SSO providers
- Can enable/disable user registration
- Becomes owner of the default organization
- Navigate to
http://your-server:4096 - Click “Sign Up”
- Enter email, username, and password
- Complete registration
The first user is critical for system administration. Use a strong password and enable two-factor authentication immediately.
User Registration
By default, user registration is disabled after the first user registers. Adding additional users:Option 1: Enable Registration (Admin)
Allow anyone to register:- Log in as admin
- Go to Settings → Security
- Enable “User Registration”
- Save changes
Option 2: SSO Invitation (Recommended)
Invite users to your organization via SSO:- Configure an SSO provider (see SSO Configuration)
- Invite user by email
- User receives invitation and signs in via SSO
- User is automatically added to organization
Cookie Security
Zerobyte automatically configures cookies based on yourBASE_URL environment variable.
HTTPS Deployments (Recommended)
Secure: true- Cookies only sent over HTTPSSameSite: Lax- CSRF protectionHttpOnly: true- JavaScript cannot access cookiesPrefix: zerobyte- Prevents cookie conflicts
- Sessions work seamlessly over HTTPS
- Full CSRF protection
- Secure against session hijacking
HTTP Deployments (Development Only)
Secure: false- Allows cookies over HTTPSameSite: Lax- CSRF protection (still enabled)HttpOnly: true- JavaScript cannot access cookies
- Sessions work over HTTP (local networks)
- Limited CSRF protection
- Vulnerable to network sniffing
Reverse Proxy Configuration
When running behind a reverse proxy, configure it to forward the correct protocol: Nginx:- User accesses
https://zerobyte.example.com - Reverse proxy forwards to
http://localhost:4096 - Proxy sends
X-Forwarded-Proto: httpsheader - Zerobyte sees HTTPS and enables secure cookies
- Cookies marked
Secureare sent back through proxy
Two-Factor Authentication (2FA)
Zerobyte supports TOTP-based two-factor authentication for enhanced security.Enable 2FA
- Log in to Zerobyte
- Go to Settings → Security
- Click “Enable Two-Factor Authentication”
- Scan QR code with authenticator app (Google Authenticator, Authy, 1Password, etc.)
- Enter verification code
- Save your backup codes (5 codes generated)
Backup Codes
Zerobyte generates 5 encrypted backup codes when you enable 2FA. Features:- Encrypted storage - Codes encrypted using
APP_SECRET - One-time use - Each code can only be used once
- Recovery access - Use if you lose your authenticator device
- Go to login page
- Enter email and password
- When prompted for 2FA code, click “Use backup code”
- Enter one of your 5 backup codes
- Log in successfully
If you use all 5 backup codes, generate new ones from Settings → Security.
Disable 2FA
- Log in to Zerobyte
- Go to Settings → Security
- Click “Disable Two-Factor Authentication”
- Confirm action
SSO Configuration
Zerobyte supports enterprise SSO via SAML 2.0 and OIDC (OpenID Connect).Supported Protocols
- SAML 2.0 - Okta, Azure AD, Google Workspace, OneLogin, etc.
- OIDC - Auth0, Keycloak, custom OIDC providers
Prerequisites
- Admin or Owner role in an organization
- BASE_URL must be set correctly (affects callback URLs)
- HTTPS recommended (required by most IdPs)
Add SSO Provider
- Log in as admin or organization owner
- Go to Organization Settings → SSO
- Click “Add SSO Provider”
- Choose protocol (SAML or OIDC)
- Enter provider details:
- Provider ID - Unique identifier (e.g.,
okta-production) - Entity ID - Your IdP’s entity ID
- SSO URL - Your IdP’s sign-on URL
- Certificate - X.509 certificate from IdP
- Provider ID - Unique identifier (e.g.,
- Save provider
Provider ID Requirements
The Provider ID must:- Be unique across all organizations
- Contain only alphanumeric characters, hyphens, and underscores
- Not use reserved names (
admin,api,auth, etc.)
okta-productionazure-ad-engineeringgoogle-workspace
admin(reserved)my provider(contains spaces)test@org(contains special characters)
Callback URLs
Provide these URLs to your IdP during configuration: SAML:{providerId} with your actual provider ID (e.g., okta-production).
Callback URLs are validated against
BASE_URL. Ensure BASE_URL matches your public domain.Auto-Linking
Allow users to automatically link SSO accounts with existing Zerobyte accounts. Enable auto-linking:- Go to Organization Settings → SSO
- Select your SSO provider
- Enable “Auto-link matching emails”
- Save changes
- User signs in via SSO with
[email protected] - Zerobyte finds existing account with same email
- Accounts are automatically linked
- User can now sign in with either method
- Only enable if you trust your IdP’s email verification
- Users must have verified emails in your IdP
- Better-auth does not trust email verification by default
SSO Invitations
Invite users to join your organization via SSO. Send invitation:- Go to Organization Settings → Members
- Click “Invite Member”
- Enter user’s email address
- Select role (Member, Admin, Owner)
- Set expiration (default: 7 days)
- Send invitation
- User clicks SSO login for your organization
- User signs in via IdP
- Zerobyte validates invitation
- User is automatically added to organization with assigned role
- Email must match invitation exactly
- Invitation must not be expired
- Invitation status must be “pending”
- Organization must have an active SSO provider
Users cannot register via SSO without an invitation. This prevents unauthorized access.
Provider Limits
By default, users can create SSO providers based on their role:| Role | Max SSO Providers |
|---|---|
| Organization Owner/Admin | 10 |
| Regular User | 0 |
Delete SSO Provider
Delete provider:- Go to Organization Settings → SSO
- Select provider to delete
- Click “Delete Provider”
- Confirm deletion
- Provider configuration removed
- All linked accounts (via this provider) deleted
- Users can no longer sign in via this provider
- Users with other auth methods (email/password, other SSO) retain access
Organizations
Zerobyte uses organizations for multi-tenant access control.Organization Roles
| Role | Permissions |
|---|---|
| Owner | Full control; cannot be removed; assigned to organization creator |
| Admin | Manage members, SSO, resources; can invite users |
| Member | View and use organization resources; no admin access |
Default Organization
When a user first signs in, a default organization is created:- Name:
{username}'s Organization - Owner: The user
- Members: Just the user
- Automatically created on first login
- User becomes organization owner
- Organization persists across sessions
Switching Organizations
Users can be members of multiple organizations. Switch active organization:- Click organization name in navigation
- Select different organization from dropdown
- Context switches to selected organization
- Visible volumes, repositories, backups
- Available SSO providers
- Member management
Manage Members
View members:- Go to Organization Settings → Members
- View list of all members with roles
- Select member
- Change role (Member ↔ Admin)
- Save changes
Owner role cannot be changed or removed. Transfer ownership before removing the original owner.
- Select member
- Click “Remove Member”
- Confirm removal
- Cannot remove owners
- Cannot remove yourself
- Must have at least one owner
Account Linking
Users can link multiple authentication methods to a single account. Supported combinations:- Email/password + SSO (Okta)
- Email/password + SSO (Azure AD)
- Multiple SSO providers
- Log in with primary method
- Go to Settings → Accounts
- Click “Link Account”
- Sign in with secondary method
- Accounts are linked
- Sign in via SSO
- If email matches existing account
- And auto-linking is enabled for provider
- Accounts automatically linked
- Go to Settings → Accounts
- View linked accounts
- Click “Unlink” on account to remove
- Confirm action
User Deletion
Deleting a user affects their organizations and resources.Deletion Impact
Before deletion, Zerobyte shows the impact: If user is the sole owner of organizations:- Organizations will be deleted
- All organization resources deleted:
- Volumes
- Repositories
- Backup schedules
- SSO providers
- Other members (removed from org)
- Organizations remain intact
- User is removed from memberships
- Resources remain available to other members
Delete User
- Log in as admin
- Go to Settings → Users
- Select user to delete
- Click “Delete User”
- Review deletion impact
- Confirm deletion
Session Management
Session Configuration
- Storage: SQLite database (
sessionsTable) - Encryption: AES-256 using derived secret from
APP_SECRET - Cookie name:
zerobyte-session - Active organization: Stored in session (
activeOrganizationId)
Session Lifecycle
- User logs in → Session created
- Session stored → Database + cookie
- User makes requests → Session validated
- User switches org → Session updated
- User logs out → Session deleted
Session Security
- HttpOnly cookies - JavaScript cannot access session tokens
- Secure cookies - Only sent over HTTPS (when
BASE_URLuses HTTPS) - SameSite: Lax - CSRF protection
- Encrypted storage - Session data encrypted in database
Force Logout
Admins can force users to log out:- Log in as admin
- Go to Settings → Users
- Select user
- Click “Force Logout”
- User’s session is deleted
- User must log in again
Troubleshooting
Cannot Log In
Check BASE_URL:- Check browser settings
- Clear cookies and try again
- Disable browser extensions
- If
BASE_URLuses HTTPS, you must access via HTTPS - Cookies marked
Securewon’t work over HTTP
SSO Login Fails
Validate callback URL:- Check IdP configuration
- Ensure callback URL matches exactly:
- Verify
BASE_URLis set correctly
- Provider ID in callback URL must match
- Provider ID must exist in organization
- Check for typos
Two-Factor Not Working
Time sync issues:- Ensure container timezone is correct (
TZenvironment variable) - Ensure authenticator app has correct time
- TOTP codes are time-sensitive (30-second window)
- Click “Use backup code” on login
- Enter one of your saved backup codes
- Generate new codes after logging in
- Access database directly (advanced)
- Reset 2FA for user
- Contact system administrator
Invalid Trusted Origins
If you see log warnings:- Check
TRUSTED_ORIGINSenvironment variable - Ensure all origins are valid URLs:
- Remove invalid entries
- Restart container
