mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 20:36:26 +02:00
* add cert auth method to ui * add test coverage * add changelog Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
43 lines
1002 B
TypeScript
43 lines
1002 B
TypeScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import AuthBase from './base';
|
|
|
|
import type { CertLoginApiResponse } from 'vault/vault/auth/methods';
|
|
|
|
/**
|
|
* @module Auth::Form::Cert
|
|
* see Auth::Base
|
|
* */
|
|
|
|
export default class AuthFormCert extends AuthBase {
|
|
loginFields = [
|
|
{
|
|
name: 'name',
|
|
label: 'Role name',
|
|
helperText: 'Leave blank to match any certificate role.',
|
|
},
|
|
];
|
|
|
|
async loginRequest(formData: { name: string; path: string }) {
|
|
const { path, name } = formData;
|
|
|
|
const { auth } = (await this.api.auth.certLogin(path, {
|
|
name,
|
|
})) as CertLoginApiResponse;
|
|
|
|
const { cert_name, common_name } = auth?.metadata || {};
|
|
const displayName =
|
|
cert_name && common_name ? `${cert_name}/${common_name}` : cert_name || common_name || '';
|
|
|
|
return this.normalizeAuthResponse(auth, {
|
|
authMountPath: path,
|
|
displayName,
|
|
token: auth.client_token,
|
|
ttl: auth.lease_duration,
|
|
});
|
|
}
|
|
}
|