IMPORTANT NOTE: Source License is still in Alpha. There WILL be issues, missing functionality, missing documentation, etc. Please let us know of any and all issues via a Issue!
A comprehensive Ruby/Sinatra-based software licensing management system with integrated payment processing, secure API endpoints, and enterprise-grade features for software vendors.
Source License is a complete solution for independent software vendors who need to sell, manage, and validate software licenses. Built with Ruby and Sinatra, it provides a robust platform for handling everything from product sales to license validation APIs that can be integrated into your software products.
- Product Management: Create and manage software products with pricing, descriptions, and download files
- Shopping Cart & Checkout: Full e-commerce flow with cart functionality and secure checkout
- Payment Processing: Integrated Stripe and PayPal support with webhook handling
- Order Management: Complete order tracking and fulfillment system
- Cryptographically Secure License Keys: Multiple formats (XXXX-XXXX-XXXX-XXXX, UUID, custom)
- Activation Control: Limit installations per license with machine fingerprinting
- License Types: Support for perpetual, subscription, and trial licenses
- License Operations: Suspend, revoke, extend, transfer, and batch generate licenses
- Validation API: REST endpoints for real-time license verification in your software
- Dashboard: Real-time statistics and system overview
- Product Management: Create products with pricing, trial periods, and download files
- License Administration: Generate, manage, and monitor all licenses
- Customer Management: Track users, orders, and support requests
- Order Processing: View, manage, and fulfill customer orders
- Reports & Analytics: Detailed insights into sales and license usage
- Template System: ERB templates with extensive helper functions
- Live Customization: Admin interface for colors, branding, and content
- Responsive Design: Bootstrap-based responsive layout
- Multi-language Ready: Template structure supports internationalization
- JWT Authentication: Secure API access with token-based auth
- Admin Role Management: Granular permissions and multi-admin support
- Security Middleware: CSRF protection, rate limiting, and security headers
- Audit Logging: Comprehensive logging of all license operations
- Database Security: Sequel ORM with prepared statements prevents SQL injection
- License Validation: Real-time license verification endpoints
- License Activation: Machine-based activation and deactivation
- Order Processing: Complete API for order creation and management
- Webhook Support: Stripe and PayPal webhook handling
- Settings Management: API for configuration management
- Recurring Billing: Automatic subscription renewals
- Grace Periods: Handle failed payments gracefully
- Trial Management: Free trial periods with automatic conversion
- Billing History: Complete payment and billing tracking
- Ruby 3.4.4 or higher
- Database: MySQL, PostgreSQL, or SQLite (SQLite should not be used in production!!!)
- Git for cloning the repository
-
Clone the repository
git clone https://github.com/PixelRidge-Softworks/Source-License.git cd Source-License
-
Run the Install Script for your platform
.\install.ps1 (for windows) ./install.sh (for linux/macos)
-
Run the deployment script for your platform
.\deploy.ps1 (for windows) ./deploy.sh (for linux/macos) The launcher will automatically: - β Verify Ruby version compatibility - π¦ Install required gems via Bundler - ποΈ Set up and migrate the database - βοΈ Create configuration files from templates - π Launch the application server
-
Access the application
- Main Website: http://localhost:4567
- Admin Panel: http://localhost:4567/admin
- License Lookup: http://localhost:4567/my-licenses
The launcher creates a .env
file from the template. Configure these essential settings:
# Application Settings
APP_ENV=development
APP_SECRET=your_secret_key_here_change_this_in_production
APP_HOST=localhost
APP_PORT=4567
# Security Settings
JWT_SECRET=your_jwt_secret_here_change_in_production
SECURITY_WEBHOOK_URL=https://your-security-monitoring-service.com/webhook
# Production Configuration
APP_VERSION=1.0.0
ALLOWED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
# Logging & Monitoring
LOG_LEVEL=info
LOG_FORMAT=json
ERROR_TRACKING_DSN=https://your-sentry-dsn@sentry.io/project
# Performance & Caching
REDIS_URL=redis://localhost:6379/0
ENABLE_CACHING=true
CACHE_TTL=3600
# SSL/TLS Configuration
FORCE_SSL=true
HSTS_MAX_AGE=31536000
# Database Connection Pool
DB_POOL_SIZE=10
DB_TIMEOUT=5000
# Rate Limiting
RATE_LIMIT_REQUESTS_PER_HOUR=1000
RATE_LIMIT_ADMIN_REQUESTS_PER_HOUR=100
# Session Configuration
SESSION_TIMEOUT=28800
SESSION_ROTATION_INTERVAL=7200
# Database Configuration
# Choose one: mysql, postgresql, or sqlite
# Option 1: MySQL (requires MySQL server)
DATABASE_ADAPTER=mysql
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_NAME=source_license
DATABASE_USER=root
DATABASE_PASSWORD=your_password
# Option 2: PostgreSQL (requires PostgreSQL server)
# DATABASE_ADAPTER=postgresql
# DATABASE_HOST=localhost
# DATABASE_PORT=5432
# DATABASE_NAME=source_license
# DATABASE_USER=postgres
# DATABASE_PASSWORD=your_password
# Option 3: SQLite (ONLY for development - no server required)
# DATABASE_ADAPTER=sqlite
# DATABASE_NAME=source_license.db
# Admin Settings
ADMIN_EMAIL=admin@yourdomain.com
ADMIN_PASSWORD=change_this_secure_password
# Payment Gateway Settings
# Stripe
STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
# PayPal
PAYPAL_CLIENT_ID=your_paypal_client_id
PAYPAL_CLIENT_SECRET=your_paypal_client_secret
PAYPAL_ENVIRONMENT=sandbox
# Email Configuration (for license delivery)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your_email@gmail.com
SMTP_PASSWORD=your_app_password
SMTP_TLS=true
# License Settings
# THESE SETTINGS ARE DEPRECATED
LICENSE_VALIDITY_DAYS=365
MAX_ACTIVATIONS_PER_LICENSE=3
# File Storage
DOWNLOADS_PATH=./downloads
LICENSES_PATH=./licenses
Source-License/
βββ app.rb # Main application entry point
βββ config.ru # Rack configuration for deployment
βββ launch.rb # Cross-platform launcher script
βββ Gemfile # Ruby dependencies
βββ .env.example # Environment configuration template
β
βββ lib/ # Core application logic
β βββ models.rb # Database models (User, Product, License, Order, etc.)
β βββ license_generator.rb # License creation and management
β βββ payment_processor.rb # Stripe/PayPal integration
β βββ database.rb # Database configuration and migrations
β βββ auth.rb # Authentication helpers
β βββ security.rb # Security middleware and utilities
β βββ helpers.rb # Template helpers and utilities
β βββ customization.rb # Theme and branding management
β βββ settings_manager.rb # Configuration management
β βββ controllers/ # Modular controller architecture
β βββ public_controller.rb # Public website routes
β βββ admin_controller.rb # Admin interface routes
β βββ api_controller.rb # REST API endpoints
β βββ admin/ # Admin sub-controllers
β
βββ views/ # ERB template files
β βββ layouts/ # Layout templates
β βββ partials/ # Reusable components
β βββ admin/ # Admin interface templates
β βββ users/ # User account templates
β βββ licenses/ # License management templates
β βββ errors/ # Error page templates
β
βββ test/ # Comprehensive test suite
β βββ app_test.rb # Application integration tests
β βββ models_test.rb # Database model tests
β βββ auth_test.rb # Authentication tests
β βββ factories.rb # Test data factories
β
βββ config/ # Configuration files
βββ downloads/ # Product download files (auto-created)
βββ public/ # Static assets (auto-created)
Core Models:
User
- Customer accounts with license managementAdmin
- Administrative users with role-based permissionsProduct
- Software products for sale with pricing and configurationOrder
- Customer purchases with payment trackingOrderItem
- Individual items within ordersLicense
- Generated software licenses with activation trackingLicenseActivation
- Machine-specific activation recordsSubscription
- Recurring billing for subscription products
The application uses a modular controller architecture:
- PublicController: Homepage, product pages, cart, checkout
- AdminController: Admin dashboard, settings, management interfaces
- ApiController: REST API endpoints for license validation and management
- UserAuthController: User registration, login, password reset
- Admin Namespace: Specialized admin controllers for products, licenses, features
SQLite (ONLY for Development)
DATABASE_ADAPTER=sqlite
DATABASE_NAME=source_license.db
MySQL
DATABASE_ADAPTER=mysql
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_NAME=source_license
DATABASE_USER=your_user
DATABASE_PASSWORD=your_password
PostgreSQL
DATABASE_ADAPTER=postgresql
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_NAME=source_license
DATABASE_USER=postgres
DATABASE_PASSWORD=your_password
Stripe Configuration
- Create account at stripe.com
- Get API keys from dashboard
- Configure webhook endpoint:
your-domain.com/api/webhook/stripe
PayPal Configuration
- Create developer account at developer.paypal.com
- Create application for API credentials
- Set environment (sandbox/production)
Supports SMTP for license delivery and notifications:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your_email@gmail.com
SMTP_PASSWORD=your_app_password
SMTP_TLS=true
Obtain JWT token for API access:
curl -X POST http://localhost:4567/api/auth \
-H "Content-Type: application/json" \
-d '{"email": "admin@example.com", "password": "password"}'
Validate a license key:
curl -X GET http://localhost:4567/api/license/XXXX-XXXX-XXXX-XXXX/validate
Response:
{
"valid": true,
"status": "active",
"product": "My Software",
"expires_at": "2025-12-31T23:59:59Z",
"activations_used": 1,
"max_activations": 3
}
Activate license on a machine:
curl -X POST http://localhost:4567/api/license/XXXX-XXXX-XXXX-XXXX/activate \
-H "Content-Type: application/json" \
-d '{"machine_fingerprint": "unique_machine_id"}'
Method | Endpoint | Description |
---|---|---|
POST | /api/auth |
Authenticate and get JWT token |
GET | /api/products |
List active products |
POST | /api/orders |
Create new order |
GET | /api/orders/:id |
Get order details |
POST | /api/orders/free |
Process free orders |
GET | /api/license/:key/validate |
Validate license key |
POST | /api/license/:key/activate |
Activate license |
POST | /api/webhook/:provider |
Payment webhooks |
GET | /api/settings/:category |
Get configuration settings |
PUT | /api/settings/:category/:key |
Update setting |
The application includes a powerful customization system accessible via the admin panel:
- Branding: Site name, logo, colors, fonts
- Content: Homepage text, product descriptions, legal pages
- Layout: Template structure and styling
- Themes: Pre-built color schemes and layouts
Templates include extensive helper functions:
<!-- Currency formatting -->
<%= format_currency(29.99) %> <!-- Output: $29.99 -->
<!-- Date formatting -->
<%= format_date(Time.now, :long) %> <!-- Output: January 19, 2025 -->
<!-- Status badges -->
<%= status_badge('active') %> <!-- Output: <span class="badge badge-success">Active</span> -->
<!-- Custom buttons -->
<%= button 'Buy Now', class: 'btn btn-primary btn-lg' %>
<!-- Cards with styling -->
<%= card 'Product Info', class: 'border-primary' do %>
<p>Product details here...</p>
<% end %>
For developers, templates can be directly modified:
- Layouts:
views/layouts/main_layout.erb
,views/layouts/admin_layout.erb
- Partials:
views/partials/_navigation.erb
,views/partials/_footer.erb
- Styles: Customize CSS via admin panel or edit templates directly
ruby launch.rb
-
Edit .env
-
Run Install Script
.\install.ps1 (windows) ./install.sh (linux/macos)
-
Run deployment script
.\deploy.ps1 (windows) ./deploy.sh (linux/macos)
APP_ENV=production
FORCE_SSL=true
HSTS_MAX_AGE=31536000
SESSION_TIMEOUT=28800
RATE_LIMIT_REQUESTS_PER_HOUR=1000
-
Install dependencies
bundle install
-
Start development server
ruby launch.rb
The project includes comprehensive code quality tools:
- RuboCop: Ruby style guide enforcement
- RuboCop Extensions: Minitest, Performance, Sequel specific rules
- Test Coverage: SimpleCov with console reporting
# Run style checks
bundle exec rubocop
# Auto-fix style issues
bundle exec rubocop -A
- Sell desktop applications with license management
- Distribute plugins and extensions with activation limits
- Manage trial periods and subscription renewals
- Track usage analytics and license compliance
- License validation for client-side applications
- Machine-based activation for offline software
- Subscription management with automatic renewals
- Multi-tier licensing with different activation limits
- Student/teacher license management
- Institution-wide licensing
- Temporary access and trial periods
- Bulk license generation for schools
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Check code style (
bundle exec rubocop
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the GNU General Public License v2.0 - see the LICENSE file for details.
- Issues: GitHub Issues
- Documentation: Project Wiki
- Discussions: GitHub Discussions
- β Complete license management system
- β Stripe and PayPal integration
- β REST API with JWT authentication
- β Admin dashboard and user management
- β Cross-platform launcher
- β Multiple database support
- π Advanced analytics and reporting
- π Multi-language support
- π± Mobile-responsive admin interface
- π§ Plugin system for extensions
- π Advanced subscription management
- π International payment methods
Built with β€οΈ using Ruby and Sinatra by the PixelRidge Softworks team
Source License - Empowering software vendors with professional licensing solutions