MCPcopy Create free account
hub / github.com/bytebase/bytebase / CreateLicense

Method CreateLicense

backend/enterprise/license.go:427–444  ·  view source on GitHub ↗

CreateLicense signs a new license JWT from business params. Only available when private key is configured (SaaS mode). Handles JWT plumbing (issuer, audience, kid) internally.

(params *LicenseParams)

Source from the content-addressed store, hash-verified

425// Only available when private key is configured (SaaS mode).
426// Handles JWT plumbing (issuer, audience, kid) internally.
427func (s *LicenseService) CreateLicense(params *LicenseParams) (string, error) {
428 if s.config.PrivateKey == nil {
429 return "", errors.New("license signing not available: private key not configured")
430 }
431
432 c := newLicenseClaims(params)
433 c.Issuer = s.config.Issuer
434 c.Audience = jwt.ClaimStrings{s.config.Audience}
435 c.IssuedAt = jwt.NewNumericDate(time.Now())
436 c.Subject = params.WorkspaceID
437 if !params.ExpiresAt.IsZero() {
438 c.ExpiresAt = jwt.NewNumericDate(params.ExpiresAt)
439 }
440
441 token := jwt.NewWithClaims(jwt.SigningMethodRS256, c)
442 token.Header["kid"] = s.config.Version
443 return token.SignedString(s.config.PrivateKey)
444}
445
446// InvalidateCache removes the cached subscription for a workspace,
447// forcing the next LoadSubscription call to reload from the database.

Callers 1

updateLicenseMethod · 0.80

Calls 1

newLicenseClaimsFunction · 0.85

Tested by

no test coverage detected