You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -61,21 +62,20 @@ There are three options available to support automated GitHub Action and Workflo
61
62
- ➖ **The token can only access a repository containing the workflow file**. If you need to access other private repositories or require write access to other public repositories this token will not be sufficient.
62
63
- ➖ **The token cannot trigger other workflows**. If you have a workflow that creates a release and another workflow that runs when someone creates a release, the first workflow will not trigger the second workflow if it utilises this token based mechanism for authentication.
2.[GitHub PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) (fine-grained Personal Access Token)
65
66
66
-
- ➕ **Simple to set up**. You can create a [fine-grained personal access token](https://github.com/settings/tokens?type=beta) with a repository scope or a [classic personal access token](https://github.com/settings/tokens) with a wider permission model that extends beyond a single repository.
67
+
- ➕ **Simple to set up**. You can create a [fine-grained personal access token](https://github.com/settings/tokens?type=beta) with a repository scope. Classic personal access token should never be used.
68
+
- ➕ **GitHub PAT provides a more fine-grained permission model** than the built-in `GITHUB_TOKEN`
67
69
- ➕ **The token can trigger other workflows**.
68
-
- ➕ **It can access all repositories you have access to** (using a classic PAT). This is convenient because you can access other repositories without any additional setup.
69
-
- ➖ **It can access all your repositories you have access to** (using a classic PAT). You do not have fine-grained control over which repositories this token can access because this token represents you.
70
70
- ➖ **It is bound to a person**. The owner of the token leaving the organisation can cause your workflow to break.
- ➕ **You can control which repositories your token has access to** by installing the GitHub App to selected repositories.
75
75
- ➕ **An organisation can own multiple GitHub Apps** and they do not consume a team seat.
76
-
- ➕ **GitHub App provides a more fine-grained permission model**.
76
+
- ➕ **GitHub App provides a more fine-grained permission model** than the built-in `GITHUB_TOKEN`
77
77
- ➕ **The token can trigger other workflows**.
78
-
- ➖ **Not very well documented**.
78
+
- ➖ **Not very well documented**. Despite the extensive content of the GitHub documentation, it does not effectively communicate the pros & cons, use-cases and comparison of each authentication method. This was one of the reasons we created this ADR.
79
79
- ➖ **The setup is a bit more complicated**.
80
80
81
81
### Outcome
@@ -89,7 +89,7 @@ A `GITHUB_TOKEN` is automatically generated and used within GitHub Action and Wo
89
89
90
90
This method <u>enables basic operations</u> expected from the repository pipeline, like accessing GitHub secret variables.
91
91
92
-
#### GitHub PAT (Personal Access Token)
92
+
#### GitHub PAT (fine-grained Personal Access Token)
93
93
94
94
Use personal access token when:
95
95
@@ -117,7 +117,7 @@ Use app when:
117
117
118
118
-**Acting on behalf of a user or an organisation**: GitHub Apps can be installed directly onto an organisation or a user account and can access specific repositories. They act as separate entities and do not need a specific user to authenticate actions, thus separating the app's actions from individual users and preventing user-related issues (like a user leaving the organisation) from disrupting the app's operation. In this model, a GitHub App can act on behalf of a user to perform actions that the user has permissions for. For example, if a GitHub App is used to manage issues in a repository, it can act on behalf of a user to open, close, or comment on issues. The actions the app can perform are determined by the user's permissions and the permissions granted to the app during its installation.
119
119
120
-
-**When you need fine-grained permissions**: GitHub Apps provide more detailed control over permissions than the classic PAT. You can set access permissions on a per-resource basis (issues, pull requests, repositories, etc.). This allows you to follow the principle of least privilege, granting your app only the permissions it absolutely needs.
120
+
-**When you need fine-grained permissions**: GitHub Apps provide more detailed control over permissions than the classic PAT, which should no longer be used. You can set access permissions on a per-resource basis (issues, pull requests, repositories, etc.). This allows you to follow the principle of least privilege, granting your app only the permissions it absolutely needs.
121
121
122
122
-**Webhook events**: GitHub Apps can be configured to receive a variety of webhook events. Unlike personal tokens, apps can receive granular event data and respond accordingly. For instance, an app can listen for `push` events to trigger a CI/CD pipeline or `issue_comment` events to moderate comments.
123
123
@@ -156,6 +156,10 @@ To be executed by a GitHub organisation owner:
156
156
157
157
- Install the `[Team] [Repository Name] [Purpose]` app on the GitHub organisation and set repository access to the `[repository-name]` only
158
158
159
+
#### Recommendation for GitHub Admins
160
+
161
+
It is advisable to create a separate bot account for each service or programme. This approach fosters responsible ownership practices. It also allows the team to use the bot's identity for signing commits and integrating their service with other SaaS products, such as SonarCloud, without relying on individual team member accounts. Exceptions can be made on a case-by-case basis, allowing for the use of a central organisation account instead.
162
+
159
163
### Diagram
160
164
161
165
#### Context diagram showing the GitHub App setup
@@ -200,8 +204,6 @@ Please, see the above being implemented for the _update from template_ capabilit
200
204
-[GitHub account (bot)](https://github.com/update-from-template-app) linked to an `nhs.net` email address, but not part of any GitHub organisation
201
205
-[GitHub App (registration)](https://github.com/apps/nhs-england-update-from-template) to be installed within the GitHub organisations in use, e.g. `nhs-england-tools`
202
206
203
-
<spanstyle="color:red">A recommendation for GitHub Admins:</span> It is advisable to create a separate bot account for each service. This approach fosters responsible ownership practices. It also allows the team to use the bot's identity for signing commits and integrating their service with other SaaS products, such as SonarCloud, without relying on individual team member accounts. Exceptions can be made on a case-by-case basis, allowing for the use of a central organisation account instead.
204
-
205
207
#### Authentication flow diagram
206
208
207
209
The diagram below represents all the steps needed for an app implementation (aka app runner) to be authenticated and authorised to perform operations defined by the GitHub App registration and installation.
Copy file name to clipboardExpand all lines: docs/user-guides/Perform_static_analysis.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,17 +21,18 @@ Static code analysis is an essential part of modern software development. It pro
21
21
22
22
## Configuration checklist
23
23
24
-
- Create your [SonarCloud](https://sonarcloud.io) project
24
+
- Contact the GitHub Admins via email to have your [SonarCloud](https://sonarcloud.io) project created within the organisation space
25
+
- Create a bot account for your service. For more details, please see this [note](../../docs/adr/ADR-003_Acceptable_use_of_GitHub_PAT_and_Apps_for_authN_and_authZ.md#recommendation-for-github-admins). This account should be given access to your project and must own the `SONAR_TOKEN` for security reasons. Use this account to complete the rest of the activities in the Sonar service
25
26
- Navigate to project `Administration > Analysis Method > Manually` and select `Other (for JS, TS, Go, Python, PHP, ...)`
26
-
- In the [sonar-scanner.properties](../../scripts/config/sonar-scanner.properties) file, set the following properties according to the information provided above
27
-
-`sonar.[language].[coverage-tool].reportPaths` to ensure the unit test coverage is reported back to Sonar
27
+
- In the [sonar-scanner.properties](../../scripts/config/sonar-scanner.properties) file in your repository, set the following properties according to the information provided above
28
+
-Set `sonar.[language].[coverage-tool].reportPaths` to ensure the unit test coverage is reported back to Sonar
28
29
- Do not set the `sonar.organization` and `sonar.projectKey` properties in this file; do the next step instead
29
30
- Follow the documentation on [creating encrypted secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) to add the `SONAR_TOKEN` secret to your repository. The GitHub action is already configured to fetch that secret and pass it as a variable. In addition to that:
30
31
- Add `SONAR_ORGANISATION_KEY` variable (not a secret)
31
32
- Add `SONAR_PROJECT_KEY` variable (not a secret)
32
33
- Navigate to project `Administration > Analysis Method` and turn off the `Automatic Analysis` option
33
-
- Please, refrain from adding your repository to the GitHub SonarCloud App. Doing so will duplicate reports and initiate them outside the primary pipeline workflow
34
-
- Confirm that the GitHub action is part of your GitHub CI/CD workflow and enforces the "Sonar Way" quality gates. You can find more information about this in the [NHSE Software Engineering Quality Framework](https://github.com/NHSDigital/software-engineering-quality-framework/blob/main/tools/sonarqube.md)
34
+
- Please, refrain from adding your repository to the GitHub SonarCloud App, as this app should not be used. Doing so will duplicate reports and initiate them outside the primary pipeline workflow
35
+
- Confirm that the _"Perform static analysis"_GitHub action is part of your GitHub CI/CD workflow and enforces the _"Sonar Way"_ quality gates. You can find more information about this in the [NHSE Software Engineering Quality Framework](https://github.com/NHSDigital/software-engineering-quality-framework/blob/main/tools/sonarqube.md)
0 commit comments