Skip to content

Commit 104f47d

Browse files
Merge pull request #93889 from gaurav-nelson/ROX-29281-keyless-quay
[RHACS] Add Quay keyless authentication procedure
2 parents 3a50c70 + 22b4d50 commit 104f47d

File tree

4 files changed

+132
-7
lines changed

4 files changed

+132
-7
lines changed

cli/image-scanning-by-using-the-roxctl-cli.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ By specifying the appropriate cluster in the delegated scanning configuration or
1616

1717
[IMPORTANT]
1818
====
19-
For more information about how to configure delegated image scanning, see xref:../operating/examine-images-for-vulnerabilities.adoc#configuring-delegated-image-scanning_examine-images-for-vulnerabilities[Configuring delegated image scanning].
19+
For more information about how to configure delegated image scanning, see xref:../operating/examine-images-for-vulnerabilities.adoc#accessing-delegated-image-scanning_examine-images-for-vulnerabilities[Accessing delegated image scanning].
2020
====
2121

2222
.Procedure

integration/integrate-with-image-registries.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ include::modules/manual-configuration-image-registry-qcr.adoc[leveloffset=+2]
7373
[role="_additional-resources"]
7474
.Additional resources
7575
* xref:../integration/integrate-with-image-vulnerability-scanners.adoc#integrate-with-qcr-scanner_integrate-with-image-vulnerability-scanners[Integrating with Quay Container Registry to scan images]
76+
* link:https://external-secrets.io/latest/api/generator/quay/[External Secrets Operator - Quay]
77+
78+
include::modules/quay-keyless-eso.adoc[leveloffset=+2]
79+
80+
[role="_additional-resources"]
81+
.Additional resources
82+
83+
* xref:../operating/examine-images-for-vulnerabilities.adoc#accessing-delegated-image-scanning_examine-images-for-vulnerabilities[Accessing delegated image scanning].
7684

7785
include::modules/manual-configuration-image-registry-ghcr.adoc[leveloffset=+2]
7886

modules/manual-configuration-image-registry-qcr.adoc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77

88
You can integrate {product-title} ({product-title-short}) with Quay Container Registry. You can integrate with Quay by using the following methods:
99

10-
- Integrating with the Quay public repository (registry): This method does not require authentication.
11-
- Integrating with a Quay private registry by using a robot account: This method requires that you create a robot account to use with Quay (recommended). See the link:https://access.redhat.com/documentation/en-us/red_hat_quay/3/html/use_red_hat_quay/use-quay-manage-repo#allow-robot-access-user-repo[Quay documentation] for more information.
12-
- Integrating with Quay to use the Quay scanner rather than the {product-title-short} scanner: This method uses the API and requires an OAuth token for authentication. See "Integrating with Quay Container Registry to scan images" in the "Additional Resources" section.
10+
* Integrating with the Quay public repository (registry): This method does not require authentication.
11+
* Integrating with a Quay private registry:
12+
13+
** By using a robot account: This method requires that you create a robot account to use with Quay (recommended). See the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.14/html/about_quay_io/allow-robot-access-user-repo[Red{nbsp}Hat Quay Robot Account overview] topic in Quay documentation for more information.
14+
** By using keyless authentication with external secret: This method uses OIDC federation and the External Secrets Operator (ESO). For more information, see "Enabling Quay registry keyless authentication using external secret".
15+
16+
* Integrating with Quay to use the Quay scanner rather than the {product-title-short} scanner: This method uses the API and requires an OAuth token for authentication. For more information, see "Integrating with Quay Container Registry to scan images" in the "Additional resources" section.
1317
1418
.Prerequisites
1519
* For authentication with a Quay private registry, you need the credentials associated with a robot account or an OAuth token (deprecated).
@@ -20,16 +24,16 @@ You can integrate {product-title} ({product-title-short}) with Quay Container Re
2024
. Click *New integration*.
2125
. Enter the *Integration name.*
2226
. Enter the *Endpoint*, or the address of the registry.
23-
.. If you are integrating with the Quay public repository, under *Type*, select *Registry*, and then go to the next step.
27+
.. If you are integrating with the Quay public repository, under *Type*, select *Registry*, and then go to the next step.
2428
.. If you are integrating with a Quay private registry, under *Type*, select *Registry* and enter information in the following fields:
2529
** *Robot username*: If you are accessing the registry by using a Quay robot account, enter the user name in the format `_<namespace>+<accountname>_`.
2630
** *Robot password*: If you are accessing the registry by using a Quay robot account, enter the password for the robot account user name.
27-
** *OAuth token*: If you are accessing the registry by using an OAuth token (deprecated), enter it in this field.
31+
** *OAuth token*: If you are accessing the registry by using an OAuth token (deprecated), enter it in this field.
2832
. Optional: If you are not using a TLS certificate when connecting to the registry, select *Disable TLS certificate validation (insecure)*.
2933
. Optional: To create the integration without testing, select *Create integration without testing*.
3034
. Select *Save*.
3135

