Authentication Menu
After entering your DefDrive URL, you’re presented with an interactive menu:Use ↑ and ↓ arrow keys to navigate between options. The
> indicator shows your current selection.Signup Flow
Create a new DefDrive account through the CLI.Step 1: Select Signup
Navigate to “Signup” in the menu and press Enter.Step 2: Enter Account Details
The CLI prompts for five fields in sequence:Password
The password is displayed as plain text during entry in the current CLI implementation.
Step 3: Review and Confirm
After entering all fields, the CLI displays a summary:Type 'confirm' - Proceed with signup
Type 'confirm' - Proceed with signup
The CLI validates that passwords match, then sends a signup request to the server.Password Validation:Successful Signup:The CLI automatically:Common errors:
- If passwords don’t match, you’re prompted to re-enter from the password field:
- Creates your account via
/api/signup - Logs you in via
/api/login - Saves token to
.defdrive_credentials
- Username already taken
- Invalid email format
- Server connection issues
Type 'edit' - Modify entries
Type 'edit' - Modify entries
The CLI enters edit mode, allowing you to update any field:The current value is pre-populated. You can:
- Edit the existing value
- Clear it and enter a new value
- Press Enter to keep it unchanged
- Name
- Username
- Password
- Confirm Password
Signup API Request
When you confirm signup, the CLI sends a POST request to/api/signup:
Login Flow
Authenticate with an existing DefDrive account.Step 1: Select Login
Navigate to “Login” in the menu and press Enter.Step 2: Enter Credentials
The CLI prompts for two fields:Step 3: Review and Confirm
The CLI displays your credentials:Type 'confirm' - Proceed with login
Type 'confirm' - Proceed with login
The CLI sends a login request to the server.Successful Login:The CLI:Common errors:
- Receives authentication token from
/api/login - Saves token and username to
.defdrive_credentials - Completes the setup
- Invalid username or password
- Account not found
- Server connection issues
Type 'edit' - Modify credentials
Type 'edit' - Modify credentials
The CLI enters edit mode:The current value is pre-populated. You can edit it and press Enter.After modifying username, you’re prompted to modify password:After both fields, you return to the confirmation screen.
Login API Request
When you confirm login, the CLI sends a POST request to/api/login:
.defdrive_credentials for future use.
Edit Mode Details
Both signup and login flows support edit mode for correcting mistakes before submission.How Edit Mode Works
Cycle through fields
The CLI prompts you to modify each field in order:
- Signup: name → email → username → password → confirm_password
- Login: username → password
Pre-populated values
Each field shows your previous entry, which you can:
- Edit using backspace and typing
- Navigate with ← → arrow keys
- Press Enter to keep unchanged and move to next field
Edit Mode Flow States
The CLI uses internal step tracking for edit mode:| Flow | Confirmation Step | Edit Mode Step |
|---|---|---|
| Signup | Step 5 | Step 7 |
| Login | Step 6 | Step 8 |
Existing Configuration Flow
If you’ve previously authenticated, the CLI detects your saved credentials on startup.Confirmation Prompt
Type 'yes' - Use existing config
Type 'yes' - Use existing config
Type 'no' - Reset configuration
Type 'no' - Reset configuration
Input Controls
During any text input field, you can use:| Key | Action |
|---|---|
| Letters/Numbers | Type characters |
| Backspace | Delete character before cursor |
| ← | Move cursor left |
| → | Move cursor right |
| Enter | Confirm input and continue |
| q or Ctrl+C | Quit CLI |
| in the input field:
Error Handling
The CLI handles various error scenarios:Password Mismatch (Signup)
Password Mismatch (Signup)
If password and confirm_password don’t match:You’re returned to the password field (step 3 of signup input) to re-enter both passwords.
Server Connection Failure
Server Connection Failure
If the CLI can’t reach the DefDrive server:orVerify:
- The URL is correct
- The server is running
- Network connectivity
Authentication Rejected
Authentication Rejected
If the server rejects your credentials:orThe server’s error message is displayed. Common issues:
- Username already taken (signup)
- Invalid credentials (login)
- Email format invalid (signup)
Invalid Response Format
Invalid Response Format
If the server returns an unexpected response:This indicates a server-side issue or API version mismatch.
Complete Flow Diagram
Authentication Source Code
Key functions incli/main.go:
Security Considerations
Important Security Notes:
- Password Visibility: Passwords are displayed as plain text during input in the TUI. Consider implementing masked input for production use.
-
Token Storage: Authentication tokens are stored in plain text in
.defdrive_credentials. Restrict file permissions: - HTTPS Required: Always use HTTPS URLs for production DefDrive instances to encrypt credentials in transit.
-
Credential File: Add
.defdrive_credentialsto.gitignoreto avoid committing tokens to version control.
Next Steps
Configuration
Learn more about credential storage and management
Introduction
Return to the CLI overview