Skip to content

Commit 23d8621

Browse files
committed
Remove config templating in favour of explicit secret references
After extensive testing and some initial user feedback, it became clear that expressions / templating provides horrible UX, because: * It's not clear where expressions can be used. * Expressions are only evaluated at runtime, so users don't get feedback when they reference secrets that don't exist. * Non-technical users struggle with expression syntax. Additionally, we don't really *need* the flexibility expressions give us. We just need a way to safely reference managed secrets. This change introduces support for the `x-secret-ref` JSON schema annotation. Properties annotated with it will be treated as secret references. When extensions retrieve their runtime config, secret references are transparently resolved. When extension configs are updated via REST API, it's validated that all referenced secrets exist. Secret managers now support pagination and filtering for the `listSecrets` operation. This is used to deliver a convenient dropdown with search-as-you-type in the UI. Note that it is expected that not all providers can support pagination natively, in which case they'll need to emulate the desired behaviour, which is what the `env` provider does. Listing secret metadata no longer requires the `SECRET_MANAGEMENT_READ` permission, but the `SYSTEM_CONFIGURATION_READ` permission. This is because users who maintain configuration are actually the ones that need to know which secrets they can use. Signed-off-by: nscuro <nscuro@protonmail.com>
1 parent 27c90a8 commit 23d8621

51 files changed

Lines changed: 1130 additions & 801 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/src/main/openapi/components/schemas/secrets/list-secrets-response.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
# SPDX-License-Identifier: Apache-2.0
1616
# Copyright (c) OWASP Foundation. All Rights Reserved.
1717
type: object
18+
allOf:
19+
- $ref: "../paginated-response.yaml"
1820
properties:
1921
secrets:
2022
type: array
2123
items:
22-
$ref: "./list-secrets-response-item.yaml"
24+
$ref: "./secret-metadata.yaml"
2325
required:
2426
- secrets

api/src/main/openapi/components/schemas/secrets/list-secrets-response-item.yaml renamed to api/src/main/openapi/components/schemas/secrets/secret-metadata.yaml

File renamed without changes.

api/src/main/openapi/paths/secrets.yaml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,27 @@
1515
# SPDX-License-Identifier: Apache-2.0
1616
# Copyright (c) OWASP Foundation. All Rights Reserved.
1717
get:
18-
operationId: listSecrets
19-
summary: List all secrets
20-
description: >-
21-
Returns a list of secrets.
22-
23-
* Does not include secret *values*, only metadata.
24-
* Does not support pagination.
18+
operationId: listSecretMetadata
19+
summary: List secret metadata
20+
description: |-
21+
Returns a paginated list of secret metadata.
2522
26-
Requires the `SECRET_MANAGEMENT` or `SECRET_MANAGEMENT_READ` permission.
23+
Requires the `SYSTEM_CONFIGURATION` or `SYSTEM_CONFIGURATION_READ` permission.
2724
tags:
2825
- Secrets
26+
parameters:
27+
- name: q
28+
description: >-
29+
Optional search text to filter secrets by.
30+
Filtering uses case-insensitive "starts with" semantics on the secret name.
31+
in: query
32+
schema:
33+
type: string
34+
- $ref: "../components/parameters/page-token.yaml"
35+
- $ref: "../components/parameters/pagination-limit.yaml"
2936
responses:
3037
"200":
31-
description: List of secrets
38+
description: Paginated list of secret metadata
3239
content:
3340
application/json:
3441
schema:

api/src/main/openapi/paths/secrets__name_.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,38 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
get:
18+
operationId: getSecretMetadata
19+
summary: Get secret metadata
20+
description: |-
21+
Returns metadata about a given secret.
22+
23+
Requires the `SYSTEM_CONFIGURATION` or `SYSTEM_CONFIGURATION_READ` permission.
24+
tags:
25+
- Secrets
26+
parameters:
27+
- name: name
28+
in: path
29+
description: The name of the secret
30+
required: true
31+
schema:
32+
$ref: "../components/schemas/secrets/secret-name.yaml"
33+
responses:
34+
"200":
35+
description: Secret metadata
36+
content:
37+
application/json:
38+
schema:
39+
$ref: "../components/schemas/secrets/secret-metadata.yaml"
40+
"401":
41+
$ref: "../components/responses/generic-unauthorized-error.yaml"
42+
"403":
43+
$ref: "../components/responses/generic-forbidden-error.yaml"
44+
"404":
45+
$ref: "../components/responses/generic-not-found-error.yaml"
46+
default:
47+
$ref: "../components/responses/generic-error.yaml"
48+
1749
patch:
1850
operationId: updateSecret
1951
summary: Update a secret

apiserver/src/main/java/org/dependencytrack/auth/Permissions.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public enum Permissions {
5353
ACCESS_MANAGEMENT_DELETE("Allows delete permissions of users, teams, and API keys"),
5454
SECRET_MANAGEMENT("Grants full secret management access"),
5555
SECRET_MANAGEMENT_CREATE("Grants the ability to create secrets"),
56-
SECRET_MANAGEMENT_READ("Grants the ability to view secret metadata"),
5756
SECRET_MANAGEMENT_UPDATE("Grants the ability to update secrets"),
5857
SECRET_MANAGEMENT_DELETE("Grants the ability to delete secrets"),
5958
SYSTEM_CONFIGURATION("Allows all access to configuration of the system including notifications, repositories, and email settings"),
@@ -109,7 +108,6 @@ public static class Constants {
109108
public static final String ACCESS_MANAGEMENT_DELETE = "ACCESS_MANAGEMENT_DELETE";
110109
public static final String SECRET_MANAGEMENT = "SECRET_MANAGEMENT";
111110
public static final String SECRET_MANAGEMENT_CREATE = "SECRET_MANAGEMENT_CREATE";
112-
public static final String SECRET_MANAGEMENT_READ = "SECRET_MANAGEMENT_READ";
113111
public static final String SECRET_MANAGEMENT_UPDATE = "SECRET_MANAGEMENT_UPDATE";
114112
public static final String SECRET_MANAGEMENT_DELETE = "SECRET_MANAGEMENT_DELETE";
115113
public static final String SYSTEM_CONFIGURATION = "SYSTEM_CONFIGURATION";

apiserver/src/main/java/org/dependencytrack/config/templating/ConfigTemplatePebbleExtensionCustomizer.java

Lines changed: 0 additions & 107 deletions
This file was deleted.

apiserver/src/main/java/org/dependencytrack/config/templating/ConfigTemplateRenderer.java

Lines changed: 0 additions & 150 deletions
This file was deleted.

0 commit comments

Comments
 (0)