3236
[NOTE]
3337
====
34-
If you are editing a Quay integration but do not want to update your credentials, verify that *Update stored credentials* is not selected.
38+
If you are editing a Quay integration but do not want to update your credentials, verify that *Update stored credentials* is not selected.
3539
====

modules/quay-keyless-eso.adoc

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * integration/integrate-with-image-registries.adoc
4+
:_mod-docs-content-type: PROCEDURE
5+
[id="quay-keyless-eso_{context}"]
6+
= Enabling Quay registry keyless authentication using external secret
7+
8+
For validating images stored in Quay private registries, you can configure {product-title-short} to use keyless authentication with Red{nbsp}Hat Quay registries. This method uses the External Secrets Operator (ESO) and OpenID Connect (OIDC) federation.
9+
10+
.Prerequisites
11+
12+
* You have enabled delegated scanning in {product-title-short}. For more information, see "Accessing delegated image scanning" in the "Additional resources" section.
13+
* The Central endpoint configured for the Secured Cluster `centralEndpoint: central.stackrox:443` or similar.
14+
* A robot account created in Red{nbsp}Hat Quay with OIDC federation configured.
15+
+
16+
--
17+
* The issuer URL in the Quay robot identity federation configuration must match the service account token issuer of your {ocp} cluster.
18+
* The `sub claim` subject must match the service account name and namespace that you configure in your cluster.
19+
--
20+
+
21+
See the link:https://docs.redhat.com/en/documentation/red_hat_quay/latest/html/about_quay_io/allow-robot-access-user-repo[Red Hat Quay Robot Account overview] topic in Quay documentation for more information.
22+
23+
.Procedure
24+
25+
. In your Quay instance, navigate to your robot account settings and configure OIDC federation.
26+
+
27+
Ensure the *Issuer URL* and *Subject* fields are correctly set to match your {ocp} service account that ESO uses. See the link:https://docs.redhat.com/en/documentation/red_hat_quay/latest/html/about_quay_io/allow-robot-access-user-repo#setting-robot-federation[Setting up robot account federation] topic in the Red Hat Quay documentation for more information.
28+
29+
. If ESO is not already present in your cluster, install it using Helm or another preferred method.
30+
+
31+
[source,terminal,subs="+attributes"]
32+
----
33+
$ helm repo add external-secrets https://charts.external-secrets.io
34+
helm install external-secrets \
35+
external-secrets/external-secrets \
36+
-n external-secrets \
37+
--create-namespace
38+
----
39+
40+
. Define and apply the following Kubernetes resources. This example creates a `ServiceAccount` resource, a `QuayAccessToken` generator resource provided by the ESO installation, and an `ExternalSecret` resource that uses the generator to create a `kubernetes.io/dockerconfigjson` secret in the specified namespace.
41+
+
42+
[IMPORTANT]
43+
====
44+
Update the `robotAccount` field in the `QuayAccessToken` resource to match the name of your Quay robot account.
45+
====
46+
+
47+
[source,yaml]
48+
----
49+
apiVersion: v1
50+
kind: ServiceAccount
51+
metadata:
52+
name: quay
53+
namespace: quay
54+
---
55+
apiVersion: generators.external-secrets.io/v1alpha1
56+
kind: QuayAccessToken
57+
metadata:
58+
name: quay-token
59+
namespace: quay
60+
spec:
61+
url: quay.io
62+
robotAccount: keyless+account # <1>
63+
serviceAccountRef:
64+
name: quay
65+
namespace: quay
66+
---
67+
apiVersion: external-secrets.io/v1beta1
68+
kind: ExternalSecret
69+
metadata:
70+
name: quay-credentials
71+
namespace: quay
72+
spec:
73+
dataFrom:
74+
- sourceRef:
75+
generatorRef:
76+
apiVersion: generators.external-secrets.io/v1alpha1
77+
kind: QuayAccessToken
78+
name: quay-token
79+
refreshInterval: 55m
80+
target:
81+
name: quay-credentials
82+
template:
83+
type: kubernetes.io/dockerconfigjson
84+
data:
85+
.dockerconfigjson: |
86+
{
87+
"auths": {
88+
"{{ .registry }}": {
89+
"auth": "{{ .auth }}"
90+
}
91+
}
92+
}
93+
----
94+
<1> Replace `keyless+account` with the actual name of your Quay robot account.
95+
96+
.Verification
97+
98+
* Confirm that ESO has successfully created a secret named `quay-credentials` of type `kubernetes.io/dockerconfigjson` in the specified namespace.
99+
+
100+
[source,terminal]
101+
----
102+
$ kubectl get secret quay-credentials -n quay -o yaml
103+
----
104+
105+
The keyless authentication method supports image scanning by using **delegated scanning**.
106+
107+
* Use delegated image scanning by running the following command:
108+
+
109+
[source,terminal]
110+
----
111+
$ roxctl image scan <image_name> --namespace=<namespace_where_secret_exists> <1>
112+
----
113+
<1> Specify the image name and namespace where you created the secret.

0 commit comments

Comments
 (0)