MCPcopy
hub / github.com/scality/cloudserver / _authenticate

Method _authenticate

lib/auth/streamingV4/V4Transform.js:147–176  ·  view source on GitHub ↗

* Build the stringToSign and authenticate the chunk * @param {Buffer} dataToSend - chunk sent from _transform or null * if last chunk without data * @param {function} done - callback to _transform * @return {function} executes callback with err if applicable

(dataToSend, done)

Source from the content-addressed store, hash-verified

145 * @return {function} executes callback with err if applicable
146 */
147 _authenticate(dataToSend, done) {
148 // use prior sig to construct new string to sign
149 const stringToSign = constructChunkStringToSign(this.timestamp,
150 this.credentialScope, this.lastSignature, dataToSend);
151 this.log.trace('constructed chunk string to sign',
152 { stringToSign });
153 // once used prior sig to construct string to sign, reassign
154 // lastSignature to current signature
155 this.lastSignature = this.currentSignature;
156 const vaultParams = {
157 log: this.log,
158 data: {
159 accessKey: this.accessKey,
160 signatureFromRequest: this.currentSignature,
161 region: this.region,
162 scopeDate: this.scopeDate,
163 stringToSign,
164 timestamp: this.timestamp,
165 credentialScope: this.credentialScope,
166 },
167 };
168 return vault.authenticateV4Request(vaultParams, null, {}, err => {
169 if (err) {
170 this.log.trace('err from vault on streaming v4 auth',
171 { error: err, paramsSentToVault: vaultParams.data });
172 return done(err);
173 }
174 return done();
175 });
176 }
177
178
179 /**

Callers 1

_transformMethod · 0.95

Calls 2

traceMethod · 0.80

Tested by

no test coverage detected