Skip to main content
Authorization mode provides access control for your DeepWiki-Open instance by requiring users to enter a secret authorization code before generating wikis. This is essential for production deployments, shared environments, or when you want to control who can generate documentation from repositories.

What is Authorization Mode?

Authorization mode is a simple but effective security feature that:

Frontend Protection

Users must enter an authorization code in the web interface

API Security

All API requests must include the authorization code

Resource Control

Prevents unauthorized usage of AI provider quotas

Access Logging

Tracks and logs authentication attempts

When to Use Authorization Mode

Always enable authorization mode in production environments:
  • Public-facing instances
  • Shared hosting environments
  • Corporate deployments
  • Any instance accessible from the internet
Benefits:
  • Prevents unauthorized access to AI providers
  • Controls API usage and costs
  • Maintains audit trail of access
Shared development environments:
  • Team wikis for private repositories
  • Collaborative documentation projects
  • Educational environments
  • Demo instances with controlled access
Benefits:
  • Ensures only authorized team members can generate docs
  • Prevents accidental quota exhaustion
  • Maintains consistent access control
AI provider quota protection:
  • Limited API budgets
  • Pay-per-use providers
  • Rate-limited accounts
  • Enterprise cost control
Benefits:
  • Prevents unexpected charges
  • Controls usage patterns
  • Enables usage tracking per authorization

When NOT to Use Authorization Mode

Authorization mode can be disabled for:
  • Local development instances
  • Personal single-user setups
  • Internal networks with existing security
  • Testing and experimentation environments

Configuration

Environment Variables

Configure authorization mode using these environment variables: Enable or disable authorization mode. Secret authorization code required for access.

Basic Configuration

1

Set Environment Variables

Add to your .env file:
Choose a strong, unique authorization code. Avoid common passwords or easily guessable codes.
2

Restart Services

Authorization mode requires a full restart:
3

Verify Configuration

Check authorization status:
Expected response:
Server logs should show: “Authorization mode: ENABLED”

Advanced Configuration

Frontend Usage

Authorization Code Input

When authorization mode is enabled, users see an authorization code input field:
Authorization Required
This code is required to generate wikis

User Experience Flow

1

User Access

User visits the DeepWiki-Open interface and sees:
  • Normal repository URL input
  • Authorization code field (when mode is enabled)
  • Clear indication that authorization is required
2

Code Entry

User enters the authorization code:
  • Code is masked (password field)
  • Real-time validation (optional)
  • Clear error messages for invalid codes
3

Wiki Generation

After successful authorization:
  • Normal wiki generation flow continues
  • Code is included in API requests automatically
  • User doesn’t need to re-enter code for the session

Frontend Implementation

The frontend automatically detects authorization mode:

API Usage

Including Authorization Codes

All API requests must include the authorization code when mode is enabled:

Authorization Validation Endpoint

Test authorization codes before use:

Security Considerations

Authorization Code Security

Strong authorization codes:
Generation methods:
Secure storage:
  • Store codes in environment variables, not source code
  • Use secrets management in production (AWS Secrets Manager, Azure Key Vault)
  • Restrict file permissions on .env files (chmod 600)
  • Never commit authorization codes to version control
Regular rotation:
Code management:
HTTPS requirement:
Access restrictions:

Attack Prevention

Authorization mode provides basic access control but is not a complete security solution. Consider additional measures:
  • Rate limiting to prevent brute force attacks
  • IP whitelisting for sensitive environments
  • Web Application Firewall (WAF) for production
  • Regular security audits and monitoring
  • Multi-factor authentication for critical deployments
Rate limiting example:

Troubleshooting

Common Issues

Symptoms:
  • “Invalid authorization code” errors
  • Authentication consistently fails
  • API returns 401 status codes
Solutions:
  1. Verify environment variables:
  2. Check code formatting:
  3. Restart services completely:
  4. Test with curl:
Symptoms:
  • Authorization mode enabled but no auth input field
  • Frontend behaves as if authorization is disabled
  • No indication that auth is required
Solutions:
  1. Check API status endpoint:
  2. Verify frontend API connection:
  3. Clear browser cache:
  4. Check Next.js API routes:
Symptoms:
  • Frontend shows auth required but validation fails
  • Network errors in browser console
  • Proxy/forwarding failures
Solutions:
  1. Check SERVER_BASE_URL:
  2. Test direct API access:
  3. Verify port configuration:

Debugging Steps

1

Check Configuration

2

Test API Endpoints

3

Check Logs

4

Frontend Debugging

Production Deployment

Docker Configuration

Kubernetes Deployment

Monitoring and Alerting

Best Practices

Development Workflow

1

Local Development

2

Staging Environment

3

Production Deployment

Team Management

Secure methods for sharing authorization codes:
  1. Encrypted communication:
    • Use encrypted messaging (Signal, encrypted email)
    • Password managers with secure sharing
    • Company secrets management systems
  2. Documentation:
  3. Onboarding process:
    • Include authorization code in new team member setup
    • Document where to find current codes
    • Explain rotation schedule and notifications
Multiple authorization codes for different access levels:
Implementation:

Security Maintenance

1

Regular Code Rotation

2

Access Auditing

3

Security Monitoring

Next Steps

Production Setup

Complete production deployment with authorization mode

API Authentication

Learn about complete API authentication and security

Private Repositories

Configure access to private repositories with tokens

Security Best Practices

Implement comprehensive security measures