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
Merge pull request #822 from dwnusbaum/dynamic-installation-access-token-restrictions
Add new options to GitHub App credentials to allow dynamic restrictions of the repositories and permissions available to installation access tokens in some contexts
Copy file name to clipboardExpand all lines: docs/github-app.adoc
+39-2Lines changed: 39 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,8 +87,9 @@ Fill out the form:
87
87
- App ID: the github app ID, it can be found in the 'About' section of your GitHub app in the general tab.
88
88
- API endpoint (optional, only required for GitHub enterprise this will only show up if a GitHub enterprise server is configured).
89
89
- Key: click add, paste the contents of the converted private key
90
-
- Advanced: (optional) If you've installed your same GitHub app on multiple organizations you need the next step
91
-
* Owner: the name of the organisation or user, i.e. jenkinsci for https://github.com/jenkinsci
90
+
- Advanced: (optional):
91
+
* Repository access strategy: Controls what GitHub repositories will be accessible to these credentials in untrusted contexts (see below for details)
92
+
* Default permissions strategy: Controls what GitHub permissions will be accessible to these credentials in untrusted contexts (see below for details)
92
93
- Click OK
93
94
94
95
=== link:https://github.com/jenkinsci/configuration-as-code-plugin[Configuration as Code Plugin]
@@ -135,6 +136,42 @@ Verify at the bottom of the scan log it says:
135
136
Finished: SUCCESS
136
137
----
137
138
139
+
=== Enhancing security using repository access strategies and default permissions strategies
140
+
141
+
GitHub App Credentials offer advanced configuration options that can provide additional security in some scenarios.
142
+
In particular, when GitHub App Credentials are used by an Organization Folder or Multibranch Pipeline, these strategies may dynamically restrict the accessible repositories and permissions available to the credentials when they are accessed in untrusted contexts, such as when they are accessed by a `withCredentials` step in one of the individual Pipeline jobs.
143
+
See link:https://www.jenkins.io/doc/book/security/securing-org-folders-and-multibranch-pipelines/[this documentation] for additional information on why it may be beneficial to limit credentials in this way.
144
+
These strategies do not apply when using the credentials in trusted contexts, such as during organization folder scans and branch indexing.
145
+
Note also that Jenkins users who have Job/Configure permission in a context where the credentials are available are considered trusted and can bypass these strategies by configuring jobs as desired.
146
+
In trusted contexts, the generated access tokens will have the same access as configured for the app installation in GitHub.
147
+
148
+
The following repository access strategies are available:
149
+
* **Infer owner and allow access to all owned repositories** (Default)
150
+
* The credentials may only be used in contexts where a GitHub organization can be inferred, such as Organization Folders and Multibranch Pipelines
151
+
* The access tokens generated in untrusted contexts will be able to access all repositories in the inferred GitHub organization that are accessible to the GitHub App installation.
152
+
* **Infer accessible repository**
153
+
* The credentials may only be used in contexts where a GitHub organization and repository can be inferred, such as Organization Folders and Multibranch Pipelines
154
+
* The access tokens generated in untrusted contexts will only be able to access the inferred repository
155
+
* **Specify accessible repositories**
156
+
* The access tokens generated in untrusted contexts will be able to access the repositories specified statically in the credential configuration
157
+
* If the GitHub app is installed in a single organization, the owner field may be left blank empty, in which case that organization will be accessed automatically
158
+
* Leaving the repositories field empty will result in all repositories accessible to the configured owner being accessible
159
+
160
+
The following default permissions strategies are available:
161
+
* Read-only access to repository contents
162
+
* The access tokens generated in untrusted contexts will only be able to read the repository contents
163
+
* Read and write access to repository contents
164
+
* The access tokens generated in untrusted contexts will only be able to read and write the repository contents
165
+
* All permissions available to the app installation (default)
166
+
* The access tokens generated in untrusted contexts will have the same permissions as the app installation in GitHub
167
+
168
+
==== Repository access strategies and Pipeline libraries
169
+
170
+
Repository inference for GitHub App Credentials does not work when checking out Pipeline libraries.
171
+
If you have a GitHub App Credential for an Organization Folder or Multibranch Pipeline whose individual Pipeline jobs access a Pipeline library, the contextually inferred repository for the library checkout will be the repository for the Pipeline job rather than the library.
172
+
This means that the library will be inaccessible if you use an inference-based repository access strategy which only provides access to a single contextually-inferred repository, or if the Pipeline library is in a different GitHub organization than the repository being built.
173
+
For now, in this case, you either need to use a less restrictive strategy for the GitHub App credential, such as "Infer owner and allow access to all owned repositories", or you can define a second credential specifically for the Pipeline library which uses "Specify accessible repositories" and only allows access to the repository for the Pipeline library.
174
+
138
175
=== Help?
139
176
140
177
Raise an issue on link:https://issues.jenkins-ci.org/[Jenkins jira]
0 commit comments