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 > 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("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} > 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")) 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 type: integer
minimum: 1 minimum: 1
x-example: 2 x-example: 2
override_secret:
type: boolean
login_password: login_password:
type: object type: object
properties: properties:
@ -386,6 +388,10 @@ definitions:
type: string type: string
x-example: user x-example: user
example: user example: user
passphrase:
type: string
x-example: passphrase
example: passphrase
private_key: private_key:
type: string type: string
x-example: private key x-example: private key
@ -1741,8 +1747,10 @@ paths:
schema: schema:
$ref: "#/definitions/AccessKeyRequest" $ref: "#/definitions/AccessKeyRequest"
responses: responses:
204: 201:
description: Access Key created description: Access Key created
schema:
$ref: "#/definitions/AccessKey"
400: 400:
description: Bad type description: Bad type
/project/{project_id}/keys/{key_id}: /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), 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 // UpdateKey updates key in database