WenPai License Server User Guide: Setting Up Your Own Plugin Licensing Service

Introduction

The WenPai License Server is an open-source, lightweight license management service developed by WenPai. Built with Go and SQLite, it provides license activation capabilities for WordPress plugins, themes, or other digital products. It works seamlessly with the WenPai Updater client plugin to establish a complete commercial plugin distribution and licensing system.

Core Features

  • Creation, validation, activation, and revocation of licenses
  • Activation limits per domain/site
  • Automatic audit log rotation (default retention: 90 days)
  • RESTful API for easy integration
  • Single-binary deployment, Docker-ready

Quick Deployment (Docker)

git clone https://feicode.com/WenPai-org/license-server.git
cd license-server
docker compose up -d

Listens on port :8080 by default; database file is ./data/licenses.db.

Environment Variables

Variable Description
API_KEY Admin API key; if unset, all requests to the /admin endpoints are rejected
DATABASE_PATH Path to the SQLite database file
PORT Service port; defaults to 8080

API Overview

Verify a License

GET /api/v1/licenses/verify?key=LICENSE_KEY&domain=example.com

Activate a License

POST /api/v1/licenses/activate  
Body: {"key":"LICENSE_KEY","domain":"example.com"}

Admin Endpoints (require API_KEY)

POST /api/v1/admin/licenses        # Create a license  
DELETE /api/v1/admin/licenses/{id} # Revoke a license  
GET /api/v1/admin/licenses         # List licenses  

Integration with WPBridge

Enter the License Server URL and API Key in the WPBridge settings. You can then manage licenses directly from the vendor dashboard, enabling automated distribution and activation.

Important Notes

  • Always set a strong API_KEY in production environments
  • HTTPS is strongly recommended
  • Regularly clean up or back up audit logs

Use Cases

  • Licensing for commercial WordPress plugins
  • Site-based licensing for SaaS products
  • Controlled distribution of internal tools

WenPai License Server 是一个实用的授权管理方案。在 WordPress Multisite 环境中部署时,需要注意一些网络架构层面的适配。

网络级授权考量
在 Multisite 网络中,授权验证通常需要在两个层面进行:

  1. 网络级:为整个网络购买一个主许可证,允许所有子站点使用。
  2. 站点级:为每个子站点或特定子站点单独授权。

WenPai License Server 的 domain 参数在 Multisite 下需要明确策略。对于子域名架构,每个子站点(如 site1.example.com)会被视为独立域名。对于子目录架构,主域名(example.com)加上路径可能需要进行特殊处理。

集成建议

  1. 开发一个网络激活的插件,在 网络管理 后台集中管理许可证密钥。
  2. 插件代码应区分验证场景:
    // 示例:网络级验证逻辑
    if (is_multisite()) {
        // 可选项A:使用主站点域名进行网络级验证
        $license_domain = get_site_url(get_main_site_id());
        // 可选项B:为每个子站点单独验证(需存储各站点密钥)
    }
    
  3. 权限管理至关重要。许可证的激活、查看权限应仅限于 Super Admin

部署提醒

  • 在 Docker 部署中,确保 DATABASE_PATH 挂载的卷可持久化。
  • 如果 Multisite 网络规模较大,需关注 /verify/activate API 的调用频率,避免对授权服务器造成压力。
  • 审计日志有助于追踪网络内各子站点的激活行为。

对于具体的部署配置,可以咨询社区内的 @deploy 专家。更多关于多站点架构的讨论,可查看 /c/multisite 分类。