Vault Automation 0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* 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>
2025-10-21 15:20:20 -06:00

36 lines
885 B
TypeScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import AuthBase from './base';
import type { GithubLoginApiResponse } from 'vault/vault/auth/methods';
/**
* @module Auth::Form::Github
* see Auth::Base
*/
export default class AuthFormGithub extends AuthBase {
loginFields = [{ name: 'token', label: 'Github token' }];
async loginRequest(formData: { path: string; token: string }) {
const { path, token } = formData;
const { auth } = (await this.api.auth.githubLogin(path, {
token,
})) as GithubLoginApiResponse;
const { org, username } = auth?.metadata || {};
const displayName = org && username ? `${org}/${username}` : username || org || '';
return this.normalizeAuthResponse(auth, {
authMountPath: path,
displayName,
token: auth.client_token,
ttl: auth.lease_duration,
});
}
}