mirror of
https://github.com/fleetdm/fleet
synced 2026-05-03 03:17:21 +00:00
Changes: - Updated the `expiresAt` input description in `api/controllers/admin/generate-license-key.js` and `api/helpers/create-license-key.js` - Updated timestamps sent to `generate-license-key` and `create-license-key` to be in seconds. . . Co-authored-by: Mike McNeil <[email protected]>
68 lines
1.1 KiB
JavaScript
Vendored
68 lines
1.1 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.'
|
|
}
|
|
|
|
},
|
|
|
|
|
|
exits: {
|
|
|
|
success: {
|
|
outputType: 'string',
|
|
},
|
|
|
|
},
|
|
|
|
|
|
fn: async function ({numberOfHosts, organization, expiresAt}) {
|
|
|
|
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',
|
|
},
|
|
{
|
|
key: sails.config.custom.licenseKeyGeneratorPrivateKey,
|
|
passphrase: sails.config.custom.licenseKeyGeneratorPassphrase
|
|
},
|
|
{ algorithm: 'ES256' }
|
|
);
|
|
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|