Return key ID on create, add passphrase

This commit is contained in:
Brian Zoetewey 2024-11-07 11:15:36 -05:00
parent c8935eabdb
commit aac032db96
3 changed files with 18 additions and 2 deletions

View File

@ -93,6 +93,7 @@ func main() {
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/matchers > Add Integration Matcher > 204 > application/json", capabilityWrapper("integration"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/matchers/{matcher_id} > Updates Integration Matcher > 204 > application/json", capabilityWrapper("integrationmatcher"))
h.Before("project > /api/project/{project_id}/keys > Add access key > 201 > application/json", capabilityWrapper("access_key"))
h.Before("project > /api/project/{project_id}/keys/{key_id} > Updates access key > 204 > application/json", capabilityWrapper("access_key"))
h.Before("project > /api/project/{project_id}/keys/{key_id} > Removes access key > 204 > application/json", capabilityWrapper("access_key"))

View File

@ -368,6 +368,8 @@ definitions:
type: integer
minimum: 1
x-example: 2
override_secret:
type: boolean
login_password:
type: object
properties:
@ -386,6 +388,10 @@ definitions:
type: string
x-example: user
example: user
passphrase:
type: string
x-example: passphrase
example: passphrase
private_key:
type: string
x-example: private key
@ -1741,8 +1747,10 @@ paths:
schema:
$ref: "#/definitions/AccessKeyRequest"
responses:
204:
201:
description: Access Key created
schema:
$ref: "#/definitions/AccessKey"
400:
description: Bad type
/project/{project_id}/keys/{key_id}:

View File

@ -101,7 +101,14 @@ func AddKey(w http.ResponseWriter, r *http.Request) {
Description: fmt.Sprintf("Access Key %s created", key.Name),
})
w.WriteHeader(http.StatusNoContent)
// Reload key to drop sensitive fields
key, err = helpers.Store(r).GetAccessKey(*newKey.ProjectID, newKey.ID)
if err != nil {
helpers.WriteError(w, err)
return
}
helpers.WriteJSON(w, http.StatusCreated, key)
}
// UpdateKey updates key in database