mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
ab504d766a
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.
76 lines
1.4 KiB
JavaScript
Vendored
76 lines
1.4 KiB
JavaScript
Vendored
module.exports = {
|
|
|
|
|
|
friendlyName: 'Create license key',
|
|
|
|
|
|
description: '',
|
|
|
|
|
|
inputs: {
|
|
|
|
numberOfHosts: {
|
|
type: 'number',
|
|
required: true,
|
|
},
|
|
|
|
organization: {
|
|
type: 'string',
|
|
required: true,
|
|
},
|
|
|
|
expiresAt: {
|
|
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.',
|
|
}
|
|
|
|
},
|
|
|
|
|
|
exits: {
|
|
|
|
success: {
|
|
outputType: 'string',
|
|
},
|
|
|
|
},
|
|
|
|
|
|
fn: async function ({numberOfHosts, organization, expiresAt, partnerName}) {
|
|
|
|
let jwt = require('jsonwebtoken');
|
|
|
|
let expirationTimestampInSeconds = (expiresAt / 1000);
|
|
let token = jwt.sign(
|
|
{
|
|
iss: 'Fleet Device Management Inc.',
|
|
exp: expirationTimestampInSeconds,
|
|
sub: organization,
|
|
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,
|
|
passphrase: sails.config.custom.licenseKeyGeneratorPassphrase
|
|
},
|
|
{ algorithm: 'ES256' }
|
|
);
|
|
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|