Skip to content

Add managed user product line with account-bound licensing and optional activation cards #3

@banbanzhige

Description

@banbanzhige

Problem

Hi, first of all, thank you for building and maintaining Keygate.

The current Desktop / SaaS / Hybrid product models already cover many common licensing scenarios well. While working on my own use case, I found another product pattern that may also be useful for Keygate users.

Some products need Keygate to act as a transparent backend rather than a user-facing customer portal. In these cases, the business application owns the user experience, while Keygate handles accounts, licenses, entitlement history, device activation, and admin operations behind the scenes.

Example scenarios include:

  • desktop or client applications with their own login UI
  • products where purchase should immediately activate entitlement for an account
  • reseller or third-party activation/recharge cards
  • subscription products where renewals add time to an account
  • apps that want Keygate as the license backend without exposing the Keygate Portal to end users

For these cases, license keys alone are not always the best user experience. The product often needs account-bound licensing, managed user credentials, email verification, password reset, and optional activation card redemption.

Proposed solution

I would like to propose a new product type: managed_user.

It would sit alongside the existing product types: desktop / saas / hybrid / managed_user.

The main idea is that managed_user products have product-scoped managed accounts inside Keygate. The end user does not enter the normal Keygate Portal; instead, the business application calls Keygate APIs directly.

The proposed feature set includes:

Product and plan support

  • New product type: managed_user
  • Product-level options:
    • enable/disable managed self-registration
    • require email verification
    • enable/disable activation cards
    • card delivery mode
  • Managed-user plan license types:
    • subscription
    • perpetual
    • trial
    • account_bound
    • activation_card
  • Duration fields:
    • duration value
    • duration unit
    • starts on first use

Managed user account system

  • Product-scoped account registration
  • Product-scoped email uniqueness
  • Product-scoped password hash
  • Email verification
  • Password reset
  • Email change flow
  • Login/logout
  • Current managed user API
  • Admin create/disable/anonymize managed user

Account-bound license grants

  • Admin grant license to an existing managed user
  • API grant by managed user ID, external customer ID, account, or email
  • Idempotent external order handling
  • License duration snapshot from plan
  • Managed entitlement ledger
  • Multiple licenses can stack duration
  • Aggregate entitlement calculation
  • First-device-activation timing support

Device activation

  • Managed-user device activation
  • Verify active device entitlement
  • Deactivate device
  • Activation limit support
  • First activation starts the license timer when enabled
  • License lifecycle events for grant, first use, activation, revoke, and refund

Activation cards

Optional activation card support for managed_user products:

  • Create card batches
  • Export card batches
  • Sell card through API
  • Redeem card as managed user
  • Card expiration before redemption
  • Card revoke
  • Card status tracking: available, sold, redeemed, revoked, expired
  • Optional recoverable encrypted card code storage
  • Card redemption creates an account-bound license and ledger entry
  • Card duration stacks with existing entitlement

Purchase / Stripe flow

  • Managed-user checkout flow
  • License grant on successful purchase
  • Subscription renewal adds new entitlement duration
  • Full refund revokes/refunds the managed license and ledger entry
  • Activation-card plans use inventory/sale/redemption instead of direct checkout license creation

Admin UI

  • Product form support for managed_user
  • Plan form support for managed license types and duration fields
  • Managed user admin page
  • Managed user detail, licenses, events, and aggregate entitlement
  • Admin grant flow
  • Password reset, disable, anonymize actions
  • Activation card batch, inventory, export, sell, and revoke flows

Portal isolation

  • Managed-user products do not appear in the normal customer portal
  • Managed-user licenses do not appear in normal portal license management
  • Managed-user device management is handled through managed APIs instead

Webhooks and audit

  • Audit logs for managed user and license actions
  • Webhook events such as:
    • license.created
    • license.revoked
    • activation_card.batch_created
    • managed_user.created
    • managed_user.disabled
    • managed_user.anonymized

I have a working local implementation for most of this and I am currently testing it end to end before preparing a PR.

Before opening a PR, I wanted to ask whether this direction fits the project’s roadmap and architecture. If you are open to it, I can prepare the PR in smaller reviewable parts, such as:

  1. Data model and product/plan validation
  2. Managed user auth APIs
  3. Managed license grant and entitlement ledger
  4. Device activation flow
  5. Activation card support
  6. Admin UI
  7. Stripe / webhook integration
  8. Documentation and OpenAPI updates

I am happy to adjust naming, API shape, or split the implementation differently if you prefer another direction.

Alternatives considered

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions