Website: Update admin license generator (#13101)

Closes: https://github.com/fleetdm/confidential/issues/3230

Changes:
- Added a new (optional) input to the admin license key generator:
`partnerName`.
- Renamed `admin/generate-license-key.js` to
`admin/build-license-key.js`, updated routes and regenerated
`cloud.setup.js`
- Updated the create license key helper to add a `partner` field to the
generated license key if `partnerName` is provided.
This commit is contained in:
Eric
2023-08-04 14:48:29 -05:00
committed by GitHub
parent 06319f7453
commit ab504d766a
6 changed files with 28 additions and 9 deletions
@@ -1,10 +1,10 @@
module.exports = {
friendlyName: 'Generate license key',// FUTURE: Rename this to avoid confusion w/ generators. For example: 'Build license key'
friendlyName: 'Build license key',
description: 'Generate and return a Fleet Premium license key.',
description: 'Build and return a Fleet Premium license key.',
inputs: {
@@ -22,6 +22,11 @@ module.exports = {
type: 'number',
required: true,
description: 'A JS timestamp representing when this license will expire.',
},
partnerName: {
type: 'string',
description: 'The name of the partner that will be reselling the generated license.',
}
},
@@ -34,12 +39,13 @@ module.exports = {
},
fn: async function ({numberOfHosts, organization, expiresAt}) {
fn: async function ({numberOfHosts, organization, expiresAt, partnerName}) {
let licenseKey = await sails.helpers.createLicenseKey.with({
numberOfHosts: numberOfHosts,
organization: organization,
expiresAt: expiresAt
expiresAt: expiresAt,
partnerName: partnerName,
});
return licenseKey;
+8 -1
View File
@@ -23,6 +23,12 @@ module.exports = {
type: 'number',
required: true,
description: 'A JS timestamp representing when this license will expire.'
},
partnerName: {
type: 'string',
description: 'The name of the partner who will be reselling this genereated license.',
extendedDescription: 'This input is only used by the admin license generator tool.',
}
},
@@ -37,7 +43,7 @@ module.exports = {
},
fn: async function ({numberOfHosts, organization, expiresAt}) {
fn: async function ({numberOfHosts, organization, expiresAt, partnerName}) {
let jwt = require('jsonwebtoken');
@@ -50,6 +56,7 @@ module.exports = {
devices: numberOfHosts,
note: 'Created with Fleet License key dispenser',
tier: 'premium',
partner: partnerName // If this value is undefined, it will not be included in the generated token.
},
{
key: sails.config.custom.licenseKeyGeneratorPrivateKey,