User authentication
Email and password sign-in
Gitflare implements email and password authentication with the following features:Email validation
Validates email format before accepting sign-in attempts
Password requirements
Minimum 8 characters required for all passwords
Session management
Automatic session creation with secure cookies
No email verification
Currently configured without email verification for faster onboarding
/login to sign in with your credentials.
Sign-up flow
New users can create accounts at/signup by providing:
- Email address (must be unique)
- Password (minimum 8 characters)
- Display name
- Username (unique identifier for repository ownership)
Session handling
Better Auth manages sessions with:- Secure cookies: Uses secure cookie flags in production
- Session tokens: Unique tokens for each session
- Expiration tracking: Automatic session expiry with
expiresAttimestamp - Device information: Captures IP address and user agent for security
- User association: Links sessions to user accounts with cascade deletion
User accounts
Each user account in Gitflare includes:Username system
Gitflare includes Better Auth’s username plugin, which:- Ensures usernames are unique across the platform
- Links repositories to user accounts via username
- Prevents username changes after account creation
- Uses usernames in repository URLs (
/$username/$repo)
Personal Access Tokens (PATs)
Personal Access Tokens serve as passwords for Git operations over HTTPS. They’re implemented using Better Auth’s API key plugin.Creating a PAT
Navigate to Settings > Personal Access Tokens to create a new token:- Click “Generate New Token”
- Enter a descriptive name (3-50 characters)
- Click “Generate Token”
- Copy the token immediately - you won’t see it again
gvx_ for easy identification.
Token structure
Using PATs for Git operations
When pushing or pulling private repositories, provide your PAT as the password:Token authentication flow
When you perform a Git operation, Gitflare:- Extracts credentials from the HTTP Basic Auth header
- Verifies the token matches the repository owner’s username
- Validates the token using Better Auth’s
verifyApiKeyAPI - Checks repository ownership and permissions
- Allows or denies the operation based on these checks
Token management
From the Personal Access Tokens page, you can:View active tokens
See all your tokens with names, creation dates, and last usage
Delete tokens
Revoke tokens you no longer need
Track usage
Monitor when each token was last used
Identify tokens
Use descriptive names to remember each token’s purpose
Token security
Gitflare implements several security measures for PATs:- Tokens are hashed before storage
- Only the first few characters (
start) are shown in the UI - Tokens can be individually revoked at any time
- Failed authentication attempts are logged
- Rate limiting can be enabled per token (currently disabled)
Git authentication rules
Gitflare applies different authentication requirements based on the operation and repository visibility:Pull operations (clone, fetch, pull)
- Public repositories: No authentication required - anyone can read
- Private repositories: Requires valid PAT from repository owner
Push operations
- All repositories: Authentication always required
- Ownership check: Only the repository owner can push
- Token validation: Must use valid, non-expired PAT
verifyAuth function which:
- Checks if the repository exists
- Determines if authentication is needed based on operation and visibility
- Verifies the provided token (if any)
- Validates ownership for write operations
Better Auth configuration
Gitflare’s Better Auth setup includes:- Integrates with Cloudflare D1 via Drizzle
- Enables email/password authentication
- Uses secure cookies in production
- Supports username-based routing
- Provides API key functionality for Git auth
- Works seamlessly with TanStack Start
Profile management
From Settings > Profile, you can update:- Display name: Change how your name appears
- Profile image: Automatically generated avatar based on username
- Username (used in repository URLs)
- Email address (account identifier)
Session security
Better Auth tracks session metadata for security:- IP address of the connection
- User agent string (browser/client info)
- Session creation and update times
- Explicit expiration timestamps