Skip to content

Commit 2904013

Browse files
authored
Merge pull request #663 from gaurav-nelson/fixes-163-token-scopes
Fix: Update GitHub token instructions for DevSecOps pattern
2 parents 64eea16 + f5b6856 commit 2904013

1 file changed

Lines changed: 35 additions & 4 deletions

File tree

content/patterns/devsecops/getting-started.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ aliases: /devsecops/getting-started/
1111
1. An OpenShift cluster (Go to [the OpenShift console](https://console.redhat.com/openshift/create)). Cluster must have a dynamic StorageClass to provision PersistentVolumes. See also [sizing your cluster](../../devsecops/cluster-sizing).
1212
1. A second OpenShift cluster for development using secure CI pipelines.
1313
1. A third OpenShift cluster for production. (optional but desirable)
14-
1. A GitHub account (and a token for it with repositories permissions, to read from and write to your forks)
14+
1. A GitHub account and a personal access token. The Tekton CI/CD pipelines use this token to clone repositories, push commits, and create pull requests. You can use either a classic token or a fine-grained token. For details, see [GitHub token scopes](#github-token-scopes).
1515
1. Tools Podman and Git. (see below)
1616

1717
If you do not have running Red Hat OpenShift clusters you can start one on a
@@ -23,17 +23,18 @@ service](https://console.redhat.com/openshift/create).
2323
In addition to the openshift cluster, you will need to prepare a number of secrets, or credentials, which will be used
2424
in the pattern in various ways. To do this, copy the [values-secret.yaml template](https://github.com/validatedpatterns/multicluster-devsecops/blob/main/values-secret.yaml.template) to your home directory as `values-secret.yaml` and replace the explanatory text as follows:
2525

26-
* Your git repository username and password. The password must be base64 encoded.
26+
* Your GitHub username and personal access token. Use the token as the password value. For required token scopes, see [GitHub token scopes](#github-token-scopes). The token must be base64 encoded.
2727

2828
```yaml
2929
---
3030
secrets:
3131
# NEVER COMMIT THESE VALUES TO GIT
3232
git:
3333
# Go to: https://github.com/settings/tokens
34-
# Then: echo -n 'your string value' | base64
34+
# For required scopes, see the "GitHub token scopes" section in the docs
35+
# Then: echo -n 'your-token' | base64
3536
username: USERNAME
36-
password: 'encoded password in single quotes'
37+
password: 'encoded token in single quotes'
3738
```
3839
3940
* You application secret. TBD This may change when the application is changed.
@@ -47,6 +48,36 @@ secrets:
4748
secret: PLAINTEXT
4849
```
4950
51+
## GitHub token scopes
52+
53+
The Tekton CI/CD pipelines require a GitHub personal access token to clone repositories, push commits, and create pull requests. You can use a classic token or a fine-grained token.
54+
55+
### Option 1: Classic token
56+
57+
Create a [personal access token (classic)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) with the following scope:
58+
59+
| Scope | Reason |
60+
|-------|--------|
61+
| **`repo`** | Grants read and write access to repositories, including the ability to create pull requests |
62+
63+
To create the token, go to [GitHub Settings > Tokens](https://github.com/settings/tokens).
64+
65+
### Option 2: Fine-grained token
66+
67+
If you prefer more restrictive permissions, create a [fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) with the following repository permissions:
68+
69+
| Permission | Access | Reason |
70+
|------------|--------|--------|
71+
| **Contents** | Read and write | Clone repositories and push commits |
72+
| **Pull requests** | Read and write | Create pull requests through the GitHub API |
73+
74+
When you create a fine-grained token, you must also configure these settings:
75+
76+
- **Resource owner**: Select the GitHub account or organization that owns your fork.
77+
- **Repository access**: Grant access to your fork of the `multicluster-devsecops` repository. If the pipelines interact with additional repositories, include those as well.
78+
79+
> **Note:** Fine-grained tokens are scoped to specific repositories and owners. If your organization restricts fine-grained token usage, you must use a classic token instead.
80+
5081
# Preparing to deploy
5182

5283
1. Install the installation tooling dependencies. See [Patterns quick start](/learn/quickstart/)

0 commit comments

Comments
 (0)