MCPcopy Index your code
hub / github.com/scality/cloudserver / issueCredentials

Function issueCredentials

lib/management/credentials.js:28–55  ·  view source on GitHub ↗
(managementEndpoint, instanceId, log, callback)

Source from the content-addressed store, hash-verified

26}
27
28function issueCredentials(managementEndpoint, instanceId, log, callback) {
29 log.info('registering with API to get token');
30
31 const keyPair = forge.pki.rsa.generateKeyPair({ bits: 2048, e: 0x10001 });
32 const privateKey = forge.pki.privateKeyToPem(keyPair.privateKey);
33 const publicKey = forge.pki.publicKeyToPem(keyPair.publicKey);
34
35 const postData = {
36 publicKey,
37 };
38
39 request.post(`${managementEndpoint}/${instanceId}/register`,
40 { body: postData, json: true }, (error, response, body) => {
41 if (error) {
42 return callback(error);
43 }
44 if (response.statusCode !== 201) {
45 log.error('could not register instance', {
46 statusCode: response.statusCode,
47 });
48 return callback(arsenal.errors.InternalError);
49 }
50 /* eslint-disable no-param-reassign */
51 body.privateKey = privateKey;
52 /* eslint-enable no-param-reassign */
53 return callback(null, body);
54 });
55}
56
57function confirmInstanceCredentials(
58 managementEndpoint, instanceId, creds, log, callback) {

Callers 1

Calls 2

infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected