Este conteúdo não está disponível no idioma selecionado.
Chapter 1. Red Hat OpenShift Container Platform
1.1. Resource recommendations for deploying on OpenShift Copiar o linkLink copiado para a área de transferência!
Understanding how to size the infrastructure resources before deploying Red Hat Trusted Artifact Signer (RHTAS) on Red Hat OpenShift is important for optimizing your workloads. The key infrastructure piece for consideration is the number of CPUs and the memory available for the Trillian database. As the number of signing and verifying requests increases, this adds more load to the CPU, and increases the memory usage of the Trillian database.
You have two options for implementing the Trillian database used with RHTAS: a dedicated database, or a managed database. Red Hat recommends a dedicated database for production workloads, and a managed database for non-production workloads. Here are the baseline CPU and memory resources you can start with.
- Dedicated
- 2 CPU cores
- 1 GB of RAM
- 5 GB of storage
- Managed
- 4 CPU cores
- 2 GB of RAM
- 10 GB of storage
1.2. Installing Trusted Artifact Signer using the Operator Lifecycle Manager Copiar o linkLink copiado para a área de transferência!
You can install the Red Hat Trusted Artifact Signer (RHTAS) Operator, and deploy the RHTAS service by using OpenShift’s Operator Lifecycle Manager (OLM). This deployment gives you a basic signing framework with your choice of an OpenID Connect (OIDC) provider. You must configure at least one of the following OIDC providers: Red Hat Single Sign-on (SSO), Google, Amazon Secure Token Service (STS), or GitHub. You can also optionally customize your database solution, if you do not want to use the default.
Prerequisites
- Red Hat OpenShift Container Platform 4.15 or later.
-
Access to the OpenShift web console with the
cluster-adminrole. - An OIDC provider configured for signing artifacts.
-
A workstation with the
ocbinary installed.
Procedure
-
Log in to the OpenShift web console with a user that has the
cluster-adminrole. - From the Administrator perspective, expand the Operators navigation menu, and click OperatorHub.
- In the search field, type trusted, and click the Red Hat Trusted Artifact Signer tile.
- Click the Install button to show the operator details.
Accept the default values, click Install on the Install Operator page, and wait for the installation to finish.
ImportantOnce the installation finishes, a new project is automatically created for you. The new project name is
trusted-artifact-signer.NoteThe Trusted Artifact Signer operator installs into the
openshift-operatorsnamespace, and all dependencies are automatically installed.- Optional. Instead of the default database, you can use an alternative database provider for the Trusted Artifact Signer service. If you want to use Amazon’s Relational Database Service (RDS), or a self-managed database on OpenShift, then follow one of those procedures first before continuing on with this installation. Once done configuring one of these other database providers, you can continue onto the next step of this procedure.
To deploy the Trusted Artifact Signer service.
- Within the OpenShift web console, expand Operators from the navigation menu, click Installed Operators.
-
Select
trusted-artifact-signerfrom the project drop-down box. - Click Red Hat Trusted Artifact Signer.
- Click the Securesign tab, and click the Create Securesign button.
- On the Create Securesign page, select YAML view.
You can configure different OIDC providers, such as, Red Hat build of Keycloak, Google OAuth, Amazon STS, Microsoft’s Entra ID or GitHub OAuth as the initial OIDC provider for this deployment. Under the
spec.fulcio.config.OIDCIssuerssection, edit the following three lines with the OIDC provider URL, and set theClientIDappropriately.Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantYou can define several different OIDC providers in the same configuration.
Optional. If you chosen to use a different database other than the default, then under the
spec.trilliansection, setcreatetofalse, and give the name of the database secret object.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click the Create button.
Click All instances tab to watch the deployment status until the CTlog, Fulcio, Rekor, Trillian, and TUF instances are ready.
NoteThe Securesign instance does not give a status.
- You can check on the health of the new Trusted Artifact Signer service by using Prometheus in the OpenShift console. From the navigation menu, expand Observe, and click Dashboards.
- Verify the installation by signing a container image, or a Git commit.
1.3. Verify the Trusted Artifact Signer installation Copiar o linkLink copiado para a área de transferência!
As as systems administrator, you can verify if the deployment of Red Hat Trusted Artifact Signer (RHTAS) running on Red Hat OpenShift Container Platform was successful.
You can sign a test container image, and verify the authenticity of that signature to validate the deployment of RHTAS in your environment.
There are two ways to sign and three ways to verify build artifacts from your code pipeline. You can sign and verify with cosign and gitsign, but can only verify with Enterprise Contract.
1.3.1. Signing and verifying containers by using Cosign from the command-line interface Copiar o linkLink copiado para a área de transferência!
The cosign tool gives you the capability to sign and verify Open Container Initiative (OCI) container images, along with other build artifacts by using Red Hat’s Trusted Artifact Signer (RHTAS) service.
For RHTAS, you must use cosign version 2.2 or later.
Prerequisites
- Installation of RHTAS running on Red Hat OpenShift Container Platform 4.15 or later.
- Access to the OpenShift web console.
-
A workstation with the
oc, andpodmanbinaries installed.
Procedure
Download the
cosignbinary from the OpenShift cluster to your workstation.- Login to the OpenShift web console. From the home page, click the ? icon, click Command line tools, go to the cosign download section, and click the link for your platform.
Open a terminal on your workstation, decompress the binary
.gzfile, and set the execution bit:gunzip cosign-amd64.gz chmod +x cosign-amd64
$ gunzip cosign-amd64.gz $ chmod +x cosign-amd64Copy to Clipboard Copied! Toggle word wrap Toggle overflow Move and rename the binary to a location within your
$PATHenvironment:sudo mv cosign-amd64 /usr/local/bin/cosign
$ sudo mv cosign-amd64 /usr/local/bin/cosignCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Log in to the OpenShift cluster:
oc login --token=TOKEN --server=SERVER_URL_AND_PORT
oc login --token=TOKEN --server=SERVER_URL_AND_PORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443
$ oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can find your login token and URL to use on the command line from the OpenShift web console. Log in to the OpenShift web console. Click your user name, and click Copy login command. Offer your user name and password again, if asked, and click Display Token to view the command.
Switch to the RHTAS project:
oc project PROJECT_NAME
oc project PROJECT_NAMECopy to Clipboard Copied! Toggle word wrap Toggle overflow oc project trusted-artifact-signer
$ oc project trusted-artifact-signerCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteUse the project name for the RHTAS installation.
Configure your shell environment for doing container image signing and verifying.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you are using the Ingress Operator to auto-generate route names, then you must update the
oc get route …command by replacingkeycloakwith the auto-generated route name.Initialize The Update Framework (TUF) system:
cosign initialize
$ cosign initializeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Sign a test container image.
Create an empty container image:
echo "FROM scratch" > ./tmp.Dockerfile podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1h
$ echo "FROM scratch" > ./tmp.Dockerfile $ podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Push the empty container image to the
ttl.shephemeral registry:podman push ttl.sh/rhtas/test-image:1h
$ podman push ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Sign the container image:
cosign sign -y IMAGE_NAME:TAG
cosign sign -y IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow cosign sign -y ttl.sh/rhtas/test-image:1h
$ cosign sign -y ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow A web browser opens allowing you to sign the container image with an email address.
Remove the temporary Docker file:
rm ./tmp.Dockerfile
$ rm ./tmp.DockerfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verify a signed container image by using a certificate identity and issuer:
cosign verify --certificate-identity=SIGNING_EMAIL_ADDR IMAGE_NAME:TAG
cosign verify --certificate-identity=SIGNING_EMAIL_ADDR IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow cosign verify --certificate-identity=jdoe@redhat.com ttl.sh/rhtas/test-image:1h
$ cosign verify --certificate-identity=jdoe@redhat.com ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can also use regular expressions for the certificate identity and issuer by using the following options to the
cosigncommand,--certificate-identity-regexpand--certificate-oidc-issuer-regexp.Download the
rekor-clibinary from the OpenShift cluster to your workstation.- Login to the OpenShift web console. From the home page, click the ? icon, click Command line tools, go to the rekor-cli download section, and click the link for your platform.
Open a terminal on your workstation, decompress the binary
.gzfile, and set the execution bit:gunzip rekor-cli-amd64.gz chmod +x rekor-cli-amd64
$ gunzip rekor-cli-amd64.gz $ chmod +x rekor-cli-amd64Copy to Clipboard Copied! Toggle word wrap Toggle overflow Move and rename the binary to a location within your
$PATHenvironment:sudo mv rekor-cli-amd64 /usr/local/bin/rekor-cli
$ sudo mv rekor-cli-amd64 /usr/local/bin/rekor-cliCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Query the transparency log by using the Rekor command-line interface.
Search based on the log index:
rekor-cli get --log-index 0 --rekor_server $COSIGN_REKOR_URL --format json | jq
$ rekor-cli get --log-index 0 --rekor_server $COSIGN_REKOR_URL --format json | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow Search for an email address to get the universal unique identifier (UUID):
rekor-cli search --email SIGNING_EMAIL_ADDR --rekor_server $COSIGN_REKOR_URL --format json | jq
rekor-cli search --email SIGNING_EMAIL_ADDR --rekor_server $COSIGN_REKOR_URL --format json | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow rekor-cli search --email jdoe@redhat.com --rekor_server $COSIGN_REKOR_URL --format json | jq
$ rekor-cli search --email jdoe@redhat.com --rekor_server $COSIGN_REKOR_URL --format json | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command returns the UUID for use with the next step.
Use the UUID to get the transaction details:
rekor-cli get --uuid UUID --rekor_server $COSIGN_REKOR_URL --format json | jq
rekor-cli get --uuid UUID --rekor_server $COSIGN_REKOR_URL --format json | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow rekor-cli get --uuid 24296fb24b8ad77a71b9c1374e207537bafdd75b4f591dcee10f3f697f150d7cc5d0b725eea641e7 --rekor_server $COSIGN_REKOR_URL --format json | jq
$ rekor-cli get --uuid 24296fb24b8ad77a71b9c1374e207537bafdd75b4f591dcee10f3f697f150d7cc5d0b725eea641e7 --rekor_server $COSIGN_REKOR_URL --format json | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.3.2. Signing and verifying commits by using Gitsign from the command-line interface Copiar o linkLink copiado para a área de transferência!
The gitsign tool gives you the ability to sign and verify Git repository commits by using Red Hat’s Trusted Artifact Signer (RHTAS) service.
Prerequisites
- A RHTAS installation on Red Hat OpenShift Container Platform 4.15 or later.
- Access to the OpenShift web console.
A workstation with the
oc,git, andcosignbinaries installed.-
You must use
cosignversion 2.2 or later.
-
You must use
- A locally cloned Git repository.
Procedure
Download the
gitsignbinary from the OpenShift cluster to your workstation.- Login to the OpenShift web console. From the home page, click the ? icon, click Command line tools, go to the gitsign download section, and click the link for your platform.
Open a terminal on your workstation, decompress the .gz file, and set the execution bit:
gunzip gitsign-amd64.gz chmod +x gitsign-amd64
$ gunzip gitsign-amd64.gz $ chmod +x gitsign-amd64Copy to Clipboard Copied! Toggle word wrap Toggle overflow Move and rename the binary to a location within your
$PATHenvironment:sudo mv gitsign-amd64 /usr/local/bin/gitsign
$ sudo mv gitsign-amd64 /usr/local/bin/gitsignCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Log in to the OpenShift cluster:
oc login --token=TOKEN --server=SERVER_URL_AND_PORT
oc login --token=TOKEN --server=SERVER_URL_AND_PORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443
$ oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can find your login token and URL to use on the command line from the OpenShift web console. Log in to the OpenShift web console. Click your user name, and click Copy login command. Offer your user name and password again, if asked, and click Display Token to view the command.
Switch to the RHTAS project:
oc project PROJECT_NAME
oc project PROJECT_NAMECopy to Clipboard Copied! Toggle word wrap Toggle overflow oc project trusted-artifact-signer
$ oc project trusted-artifact-signerCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteUse the project name for the RHTAS installation.
Configure your shell environment for doing commit signing and verifying:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Change directory (
cd) to the local Git repository directory. Configure the local repository configuration to sign your commits by using the RHTAS service:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make a commit to the local repository:
git commit --allow-empty -S -m "Test of a signed commit"
$ git commit --allow-empty -S -m "Test of a signed commit"Copy to Clipboard Copied! Toggle word wrap Toggle overflow A web browser opens allowing you to sign the commit with an email address.
Initialize The Update Framework (TUF) system:
cosign initialize
$ cosign initializeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the commit:
gitsign verify --certificate-identity=SIGNING_EMAIL --certificate-oidc-issuer=$SIGSTORE_OIDC_ISSUER HEAD
gitsign verify --certificate-identity=SIGNING_EMAIL --certificate-oidc-issuer=$SIGSTORE_OIDC_ISSUER HEADCopy to Clipboard Copied! Toggle word wrap Toggle overflow gitsign verify --certificate-identity=jdoe@redhat.com --certificate-oidc-issuer=$SIGSTORE_OIDC_ISSUER HEAD
$ gitsign verify --certificate-identity=jdoe@redhat.com --certificate-oidc-issuer=$SIGSTORE_OIDC_ISSUER HEADCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.3.3. Verifying signatures on container images with Conforma Copiar o linkLink copiado para a área de transferência!
Conforma, formally known as Enterprise Contract (EC), is a tool for maintaining the security of software supply chains, and you can use it to define and enforce policies for container images. You can use the ec binary to verify the attestation and signature of container images that use Red Hat’s Trusted Artifact Signer (RHTAS) signing framework.
Prerequisites
- A RHTAS installation on Red Hat OpenShift Container Platform 4.15 or later.
- Access to the OpenShift web console.
A workstation with the
oc,cosign, andpodmanbinaries installed.-
You must use
cosignversion 2.2 or later.
-
You must use
Procedure
Download the
ecbinary from the OpenShift cluster.- Log in to the OpenShift web console. From the home page, click the ? icon, click Command line tools, go to the ec download section, then click the link for your platform.
Open a terminal on your workstation, decompress the binary .gz file, and set the execution bit:
gunzip ec-amd64.gz chmod +x ec-amd64
$ gunzip ec-amd64.gz $ chmod +x ec-amd64Copy to Clipboard Copied! Toggle word wrap Toggle overflow Move and rename the binary to a location within your
$PATHenvironment:sudo mv ec-amd64 /usr/local/bin/ec
$ sudo mv ec-amd64 /usr/local/bin/ecCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Log in to the OpenShift cluster:
oc login --token=TOKEN --server=SERVER_URL_AND_PORT
oc login --token=TOKEN --server=SERVER_URL_AND_PORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443
$ oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can find your login token and URL to use on the command line from the OpenShift web console. Log in to the OpenShift web console. Click your user name, and click Copy login command. Offer your user name and password again, if asked, and click Display Token to view the command.
Switch to the RHTAS project:
oc project PROJECT_NAME
oc project PROJECT_NAMECopy to Clipboard Copied! Toggle word wrap Toggle overflow oc project trusted-artifact-signer
$ oc project trusted-artifact-signerCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteUse the project name for the RHTAS installation.
Configure your shell environment for doing container image signing and verifying.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Initialize The Update Framework (TUF) system:
cosign initialize
$ cosign initializeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Sign a test container image.
Create an empty container image:
echo "FROM scratch" > ./tmp.Dockerfile podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1h
$ echo "FROM scratch" > ./tmp.Dockerfile $ podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Push the empty container image to the
ttl.shephemeral registry:podman push ttl.sh/rhtas/test-image:1h
$ podman push ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Sign the container image:
cosign sign -y IMAGE_NAME:TAG
cosign sign -y IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow cosign sign -y ttl.sh/rhtas/test-image:1h
$ cosign sign -y ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow A web browser opens allowing you to sign the container image with an email address.
Remove the temporary Docker file:
rm ./tmp.Dockerfile
$ rm ./tmp.DockerfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create a
predicate.jsonfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Refer to the SLSA provenance predicate specifications for more information about the schema layout.
Associate the
predicate.jsonfile with the container image:cosign attest -y --predicate ./predicate.json --type slsaprovenance IMAGE_NAME:TAG
cosign attest -y --predicate ./predicate.json --type slsaprovenance IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow cosign attest -y --predicate ./predicate.json --type slsaprovenance ttl.sh/rhtas/test-image:1h
$ cosign attest -y --predicate ./predicate.json --type slsaprovenance ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the container image has at least one attestation and signature:
cosign tree IMAGE_NAME:TAG
cosign tree IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the container image by using Conforma:
ec validate image --image IMAGE_NAME:TAG --certificate-identity-regexp 'SIGNER_EMAIL_ADDR' --certificate-oidc-issuer-regexp 'keycloak-system' --output yaml --show-successes
ec validate image --image IMAGE_NAME:TAG --certificate-identity-regexp 'SIGNER_EMAIL_ADDR' --certificate-oidc-issuer-regexp 'keycloak-system' --output yaml --show-successesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enterprise Contract generates a pass-fail report with details on any security violations. When you add the
--infoflag, the report includes more details and possible solutions for any violations found.
1.4. Configure additional OpenID Connect providers Copiar o linkLink copiado para a área de transferência!
As as systems administrator, you can configure many different OpenID Connect (OIDC) providers for use with Red Hat’s Trusted Artifact Signer service. You can configure the following OIDC providers for authenticating users:
- Red Hat build of Keycloak
- Red Hat Single Sign-on (SSO)
- Amazon Security Token Service (STS)
- Microsoft Entra ID
- GitHub
1.4.1. Configuring Google as an OpenID Connect provider for Trusted Artifact Signer Copiar o linkLink copiado para a área de transferência!
You can use Google OAuth 2.0 as your OpenID Connect (OIDC) provider for Red Hat’s Trusted Artifact Signer (RHTAS) service. You can decide to configure Google OAuth during the deployment of RHTAS, or at a later time.
You can define several different OIDC providers in the same configuration.
Prerequisites
- Red Hat OpenShift Container Platform 4.15 or later.
-
Access to the OpenShift web console with the
cluster-adminrole. -
A workstation with the
oc, andpodmanbinaries installed. From the Google Cloud Console, create an OAuth client ID with the following settings:
- Set the application type to “Web Application”.
- Authorized redirect URIs must include: http://localhost/auth/callback .
Procedure
Open a terminal on your workstation, and log in to OpenShift:
oc login --token=TOKEN --server=SERVER_URL_AND_PORT
oc login --token=TOKEN --server=SERVER_URL_AND_PORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443
$ oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can find your login token and URL for use on the command line from the OpenShift web console. Log in to the OpenShift web console. Click your user name, and click Copy login command. Offer your user name and password again, if asked, and click Display Token to view the command.
Update the RHTAS configuration.
Open for editing the
Securesignresource:oc edit Securesign NAME -n NAMESPACE
oc edit Securesign NAME -n NAMESPACECopy to Clipboard Copied! Toggle word wrap Toggle overflow oc edit Securesign securesign-sample -n trusted-artifact-signer
$ oc edit Securesign securesign-sample -n trusted-artifact-signerCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou must use the project name created for the RHTAS installation as the namespace.
Under the
OIDCIssuerssection, add a new subsection with your Google client identifier, issuer’s URL, and set theTypevalue toemail:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add you Google client identifier to the
ClientIDfield.- Save your changes, and quit the editor. After a few seconds the operator automatically reconfigures the RHTAS software stack.
Change the OIDC issuer, and client id environment variables to use Google:
export OIDC_ISSUER_URL=https://accounts.google.com export COSIGN_OIDC_CLIENT_ID="314919563931-35zke44ouf2oiztjg7v8o8c2ge9usnd1.apps.googleexample.com"
$ export OIDC_ISSUER_URL=https://accounts.google.com $ export COSIGN_OIDC_CLIENT_ID="314919563931-35zke44ouf2oiztjg7v8o8c2ge9usnd1.apps.googleexample.com"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy and paste your secret from the Google Console to a plain text file:
echo SECRET > my-google-client-secret
echo SECRET > my-google-client-secretCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you already have the RHTAS service running, you can verify the updated configuration by signing a test container image.
Create an empty container image:
echo "FROM scratch" > ./tmp.Dockerfile podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1h
$ echo "FROM scratch" > ./tmp.Dockerfile $ podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Push the empty container image to the
ttl.shephemeral registry:podman push ttl.sh/rhtas/test-image:1h
$ podman push ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the temporary Docker file:
rm ./tmp.Dockerfile
$ rm ./tmp.DockerfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Sign the container image:
cosign sign -y --oidc-client-secret-file=SECRET_FILE IMAGE_NAME:TAG
cosign sign -y --oidc-client-secret-file=SECRET_FILE IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow cosign sign -y --oidc-client-secret-file=my-google-client-secret ttl.sh/rhtas/test-image:1h
$ cosign sign -y --oidc-client-secret-file=my-google-client-secret ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow A web browser opens allowing you to sign the container image with an email address.
1.4.2. Configuring Red Hat SSO as an OpenID Connect provider for Trusted Artifact Signer Copiar o linkLink copiado para a área de transferência!
You can use Red Hat Single Sign-On (SSO) as your OpenID Connect provider for Red Hat’s Trusted Artifact Signer (RHTAS) service. This gives you a Keycloak authentication environment for applications and secure services.
Prerequisites
- Red Hat OpenShift Container Platform 4.15 or later.
-
Access to the OpenShift web console with the
cluster-adminrole. - Have 1 GB of container storage available for the Keycloak PostgreSQL database.
-
A workstation with the
ocbinary installed.
Procedure
-
Log in to the OpenShift web console with a user that has the
cluster-adminrole. Create a new project to deploy the Keycloak service.
- From the Administrator perspective, expand Home from the navigation menu, and click Projects.
- Click the Create Project button.
-
The new project name is
keycloak-system, and click the Create button.
- Expand Operators from the navigation menu, and click OperatorHub.
- In the search field, type sso, and click the Red Hat Single Sign-on tile.
- Click the Install button to show the operator details.
-
If not already set, select
keycloak-systemfrom the Installed Namespace drop-down menu. - Click Install on the Install Operator page, and wait for the installation to finish.
- After the installation finishes, click View Operator.
From your workstation terminal, log in to the OpenShift cluster:
oc login --token=TOKEN --server=SERVER_URL_AND_PORT
oc login --token=TOKEN --server=SERVER_URL_AND_PORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443
$ oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can find your login token and URL to use on the command line from the OpenShift web console. Log in to the OpenShift web console. Click your user name, and click Copy login command. Offer your user name and password again, if asked, and click Display Token to view the command.
Switch to the Keycloak project:
oc project keycloak-system
$ oc project keycloak-systemCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Keycloak instance:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Keycloak realm:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Keycloak client:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Keycloak user:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set a user name, the user’s email address, and a password or reference a secret object.
- Go back to the OpenShift web console, click the All instances tab to watch and wait until the Keycloak system initializes successfully.
1.4.3. Configuring Red Hat build of Keycloak as an OpenID Connect provider for Trusted Artifact Signer Copiar o linkLink copiado para a área de transferência!
You can configure Red Hat’s build of Keycloak (RHBK) as an OpenID Connect (OIDC) provider for Red Hat’s Trusted Artifact Signer (RHTAS) service. This procedure guides you on integrating RHBK with RHTAS.
You can define several different OIDC providers for Fulcio in the same SecureSign configuration.
Prerequisites
- A RHTAS installation on OpenShift Container Platform 4.15 or later.
-
Access to the OpenShift web console with the
cluster-adminrole. -
A workstation with the
ocbinary installed. - Have 1 GB of persistent storage available for the Keycloak PostgreSQL database.
- A TLS certificate and key.
Procedure
-
Log in to the OpenShift web console with a user that has the
cluster-adminrole. Create a new project to deploy the Keycloak service.
- From the Administrator perspective, expand Home from the navigation menu, and click Projects.
- Click the Create Project button.
-
The new project name is
keycloak-system, and click the Create button.
Deploy an instance of PostgreSQL for use by Keycloak to store persistent data.
ImportantIf a database already exists for use by Keycloak, replace the
username,passwordanddatabasename values for theSecretresource that corresponds with your database instance. You can skip the creation of the PostgreSQL Service and StatefulSet steps, and move ahead to the next step.Create a
Secretresource to store the database information.- Expand Workloads from the navigation menu, and click Secrets.
-
Select the
keycloak-systemfrom the Project drop-down menu. - Click the Create drop-down menu, and select Key/Value secret.
-
Enter
postgresql-dbin the Secret name field. -
Enter
usernamein the Key field. -
Enter
keycloakin the free-form field for the Value. This is the user name Keycloak uses to authenticate to the PostgreSQL database instance. - Click the Add key/value link to add another key-value pair.
-
Enter
passwordin the Key field. - Enter a password of your choice in the free-form field for the Value. This is the password Keycloak uses to authenticate to the PostgreSQL database instance.
- Click the Add key/value link to add another key-value pair.
-
Enter
databasein the Key field. -
Enter
keycloakin the free-form field for the Value. This is the name of the database for storing Keycloak data within the PostgreSQL database instance. - Click the Create button.
Create the PostgreSQL Service and StatefulSet.
- Click the + icon.
- Copy the Service and StatefulSet YAML configuration text, and on the Import YAML page, paste the text into the text editor box.
-
Click the Create button to add the Service and StatefulSet to the
keycloak-systemproject.
- Expand Operators from the navigation menu, and click OperatorHub.
- In the search field, type keycloak, and click the Red Hat build of Keycloak Operator tile from the certified Red Hat catalog.
- Click the Install button to show the operator details.
-
On the Install Operator page, select
keycloak-systemfrom the Installed Namespace drop-down menu, and click the Install button. Wait for the installation to finish. Open a terminal from your workstation, and log in to the OpenShift cluster:
oc login --token=TOKEN --server=SERVER_URL_AND_PORT
oc login --token=TOKEN --server=SERVER_URL_AND_PORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443
$ oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can find your login token and URL to use on the command line from the OpenShift web console. Log in to the OpenShift web console. Click your user name, and click Copy login command. Offer your user name and password again, if asked, and click Display Token to view the command.
Create a new
Secretresource to contain the Transport Layer Security (TLS) certificate and the corresponding private key:oc create secret tls SECRET_NAME -n NAMESPACE --cert CERTIFICATE_FILE_NAME --key PRIVATE_KEY_FILE_NAME
oc create secret tls SECRET_NAME -n NAMESPACE --cert CERTIFICATE_FILE_NAME --key PRIVATE_KEY_FILE_NAMECopy to Clipboard Copied! Toggle word wrap Toggle overflow oc create secret tls keycloak-tls -n keycloak-system --cert certificate.pem --key key.pem
$ oc create secret tls keycloak-tls -n keycloak-system --cert certificate.pem --key key.pemCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe OpenShift’s service serving certificate can automate the generation and management of a TLS certificates for use by Keycloak. See Configuring OpenShift service serving certificates to generate TLS certificates for Keycloak for more information.
- In OpenShift web console, after the installation finishes, click the View Operator button.
- Click Create instance on the Keycloak tile.
On the Create Keycloak page, select YAML view.
-
On the
nameline, replaceexample-keycloakwith your custom name, for example,keycloak. The hostname can either be explicitly specified within the
hostnameproperty or automatically generated similar to other routes. On thehostnameline, replaceexample.orgwith your custom hostname.NoteSee Generating Keycloak host names automatically for the steps necessary to have OpenShift generate the hostname for the Keycloak instance.
Under the
specsection, add your database details:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Also, under the
specsection, for thehttpproperty, specify the name of theSecretresource containing the TLS certificates.spec: ... http: tlsSecret: keycloak-tls ...spec: ... http: tlsSecret: keycloak-tls ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click the Create button.
-
On the
- Expand the Networking navigation menu, and click Routes.
- To open the Keycloak Administration Console, click the link to the route associated with the Keycloak instance.
-
The default credentials for the
adminuser are stored in a Secret called keycloak-initial-admin. To locate the password, expand the Workloads navigation menu, and click Secrets. - Select the keycloak-initial-admin Secret.
- Under the Data section, locate the password key, and click the copy icon.
-
On the Keycloak Administration Console log in page, enter
temp-adminas the username, and paste the contents of the previous step as the password. Create a new realm called
trusted-artifact-signer.- On the navigation menu, select the Red Hat Build of Keycloak drop-down menu.
- Select Create Realm.
-
Enter
trusted-artifact-signeras the Resource name. - Click Create to create the new realm.
Create a new client.
- On the navigation menu, under the Manage section, and select Clients.
- Click the Create Client button
-
In the Client Id field, enter
trusted-artifact-signer. - Optionally, you can enter a Name and Description into the corresponding fields.
- Click Next.
- Accept the default options for the Capability Config step of the new client creation process.
- Click Next.
-
In the Valid redirect URIs field, enter
*. - Click Save to create the client.
-
On the navigation menu, under the Configure section, select Realm Settings to locate the Issuer URL for the
trusted-artifact-signerrealm. - Next to Endpoints, click the OpenID Endpoint Configuration link.
-
Copy the URL from the
issuerproperty. Under the
.spec.fulcio.config.OIDCIssuerssection of theSecureSignresource for RHTAS, replace CLIENT_ID withtrusted-artifact-signer, and paste the URL content to replace RHBK_REALM_ISSUER_URL:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.4.4. Configuring Amazon STS as an OpenID Connect provider for Trusted Artifact Signer Copiar o linkLink copiado para a área de transferência!
You can use Amazon’s Security Token Service (STS) as your OpenID Connect (OIDC) provider for Red Hat’s Trusted Artifact Signer (RHTAS) service. You can decide to configure Amazon STS during the deployment of RHTAS, or at a later time.
You can define several different OIDC providers in the same configuration.
Prerequisites
- Red Hat OpenShift Container Platform 4.15 or later.
-
Access to the OpenShift web console with the
cluster-adminrole. -
A workstation with the
oc,podman, andawsbinaries installed. - Enable managed Amazon Web Service (AWS) Resources for OpenShift environments.
A created Amazon Identity and Access Management (IAM) user with full permissions. This allows access to run IAM operations.
- Created access keys for this user.
Procedure
Open a terminal on your workstation, and log in to OpenShift:
oc login --token=TOKEN --server=SERVER_URL_AND_PORT
oc login --token=TOKEN --server=SERVER_URL_AND_PORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443
$ oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can find your login token and URL for use on the command line from the OpenShift web console. Log in to the OpenShift web console. Click your user name, and click Copy login command. Offer your user name and password again, if asked, and click Display Token to view the command.
Find the AWS OIDC provider URL:
oc get authentication cluster -o jsonpath='{.spec.serviceAccountIssuer}'$ oc get authentication cluster -o jsonpath='{.spec.serviceAccountIssuer}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update RHTAS the configuration.
Open for editing the
Securesignresource:oc edit Securesign NAME -n NAMESPACE
oc edit Securesign NAME -n NAMESPACECopy to Clipboard Copied! Toggle word wrap Toggle overflow oc edit Securesign securesign-sample -n trusted-artifact-signer
$ oc edit Securesign securesign-sample -n trusted-artifact-signerCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou must use the project name created for the RHTAS installation as the namespace.
Under the
OIDCIssuerssection, add a new subsection with your AWS STS client identifier, issuer’s URL, and set theTypevalue tokubernetes:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save your changes, and quit the editor. After a few seconds the operator automatically reconfigures the RHTAS software stack.
Configure the AWS command-line tool by entering your access key, secret key, default region, and output format:
aws configure
$ aws configureCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the following environment variables:
export account_id=$(aws sts get-caller-identity --query "Account" --output text) export oidc_provider="$(oc get authentication cluster -o jsonpath='{.spec.serviceAccountIssuer}' | cut -d '/' -f3-)" export role_name=rhtas-sts export namespace=rhtas-sts export service_account=cosign-sts$ export account_id=$(aws sts get-caller-identity --query "Account" --output text) $ export oidc_provider="$(oc get authentication cluster -o jsonpath='{.spec.serviceAccountIssuer}' | cut -d '/' -f3-)" $ export role_name=rhtas-sts $ export namespace=rhtas-sts $ export service_account=cosign-stsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Trust Policy that gets associated with newly created IAM roles:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new IAM role for the RHTAS service by using the trust policy:
aws iam create-role --role-name rhtas-sts --assume-role-policy-document file://trust-relationship.json --description "Red Hat Trusted Artifact Signer STS Role"
$ aws iam create-role --role-name rhtas-sts --assume-role-policy-document file://trust-relationship.json --description "Red Hat Trusted Artifact Signer STS Role"Copy to Clipboard Copied! Toggle word wrap Toggle overflow On the OpenShift cluster with STS enabled, create a new project namespace:
oc new-project NAMESPACE
oc new-project NAMESPACECopy to Clipboard Copied! Toggle word wrap Toggle overflow oc new-project rhtas-sts
$ oc new-project rhtas-stsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a service account for assuming an IAM role, and running a workload within the OpenShift project namespace.
Create the service account manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the service account manifest to OpenShift:
oc apply -f service_account.yaml
$ oc apply -f service_account.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create a new deployment workload for signing container images within a image registry.
Create the deployment manifest:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the deployment manifest to OpenShift:
oc apply -f deployment.yaml
$ oc apply -f deployment.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create a test container image to sign.
Create an empty container image:
echo "FROM scratch" > ./tmp.Dockerfile podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1h
$ echo "FROM scratch" > ./tmp.Dockerfile $ podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Push the empty container image to the
ttl.shephemeral registry:podman push ttl.sh/rhtas/test-image:1h
$ podman push ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the temporary Docker file:
rm ./tmp.Dockerfile
$ rm ./tmp.DockerfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Validate the configuration by signing and verifying the test container image.
Open a remote shell session within a running pod:
oc rsh -n NAMESPACE deployment/cosign-sts env IMAGE=IMAGE_NAME:TAG /bin/sh
oc rsh -n NAMESPACE deployment/cosign-sts env IMAGE=IMAGE_NAME:TAG /bin/shCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc rsh -n rhtas-sts deployment/cosign-sts env IMAGE=ttl.sh/rhtas/test-image:1h /bin/sh
$ oc rsh -n rhtas-sts deployment/cosign-sts env IMAGE=ttl.sh/rhtas/test-image:1h /bin/shCopy to Clipboard Copied! Toggle word wrap Toggle overflow Sign the container image:
cosign sign -y --identity-token=$(cat $AWS_WEB_IDENTITY_TOKEN_FILE) ttl.sh/rhtas/test-image:1h
$ cosign sign -y --identity-token=$(cat $AWS_WEB_IDENTITY_TOKEN_FILE) ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the signed container image:
cosign verify --certificate-identity=https://kubernetes.io/namespaces/$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)/serviceaccounts/cosign-sts --certificate-oidc-issuer=$COSIGN_CERTIFICATE_OIDC_ISSUER ttl.sh/rhtas/test-image:1h
$ cosign verify --certificate-identity=https://kubernetes.io/namespaces/$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)/serviceaccounts/cosign-sts --certificate-oidc-issuer=$COSIGN_CERTIFICATE_OIDC_ISSUER ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.4.5. Configuring GitHub as an OpenID Connect provider for Trusted Artifact Signer Copiar o linkLink copiado para a área de transferência!
You can use GitHub OAuth 2.0 when federating it with Red Hat’s Single Sign-On (SSO) service as an OpenID Connect (OIDC) provider for the Red Hat Trusted Artifact Signer (RHTAS) service. This procedure guides you on integrating GitHub OAuth with an existing Red Hat SSO deployment on OpenShift.
You can define several different OIDC providers in the same configuration.
Prerequisites
- Red Hat OpenShift Container Platform 4.15 or later.
- A running Red Hat SSO instance.
-
A workstation with the
ocbinary installed. Create a GitHub OAuth app, and after registering the application, make note of the client identifier and secret values.
ImportantWhen registering your new GitHub OAuth app, you must specify the Homepage URL, and the Authorization callback URL. Enter placeholder values for both of these fields, for example,
https://localhost:8080. Later in this procedure you will modify your GitHub OAuth app with the intended values for these fields.
Procedure
Open a terminal on your workstation, and log in to OpenShift:
oc login --token=TOKEN --server=SERVER_URL_AND_PORT
oc login --token=TOKEN --server=SERVER_URL_AND_PORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443
$ oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can find your login token and URL for use on the command line from the OpenShift web console. Log in to the OpenShift web console. Click your user name, and click Copy login command. Offer your user name and password again, if asked, and click Display Token to view the command.
Log in to the Red Hat SSO console.
Find the Red Hat SSO console URL from the command line:
oc get routes -n keycloak-system keycloak -o jsonpath='https://{.spec.host}'$ oc get routes -n keycloak-system keycloak -o jsonpath='https://{.spec.host}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Copy and paste the Red Hat SSO console URL into your web browser.
- Click Administration Console.
Retrieve the
adminpassword from the command line:oc get secret/credential-keycloak -n keycloak-system -o jsonpath='{ .data.ADMIN_PASSWORD }' | base64 -d$ oc get secret/credential-keycloak -n keycloak-system -o jsonpath='{ .data.ADMIN_PASSWORD }' | base64 -dCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the output from this command.
-
From your web browser, log in as the
adminuser, and paste the password in the corresponding field. Click the Sign In button.
- Select your realm from the dropdown on the navigation menu.
Add the GitHub identity provider.
- From the navigational menu, click Identity Providers.
- From the Add provider… drop-down menu, select GitHub.
- Add your GitHub OAuth client identifier to the Client ID field.
- Add your GitHub OAuth client secret to the Client Secret field.
- Turn on the Trust Email option.
- Click the Save button.
Add the identity provider mapper to the newly created identity provider.
- Click the Mapper tab.
- Click the Create button.
- Give a Name to the new mapper.
- Change the Mapper Type to Hardcoded Attribute.
-
Set the User Attribute field to
emailVerified. -
Set the User Attribute Value field to
true. - Click the Save button.
-
From the GitHub Identity Provider Settings page, copy the Redirect URI value and paste it to your GitHub OAuth app Authorization Callback URL field. Also, paste this same value into the Homepage URL field, but remove the
broker/github/endpointpart of the URL string. - Click Update Application. You can now sign commits, and containers by using GitHub as your OIDC provider.
- When signing artifacts, a web browser opens and prompts you to sign in to your Red Hat SSO account. Click the GitHub button to sign in with your credentials.
- Click the Authorize button to enable GitHub user details to be accessible by Red Hat SSO.
1.4.6. Configuring Microsoft Entra ID as an OpenID Connect provider for Trusted Artifact Signer Copiar o linkLink copiado para a área de transferência!
You can use Microsoft Entra ID as your OpenID Connect (OIDC) provider for Red Hat’s Trusted Artifact Signer (RHTAS) service. You can decide to configure Microsoft Entra ID during the deployment of RHTAS, or at a later time.
Integrating Microsoft Entra ID into RHTAS requires no subscriptions.
You can define several different OIDC providers in the same configuration.
Prerequisites
- Red Hat OpenShift Container Platform 4.15 or later.
- A Microsoft Azure account with permissions to create resources.
- An Azure verified email address for users signing artifacts.
- Access to the Microsoft Azure command-line interface.
-
A workstation with the
oc,cosign,podman, andazbinaries installed.
Procedure
- Open a terminal on your workstation.
Create an App Registration within Microsoft Entra ID representing a client:
export RHTAS_APP_REGISTRATION=$(az ad app create --display-name=rhtas --web-redirect-uris=http://localhost:0/auth/callback --enable-id-token-issuance --query appId -o tsv)
$ export RHTAS_APP_REGISTRATION=$(az ad app create --display-name=rhtas --web-redirect-uris=http://localhost:0/auth/callback --enable-id-token-issuance --query appId -o tsv)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new client secret that allows user to use the App Registration to get a ID token:
export RHTAS_APP_REGISTRATION_CLIENT_SECRET=$(az ad app credential reset --id=$RHTAS_APP_REGISTRATION --display-name="RHTAS Client Secret" -o tsv --query 'password')
$ export RHTAS_APP_REGISTRATION_CLIENT_SECRET=$(az ad app credential reset --id=$RHTAS_APP_REGISTRATION --display-name="RHTAS Client Secret" -o tsv --query 'password')Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteBy default, client secrets are only valid for one year. You can customize this value by using the
--yearsor--end-dateflags.Create a new Claim Mapping Policy to define a new JWT claim called
email_verified, use a static value oftrue:az rest -m post --headers Content-Type=application/json --uri https://graph.microsoft.com/v1.0/policies/claimsMappingPolicies --body '{"definition": ["{\"ClaimsMappingPolicy\":{\"Version\":1,\"IncludeBasicClaimSet\":\"true\", \"ClaimsSchema\":[{\"value\":\"true\",\"JwtClaimType\":\"email_verified\"}]}}"],"displayName": "EmailVerified"}'$ az rest -m post --headers Content-Type=application/json --uri https://graph.microsoft.com/v1.0/policies/claimsMappingPolicies --body '{"definition": ["{\"ClaimsMappingPolicy\":{\"Version\":1,\"IncludeBasicClaimSet\":\"true\", \"ClaimsSchema\":[{\"value\":\"true\",\"JwtClaimType\":\"email_verified\"}]}}"],"displayName": "EmailVerified"}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Get the App Registration object identifier:
export RHTAS_APP_REGISTRATION_OBJ_ID=$(az ad app show --id $RHTAS_APP_REGISTRATION --output tsv --query id)
$ export RHTAS_APP_REGISTRATION_OBJ_ID=$(az ad app show --id $RHTAS_APP_REGISTRATION --output tsv --query id)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the App Registration manifest:
az rest --method PATCH --uri https://graph.microsoft.com/v1.0/applications/${RHTAS_APP_REGISTRATION_OBJ_ID} --headers 'Content-Type=application/json' --body "{\"api\":{\"acceptMappedClaims\":true}}"$ az rest --method PATCH --uri https://graph.microsoft.com/v1.0/applications/${RHTAS_APP_REGISTRATION_OBJ_ID} --headers 'Content-Type=application/json' --body "{\"api\":{\"acceptMappedClaims\":true}}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new Service Principal and associate it with the App Registration:
export SERVICE_PRINCIPAL_ID=$(az ad sp create --id=${RHTAS_APP_REGISTRATION} -o tsv --query 'id')$ export SERVICE_PRINCIPAL_ID=$(az ad sp create --id=${RHTAS_APP_REGISTRATION} -o tsv --query 'id')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Get the Claim Mapping Policy identifier:
export CLAIM_MAPPING_POLICY_ID=$(az rest --uri https://graph.microsoft.com/v1.0/policies/claimsMappingPolicies -o tsv --query "value[?displayName=='EmailVerified'] | [0].id")
$ export CLAIM_MAPPING_POLICY_ID=$(az rest --uri https://graph.microsoft.com/v1.0/policies/claimsMappingPolicies -o tsv --query "value[?displayName=='EmailVerified'] | [0].id")Copy to Clipboard Copied! Toggle word wrap Toggle overflow Associate the Claim Mapping Policy with the Service Principal:
az rest -m post --headers Content-Type=application/json --uri "https://graph.microsoft.com/v1.0/servicePrincipals/${SERVICE_PRINCIPAL_ID}/claimsMappingPolicies/\$ref" --body "{\"@odata.id\": \"https://graph.microsoft.com/v1.0/policies/claimsMappingPolicies/${CLAIM_MAPPING_POLICY_ID}\"}"$ az rest -m post --headers Content-Type=application/json --uri "https://graph.microsoft.com/v1.0/servicePrincipals/${SERVICE_PRINCIPAL_ID}/claimsMappingPolicies/\$ref" --body "{\"@odata.id\": \"https://graph.microsoft.com/v1.0/policies/claimsMappingPolicies/${CLAIM_MAPPING_POLICY_ID}\"}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Get the tenant identifier:
export TENANT_ID=$(az account show -o tsv --query tenantId)
$ export TENANT_ID=$(az account show -o tsv --query tenantId)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Get OIDC endpoint:
export ENTRA_ID_OIDC_ENDPOINT=$(echo https://login.microsoftonline.com/${TENANT_ID}/v2.0)$ export ENTRA_ID_OIDC_ENDPOINT=$(echo https://login.microsoftonline.com/${TENANT_ID}/v2.0)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the RHTAS configuration.
Open for editing the
Securesignresource:oc edit Securesign NAME -n NAMESPACE
oc edit Securesign NAME -n NAMESPACECopy to Clipboard Copied! Toggle word wrap Toggle overflow oc edit Securesign securesign-sample -n trusted-artifact-signer
$ oc edit Securesign securesign-sample -n trusted-artifact-signerCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou must use the project name created for the RHTAS installation as the namespace.
Under the
OIDCIssuerssection, add a new subsection with the client identifier, issuer’s URL, and set theTypevalue toemail:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save your changes, and quit the editor. After a few seconds the operator automatically reconfigures the RHTAS software stack.
Create a local client secret file:
echo $RHTAS_APP_REGISTRATION_CLIENT_SECRET > rhtas-entra-id-client-secret
$ echo $RHTAS_APP_REGISTRATION_CLIENT_SECRET > rhtas-entra-id-client-secretCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure your shell environment for signing artifacts:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Initialize the local machine for signing:
cosign initialize
$ cosign initializeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the updated configuration by signing a test container image.
Create an empty container image:
echo "FROM scratch" > ./tmp.Dockerfile podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1h
$ echo "FROM scratch" > ./tmp.Dockerfile $ podman build . -f ./tmp.Dockerfile -t ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Push the empty container image to the
ttl.shephemeral registry:podman push ttl.sh/rhtas/test-image:1h
$ podman push ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the temporary Docker file:
rm ./tmp.Dockerfile
$ rm ./tmp.DockerfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Sign the container image:
cosign sign -y --oidc-client-secret-file=SECRET_FILE IMAGE_NAME:TAG
cosign sign -y --oidc-client-secret-file=SECRET_FILE IMAGE_NAME:TAGCopy to Clipboard Copied! Toggle word wrap Toggle overflow cosign sign -y --oidc-client-secret-file=rhtas-entra-id-client-secret ttl.sh/rhtas/test-image:1h
$ cosign sign -y --oidc-client-secret-file=rhtas-entra-id-client-secret ttl.sh/rhtas/test-image:1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow A web browser opens allowing you to sign the container image with an email address.
1.5. Configure an alternative database for Trusted Artifact Signer Copiar o linkLink copiado para a área de transferência!
You can replace the Red Hat Trusted Artifact Signer (RHTAS) default database for Trillian with an externally managed MariaDB database instance. The database instance can be a cloud-hosted database provider, such as Amazon’s Relational Database Service (RDS), or your own database deployment in OpenShift.
1.5.1. Prerequisites Copiar o linkLink copiado para a área de transferência!
- Red Hat OpenShift Container Platform version 4.13, 4.14, or 4.15.
1.5.2. Configuring Amazon RDS for Trusted Artifact Signer Copiar o linkLink copiado para a área de transferência!
With this procedure, you can replace Red Hat’s Trusted Artifact Signer (RHTAS) default database for Trillian with a MariaDB instance managed by Amazon’s Relational Database Service (RDS).
Red Hat recommends using a highly available MariaDB database for production workloads.
Prerequisites
- An Amazon Web Service (AWS) account with access to the Amazon RDS console.
-
Access to the OpenShift web console with the
cluster-adminrole. -
A workstation with the
oc,curl, and themysqlbinaries installed. - Command-line access with privileges to create a database and populate the MariaDB instance.
Procedure
Open the Amazon RDS console, and create a new MariaDB instance.
- Wait for the MariaDB instance to be deployed, and is available.
From your workstation, log in to the new database by providing the regional endpoint, the port, and the user credentials:
mysql -h REGIONAL_ENDPOINT -P 3306 -u USER_NAME -p
mysql -h REGIONAL_ENDPOINT -P 3306 -u USER_NAME -pCopy to Clipboard Copied! Toggle word wrap Toggle overflow mysql -h exampledb.1234.us-east-1.rds.amazonaws.com -P 3306 -u admin -p
$ mysql -h exampledb.1234.us-east-1.rds.amazonaws.com -P 3306 -u admin -pCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new database named
trillian:create database trillian;
create database trillian;Copy to Clipboard Copied! Toggle word wrap Toggle overflow Switch to the newly created database:
use trillian;
use trillian;Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new database user named
trillian, and set a PASSWORD for the newly created user:CREATE USER trillian@'%' IDENTIFIED BY 'PASSWORD'; GRANT ALL PRIVILEGES ON trillian.* TO 'trillian'@'%'; FLUSH PRIVILEGES;
CREATE USER trillian@'%' IDENTIFIED BY 'PASSWORD'; GRANT ALL PRIVILEGES ON trillian.* TO 'trillian'@'%'; FLUSH PRIVILEGES;Copy to Clipboard Copied! Toggle word wrap Toggle overflow Disconnect from the database:
EXIT
EXITCopy to Clipboard Copied! Toggle word wrap Toggle overflow Download the database configuration file:
curl -o dbconfig.sql https://raw.githubusercontent.com/securesign/trillian/main/storage/mysql/schema/storage.sql
$ curl -o dbconfig.sql https://raw.githubusercontent.com/securesign/trillian/main/storage/mysql/schema/storage.sqlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the database configuration to the new database:
mysql -h FQDN_or_SERVICE_ADDR -P 3306 -u USER_NAME -p PASSWORD -D DB_NAME < PATH_TO_CONFIG_FILE
mysql -h FQDN_or_SERVICE_ADDR -P 3306 -u USER_NAME -p PASSWORD -D DB_NAME < PATH_TO_CONFIG_FILECopy to Clipboard Copied! Toggle word wrap Toggle overflow mysql -h rhtasdb.example.com -P 3306 -u trillian -p mypassword123 -D trillian < dbconfig.sql
$ mysql -h rhtasdb.example.com -P 3306 -u trillian -p mypassword123 -D trillian < dbconfig.sqlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open a terminal on your workstation, and log in to OpenShift:
oc login --token=TOKEN --server=SERVER_URL_AND_PORT
oc login --token=TOKEN --server=SERVER_URL_AND_PORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443
$ oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can find your login token and URL for use on the command line from the OpenShift web console. Log in to the OpenShift web console. Click your user name, and click Copy login command. Offer your user name and password again, if asked, and click Display Token to view the command.
Create a new Secret containing the credentials for the Trillian database within the MariaDB instance which was created previously:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can use an OpenShift internal service name for the MariaDB instance.
- You can now deploy the Trusted Artifact Signer service to use this database. If you were following the Trusted Artifact Signer installation procedure, then you can proceed to the next step.
1.5.3. Configuring a database in OpenShift for Trusted Artifact Signer Copiar o linkLink copiado para a área de transferência!
With this procedure, you can replace Red Hat’s Trusted Artifact Signer (RHTAS) default database for Trillian with a MariaDB instance managed by Amazon’s Relational Database Service (RDS).
Red Hat recommends using a highly available MariaDB database for production workloads.
Prerequisites
- Permissions to create an OpenShift project, and deploy a database instance from the OpenShift samples catalog.
-
Access to the OpenShift web console with the
cluster-adminrole. -
A workstation with the
oc,curl, and themysqlbinaries installed. - Command-line access with privileges to create a database and populate the MariaDB instance.
Procedure
- Log in to the OpenShift web console where you are deploying the RHTAS service:
- Change to the Developer perspective.
Select the
trusted-artifact-signerproject, if the project already exists, else create a new project for the database:- To create a new project, click the drop-down project menu, and click the Create Project button.
-
Name the new project
trusted-artifact-signer, and click the Create button.
- On the Developer Catalog card, click Database.
Select MariaDB, and click the Instantiate Template button.
ImportantDo not select MariaDB (Ephemeral).
On the Instantiate Template page, configure the following fields:
-
In the MariaDB Database Name field, enter
trillian. -
In the Volume Capacity field, enter
5Gi. - Click the Create button.
-
In the MariaDB Database Name field, enter
Begin a remote shell session:
- On the Topology page, selecting the MariaDB pod brings up a side panel, click the Resources tab.
- Under the Pods section, click on the MariaDB pod name.
- Click the Terminal tab to start a remote shell session to the MariaDB pod.
In the remote shell session, verify that you can connect to the Trillian database:
mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DATABASE
$ mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DATABASECopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteCredentials are stored in a secret object with the service name (
mariadb), and contains the name of the database, and user name, along with the database root password. Make a note of these credentials as they will be used later on when creating the database secret object.Disconnect from the database:
EXIT
EXITCopy to Clipboard Copied! Toggle word wrap Toggle overflow Download the database configuration file:
curl -o dbconfig.sql https://raw.githubusercontent.com/securesign/trillian/main/storage/mysql/schema/storage.sql
$ curl -o dbconfig.sql https://raw.githubusercontent.com/securesign/trillian/main/storage/mysql/schema/storage.sqlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the database configuration to the new database:
mysql -h FQDN_or_SERVICE_ADDR -P 3306 -u USER_NAME -p PASSWORD -D DB_NAME < PATH_TO_CONFIG_FILE
mysql -h FQDN_or_SERVICE_ADDR -P 3306 -u USER_NAME -p PASSWORD -D DB_NAME < PATH_TO_CONFIG_FILECopy to Clipboard Copied! Toggle word wrap Toggle overflow mysql -h rhtasdb.example.com -P 3306 -u trillian -p mypassword123 -D trillian < dbconfig.sql
$ mysql -h rhtasdb.example.com -P 3306 -u trillian -p mypassword123 -D trillian < dbconfig.sqlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open a terminal on your workstation, and log in to OpenShift:
oc login --token=TOKEN --server=SERVER_URL_AND_PORT
oc login --token=TOKEN --server=SERVER_URL_AND_PORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443
$ oc login --token=sha256~ZvFDBvoIYAbVECixS4-WmkN4RfnNd8Neh3y1WuiFPXC --server=https://example.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can find your login token and URL for use on the command line from the OpenShift web console. Log in to the OpenShift web console. Click your user name, and click Copy login command. Offer your user name and password again, if asked, and click Display Token to view the command.
Create a new Secret containing the credentials for the Trillian database within the MariaDB instance which was created previously:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can use an OpenShift internal service name for the MariaDB instance.
- You can now deploy the Trusted Artifact Signer service to use this database. If you were following the Trusted Artifact Signer installation procedure, then you can proceed to the next step.
1.6. Configuring OpenShift service serving certificates to generate TLS certificates for Keycloak Copiar o linkLink copiado para a área de transferência!
OpenShift’s service serving certificate can automate the generation and management of Transport Layer Security (TLS) certificates for use by Keycloak. Infrastructure components, such as the Ingress Controller, within an OpenShift cluster will trust these TLS certificates.
Prerequisites
- Red Hat OpenShift Container Platform 4.15 or later.
- Installation of the Red Hat build of Keycloak (RHBK) Operator.
-
Access to the OpenShift web console with the
cluster-adminrole.
Procedure
- In OpenShift web console, from the Administrator perspective, expand Home from the navigation menu, and click Projects.
-
Search for
keycloak, and select thekeycloak-systemnamespace. Create a new service.
- Click the + icon.
In the Import YAML text box, copy the example, and paste it into the text box.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click the Create button.
- Expand Operators from the navigation menu, click Installed Operators, and click the Red Hat build of Keycloak Operator tile.
In the YAML view of the
Keycloakresource, under thespecsection, add theingressproperty:Copy to Clipboard Copied! Toggle word wrap Toggle overflow By default, the Keycloak Operator creates Ingress resources instead of routes. OpenShift automatically creates a route based on the Ingress definition.
Specify the name of the secret containing the TLS certificate, under the
specsection:spec: ... http: tlsSecret: keycloak-tls ...spec: ... http: tlsSecret: keycloak-tls ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Once Keycloak starts, OpenShift’s service serving certificate starts generating TLS certificates for Keycloak.
1.7. Generating Keycloak host names automatically Copiar o linkLink copiado para a área de transferência!
OpenShift routes has support for automatically generating host names by using a set pattern. This feature can integrate with Red Hat’s build of Keycloak (RHBK) operator running on OpenShift.
Prerequisites
- Red Hat OpenShift Container Platform 4.15 or later.
- Installation of the RHBK operator.
-
Access to the OpenShift web console with the
cluster-adminrole. -
A workstation with the
ocbinary installed.
Procedure
Enable the automatically generated route hostname feature.
Under the
.specsection, remove the entirehostnamesection, and replace it with theingresssection andclassNameproperty within theKeycloakresource:spec: ... [.line-through]#hostname:# [.line-through]#hostname: example.com# ...spec: ... [.line-through]#hostname:# [.line-through]#hostname: example.com# ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow spec: ... ingress: className: openshift-default ...spec: ... ingress: className: openshift-default ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteTo view all of the available Ingress classes, run the following command:
oc get ingressclass
$ oc get ingressclassCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Click the Save button.
Verify the automatically generated
hostnameby clicking the Reload button to view the latest configuration:spec: ... hostname: hostname: example-keycloak-ingress-keycloak-system.apps.rhtas.example.com ...spec: ... hostname: hostname: example-keycloak-ingress-keycloak-system.apps.rhtas.example.com ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow