README
¶
AuthSome CLI Tool
The AuthSome CLI tool provides comprehensive management capabilities for the AuthSome authentication framework. It includes commands for database migrations, code generation, data seeding, organization management, user management, and configuration management.
Installation
Build the CLI tool from source:
go build -o authsome ./cmd/authsome
Or install it directly:
go install github.com/xraph/authsome/cmd/authsome@latest
Global Flags
--config string: Config file (default is $HOME/.authsome.yaml)--verbose, -v: Verbose output--help, -h: Help for any command--version: Show version information
Commands Overview
Database Migrations
Manage database schema migrations:
# Run pending migrations
authsome migrate up
# Rollback the last migration
authsome migrate down
# Show migration status
authsome migrate status
# Reset database (drop all tables and re-run migrations)
authsome migrate reset --confirm
Code Generation
Generate keys, configurations, and boilerplate code:
# Generate RSA key pair for JWT/OIDC
authsome generate keys --output ./keys
# Generate sample configuration file
authsome generate config --mode standalone --output authsome.yaml
authsome generate config --mode saas --output authsome-saas.yaml
# Generate cryptographically secure secret
authsome generate secret
authsome generate secret --length 64
Database Seeding
Seed the database with test data for development:
# Seed basic test data (apps, users, roles)
authsome seed basic
# Seed test users
authsome seed users --count 50 --app app_id_here
# Seed test apps
authsome seed apps --count 10
# Clear all seeded data
authsome seed clear --confirm
App Management
Manage platform-level apps (tenants):
# List all apps
authsome app list
# Create a new app
authsome app create --name "Acme Corp" --slug "acme"
# Show app details
authsome app show app_id_here
# Delete an app
authsome app delete app_id_here --confirm
# List app members
authsome app members app_id_here
# Add member to app
authsome app add-member app_id_here user_id_here --role admin
# Remove member from app
authsome app remove-member app_id_here user_id_here
User Management
Manage users across apps:
# List all users
authsome user list
# List users in specific app
authsome user list --app app_id_here
# Create a new user
authsome user create --email [email protected] --password password123 --app app_id_here --role member
# Show user details
authsome user show user_id_here
# Delete a user
authsome user delete user_id_here --confirm
# Update user password
authsome user password user_id_here --password newpassword123
# Verify user email
authsome user verify user_id_here
Configuration Management
Manage and validate configuration files:
# Validate configuration file
authsome config validate authsome.yaml
# Show current configuration
authsome config show authsome.yaml
# Initialize new configuration
authsome config init --mode standalone --output authsome.yaml
authsome config init --mode saas --output authsome-saas.yaml
Configuration File Examples
Standalone Mode
# AuthSome Standalone Configuration
mode: standalone
database:
url: "authsome.db"
server:
host: "localhost"
port: 8080
cors:
enabled: true
origins: ["http://localhost:3000"]
session:
secret: "your-session-secret-here"
maxAge: 86400
secure: false
sameSite: "lax"
plugins:
username:
enabled: true
twofa:
enabled: true
issuer: "YourApp"
SaaS Mode
# AuthSome SaaS Configuration
mode: saas
database:
url: "postgres://user:password@localhost/authsome?sslmode=disable"
server:
host: "0.0.0.0"
port: 8080
session:
secret: "your-session-secret-here"
maxAge: 86400
secure: true
sameSite: "strict"
organizations:
enabled: true
allowCreation: true
plugins:
username:
enabled: true
oauth:
enabled: true
providers:
google:
clientId: "your-google-client-id"
clientSecret: "your-google-client-secret"
Common Workflows
Development Setup
-
Generate configuration:
authsome generate config --mode standalone --output authsome.yaml -
Run migrations:
authsome migrate up -
Seed test data:
authsome seed basic
Production Deployment
-
Generate secure secrets:
authsome generate secret --length 64 authsome generate keys --output ./keys -
Validate configuration:
authsome config validate --file authsome.yaml -
Run migrations:
authsome migrate up
User Management
-
Create app:
authsome app create --name "My Company" --slug "mycompany" -
Create admin user:
authsome user create --email [email protected] --password securepassword --app app_id --role admin -
Add additional user to app:
authsome app add-member app_id user_id --role admin
Database Support
The CLI tool supports multiple database backends:
- SQLite: Default for development (
authsome.db) - PostgreSQL: Production recommended (
postgres://...) - MySQL: Alternative option (
mysql://...)
Security Considerations
- Secrets: Always use strong, randomly generated secrets in production
- Database: Use proper database credentials and SSL connections
- HTTPS: Enable secure cookies and HTTPS in production
- Rate Limiting: Configure appropriate rate limits for your use case
Troubleshooting
Common Issues
- Database connection errors: Check database URL and credentials
- Migration failures: Ensure database is accessible and has proper permissions
- Permission errors: Run with appropriate user permissions for file operations
Debug Mode
Use the --verbose flag for detailed output:
authsome --verbose migrate up
Environment Variables
The CLI tool respects these environment variables:
AUTHSOME_CONFIG: Path to configuration fileAUTHSOME_DATABASE_URL: Database connection stringAUTHSOME_LOG_LEVEL: Logging level (debug, info, warn, error)
Contributing
When adding new CLI commands:
- Create command file in
cmd/authsome/ - Follow the existing patterns for cobra commands
- Add comprehensive help text and examples
- Update this documentation
License
This CLI tool is part of the AuthSome project and follows the same license terms.
Documentation
¶
There is no documentation for this package.