1
0
mirror of https://github.com/bitwarden/web synced 2025-12-15 15:53:18 +00:00
TODO:
* encrypt key information with symm key
* store symm key with server next to api key
* Add toggle for enc access yes/no
* build out storing multiple API keys
* Add quick copy button to api key field
* See about a more user-friendly api key encoding
This commit is contained in:
Matt Gibson
2022-02-26 13:28:24 -05:00
parent 58d9ac5ebc
commit 1258989f8a
2 changed files with 29 additions and 2 deletions

View File

@@ -35,6 +35,10 @@
icon="bwi bwi-key" icon="bwi bwi-key"
*ngIf="clientSecret" *ngIf="clientSecret"
> >
<p class="mb-1">
<strong>combined:</strong>
<code>{{ combinedApiKey }}</code>
</p>
<p class="mb-1"> <p class="mb-1">
<strong>client_id:</strong><br /> <strong>client_id:</strong><br />
<code>{{ clientId }}</code> <code>{{ clientId }}</code>

View File

@@ -1,7 +1,9 @@
import { Component } from "@angular/core"; import { Component, OnInit } from "@angular/core";
import { CryptoService } from "jslib-common/abstractions/crypto.service";
import { LogService } from "jslib-common/abstractions/log.service"; import { LogService } from "jslib-common/abstractions/log.service";
import { UserVerificationService } from "jslib-common/abstractions/userVerification.service"; import { UserVerificationService } from "jslib-common/abstractions/userVerification.service";
import { Utils } from "jslib-common/misc/utils";
import { SecretVerificationRequest } from "jslib-common/models/request/secretVerificationRequest"; import { SecretVerificationRequest } from "jslib-common/models/request/secretVerificationRequest";
import { ApiKeyResponse } from "jslib-common/models/response/apiKeyResponse"; import { ApiKeyResponse } from "jslib-common/models/response/apiKeyResponse";
import { Verification } from "jslib-common/types/verification"; import { Verification } from "jslib-common/types/verification";
@@ -10,7 +12,7 @@ import { Verification } from "jslib-common/types/verification";
selector: "app-api-key", selector: "app-api-key",
templateUrl: "api-key.component.html", templateUrl: "api-key.component.html",
}) })
export class ApiKeyComponent { export class ApiKeyComponent implements OnInit {
keyType: string; keyType: string;
isRotation: boolean; isRotation: boolean;
postKey: (entityId: string, request: SecretVerificationRequest) => Promise<ApiKeyResponse>; postKey: (entityId: string, request: SecretVerificationRequest) => Promise<ApiKeyResponse>;
@@ -25,12 +27,20 @@ export class ApiKeyComponent {
formPromise: Promise<ApiKeyResponse>; formPromise: Promise<ApiKeyResponse>;
clientId: string; clientId: string;
clientSecret: string; clientSecret: string;
clientKey: string;
clientLocalKeyHash: string;
constructor( constructor(
private cryptoService: CryptoService,
private userVerificationService: UserVerificationService, private userVerificationService: UserVerificationService,
private logService: LogService private logService: LogService
) {} ) {}
async ngOnInit(): Promise<void> {
this.clientKey = Utils.fromBufferToB64((await this.cryptoService.getKey()).key);
this.clientLocalKeyHash = await this.cryptoService.getKeyHash();
}
async submit() { async submit() {
try { try {
this.formPromise = this.userVerificationService this.formPromise = this.userVerificationService
@@ -43,4 +53,17 @@ export class ApiKeyComponent {
this.logService.error(e); this.logService.error(e);
} }
} }
get combinedApiKey() {
return Utils.fromUtf8ToB64(
JSON.stringify({
clientId: this.clientId,
clientSecret: this.clientSecret,
encClientEncInfo: JSON.stringify({
clientEncKey: this.clientKey,
clientLocalKeyHash: this.clientLocalKeyHash,
}),
})
);
}
} }