Implement GitHub Enterprise authn provider (#115940)

This commit is contained in:
Kevin Abel
2021-05-07 16:13:11 -05:00
committed by GitHub
parent 0f64d3a2e5
commit 4978a1891e
5 changed files with 200 additions and 123 deletions

View File

@@ -28,13 +28,11 @@ export type Keytar = {
deletePassword: typeof keytarType['deletePassword'];
};
const SERVICE_ID = `github.auth`;
export class Keychain {
constructor(private context: vscode.ExtensionContext) { }
constructor(private context: vscode.ExtensionContext, private serviceId: string) { }
async setToken(token: string): Promise<void> {
try {
return await this.context.secrets.store(SERVICE_ID, token);
return await this.context.secrets.store(this.serviceId, token);
} catch (e) {
// Ignore
Logger.error(`Setting token failed: ${e}`);
@@ -48,7 +46,7 @@ export class Keychain {
async getToken(): Promise<string | null | undefined> {
try {
return await this.context.secrets.get(SERVICE_ID);
return await this.context.secrets.get(this.serviceId);
} catch (e) {
// Ignore
Logger.error(`Getting token failed: ${e}`);
@@ -58,7 +56,7 @@ export class Keychain {
async deleteToken(): Promise<void> {
try {
return await this.context.secrets.delete(SERVICE_ID);
return await this.context.secrets.delete(this.serviceId);
} catch (e) {
// Ignore
Logger.error(`Deleting token failed: ${e}`);