mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-26 05:01:11 +01:00
* license: update headers to IBM Corp. * `make proto` * update offset because source file changed Signed-off-by: Ryan Cragun <me@ryan.ec> Co-authored-by: Ryan Cragun <me@ryan.ec>
33 lines
769 B
TypeScript
33 lines
769 B
TypeScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import AuthBase from './base';
|
|
|
|
import type { TokenLoginApiResponse } from 'vault/vault/auth/methods';
|
|
|
|
/**
|
|
* @module Auth::Form::Token
|
|
* see Auth::Base
|
|
* */
|
|
|
|
export default class AuthFormToken extends AuthBase {
|
|
loginFields = [{ name: 'token' }];
|
|
|
|
async loginRequest(formData: { token: string }) {
|
|
const { token } = formData;
|
|
|
|
const { data } = (await this.api.auth.tokenLookUpSelf(
|
|
this.api.buildHeaders({ token })
|
|
)) as TokenLoginApiResponse;
|
|
|
|
// normalize auth data so stored token data has the same keys regardless of auth type
|
|
return this.normalizeAuthResponse(data, {
|
|
authMountPath: '',
|
|
token: data.id,
|
|
ttl: data.ttl,
|
|
});
|
|
}
|
|
}
|