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
Copy file name to clipboardExpand all lines: _docs/administration/oauth-setup.md
+99-54Lines changed: 99 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,42 @@
1
1
---
2
-
title: "Set up OAuth2 authentication"
2
+
title: "Set up OAuth2 authentication for Git providers"
3
3
description: ""
4
4
group: administration
5
5
toc: true
6
6
---
7
7
8
-
Easily Connect Codefresh to your Git provider using OAuth2.
9
-
Codefresh integrates with Git to sync repositories to your clusters, implementing Git-based operations when creating resources such as Delivery Pipelines, and to enrich Images with valuable information.
8
+
Codefresh integrates with the Git provider defined for your runtime account to sync repositories to your clusters, implementing Git-based operations when creating resources such as Delivery Pipelines, applications, and enriching images with valuable information.
10
9
10
+
As the account administrator, you can select the authentication method for a runtime account. Users in Codefresh will then authorize access to the Git providers through the defined mechanism.
11
11
12
-
Codefresh supports OAuth2 or Personal Access Tokens (PATs) for authentication:
13
-
14
-
* OAuth2 with Codefresh OAuth Application or custom OAuth2 Application
OAuth2 is the preferred authentication mechanism, currently supported for GitHub. You have the option to use the default pre-defined Codefresh OAuth Application, or your own Oauth2 Application in your Git account.
17
-
To use your own Oauth2 GitHub Application, create a secret on your K8s cluster and configure it in Authentication > Settings. See [Create a custom OAuth2 provider account](#create-a-custom-oauth2-provider-account) in this article.
18
-
22
+
Codefresh supports OAuth2 or personal access tokens (PATs) for authentication:
19
23
20
-
> A runtime can have only one active account for authentication.
24
+
* OAuth2 with Codefresh OAuth Application or custom OAuth2 Application
25
+
OAuth2 is the preferred authentication mechanism, supported for popular Git providers such as GitHub, GitHub Enterprise, GitLab Cloud and Server, and Bitbucket Cloud and Server.
26
+
You have the option to use the default predefined Codefresh OAuth Application, or a custom Oauth2 Application for Codefresh in your Git provider account.
27
+
Hosted runtime accounts automatically use Codefresh's predefined OAuth Application.
28
+
To use a custom Oauth2 Application for Codefresh, first create the application in your Git provider account, then create a secret on your K8s cluster, and finally configure OAuth2 access for the custom application in Authentication > Settings. See [Create a custom OAuth2 Application for Git provider](#create-a-custom-oauth2-provider-account) in this article.
21
29
22
30
* Token-based authentication using PAT
23
-
With token-based authentication, users must enter their personal access tokens when prompted to authorize access. Token-based authentication for users is described in [Managing Git personal access tokens]({{site.baseurl}}/docs/administration/user-settings/).
31
+
With token-based authentication, users must generate personal access tokens from their Git providers with the required scopes and enter their personal access tokens when prompted to authorize access. See [Authorize Git access in Codefresh]({{site.baseurl}}/docs/administration/user-settings/#authorize-git-access-in-codefresh).
32
+
33
+
24
34
35
+
### Authentication for Git providers and runtime accounts
36
+
The [Authentication](https://g.codefresh.io/2.0/account-settings/authentication?providerName=github){:target="\_blank"} page displays the accounts by Git provider and the authentication method selected for the same.
25
37
26
-
### Authentication provider accounts
27
-
The authentication accounts created for a provider are displayed in the [Authentication](https://g.codefresh.io/2.0/account-settings/authentication?providerName=github){:target="\_blank"}.
38
+
Authentication accounts are organized by Runtimes. A runtime can have a single authentication account.
39
+
The Type column identifies the authentication for the provider account as either Codefresh, Custom, or PAT (personal access token).
28
40
29
41
{% include
30
42
image.html
@@ -33,42 +45,71 @@ The authentication accounts created for a provider are displayed in the [Authent
The authentication accounts are organized by Runtimes. Every runtime can have a single authentication account.
39
-
The Type column identifies the provider account type as either Codefresh or Custom. You can change the provider type to Codefresh or Custom or select manual token entry as the authentication.
50
+
51
+
As the account administrator, you can change the authentication method for an account at any time to either Codefresh or Custom, or manual token entry. See [Select authentication mechanism for runtime](#select-authentication-mechanism-for-runtime).
40
52
53
+
### Create a custom OAuth2 Application for Git provider
54
+
Create a custom OAuth2 Application for Codefresh in your Git provider accounts with the correct scopes, and set up authentication for the same within Codefresh. Users in Codefresh can then authorize access to the Git provider using OAuth2, instead of a personal access token.
41
55
42
-
### Create a custom OAuth2 provider account
43
-
Codefresh account administrators can create an OAuth2 Application in GitHub, and set up authentication within Codefresh. Users in Codefresh can then authorize access to GitHub using OAuth2, instead of generating a personal access token to perform Git-based actions.
56
+
Supported Git providers:
57
+
* GitHub and GitHub Enterprise
58
+
* GitLab Cloud and GitLab Server
59
+
* Bitbucket Cloud (hosted) and Bitbucket Server (hybrid)
44
60
45
-
To set up OAuth2 authorization for GitHub in Codefresh, you must:
46
-
* Create a GitHub OAuth2 Application for Codefresh
47
-
* Create a K8s `secret` in the runtime cluster with OAuth2 Application credentials
48
-
* Configure OAuth2 settings in Codefresh to create a K8s `ConfigMap` that references the secret
61
+
{::nomarkdown}
62
+
<br>
63
+
{:/}
49
64
50
-
#### Step 1: Create GitHub OAuth2 Application
65
+
To set up OAuth2 authorization in Codefresh, you must:
66
+
1.[Create Custom OAuth2 Application in Git](#step-1-create-a-custom-oauth2-application-in-git)
67
+
1.[Create a K8s `secret` in the runtime cluster](#step-2-create-a-k8s-secret-resource-in-the-runtime-cluster)
68
+
1.[Configure OAuth2 settings for Custom Application in Codefresh](#step-3-configure-oauth2-settings-for-custom-application-in-codefresh)
69
+
70
+
{::nomarkdown}
71
+
<br>
72
+
{:/}
73
+
74
+
#### Step 1: Create a custom OAuth2 Application in Git
51
75
Create and register an OAuth App under your organization to authorize Codefresh.
52
76
53
-
> Make sure your OAuth app has `repo` scope with write access to code. For more information, see [Scopes for OAuth apps](https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps){:target="\_blank"}.
77
+
1. Follow the step-by-step instructions for your Git provider:
`<ingressHost>` is the IP address or URL of the ingress host in the runtime cluster.
54
100
55
-
1. Follow the step-by-step instructions in [GitHub](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app){:target="\_blank"}.
56
-
For the `Authorization callback URL`, enter this value:
`<ingressHost>` is the IP address or URL of the ingress host in the runtime cluster.
60
-
1. Make sure **Enable Device Flow** is _not_ selected.
61
-
1. Select **Register application**.
62
-
The client ID is automatically generated, and you are prompted to generate the client secret.
63
-
1. Select **Generate a new client secret**, and copy the generated secret.
64
-
1. Note down the following:
65
-
* Application ID from the URL
66
-
* Client ID and the client secret
101
+
{:start="2"}
102
+
1. Note down the following, as you will need them to create the K8s secret for the Git OAuth2 application:
103
+
* GitHub: Application ID from the URL, Client ID, and the client secret
104
+
* GitLab Cloud and Server: Application ID and Secret
105
+
* Bitbucket Server: Key and Secret
67
106
68
-
You need them to create the K8s secret for the GitHub OAuth2 application.
107
+
{::nomarkdown}
108
+
<br>
109
+
{:/}
69
110
70
111
#### Step 2: Create a K8s secret resource in the runtime cluster
71
-
Create a K8s secret in the runtime cluster, using the example below as a guideline. You must define the application ID (`appId`), client ID (`clientId`) and the client secret (`clientSecret`) from the GitHub OAuth2 Application you created, and the GitHub URL (`url`).
112
+
Create a K8s secret in the runtime cluster, using the example below as a guideline. You must define the application ID (`appId`), client ID (`clientId`) and the client secret (`clientSecret`) from the OAuth2 Application you created in your Git provider, and the Git URL (`url`).
72
113
73
114
> All fields in the secret _must be_ encoded in `base64`.
74
115
To encode, use this command: `echo -n VALUE | base64`.
@@ -77,10 +118,10 @@ Create a K8s secret in the runtime cluster, using the example below as a guideli
77
118
**Before you begin**
78
119
79
120
Make sure you have the following handy:
80
-
* Application ID from the application's URL
81
-
*Client ID
82
-
*Client secret
83
-
* GitHub URL
121
+
*GitHub: Application ID from the URL, Client ID, and the client secret
122
+
*GitLab Cloud and Server: Application ID and Secret
123
+
*Bitbucket Server: Key and Secret
124
+
84
125
85
126
**How to**
86
127
@@ -96,27 +137,31 @@ metadata:
96
137
labels:
97
138
codefresh_io_entity: git-pat-obtainer-sec
98
139
data:
99
-
appId: # application ID of your OAuth app from GitHub
100
-
clientId: # client ID of your OAuth app from GitHub
101
-
clientSecret: # client secret of your OAuth app from GitHub
102
-
url: https://github.com #GitHub provider URL which by default is github.com, unless self-hosted provider
140
+
appId: # application ID of your OAuth app
141
+
clientId: # client ID of your OAuth app
142
+
clientSecret: # client secret of your OAuth app
143
+
url: https://github.com #Git provider URL which by default is github.com, unless self-hosted provider
103
144
```
104
145
105
146
{:start="2"}
106
147
1. Apply the secret to the runtime cluster:
107
148
`kubectl apply -f <filename>`
108
149
150
+
{::nomarkdown}
151
+
<br>
152
+
{:/}
109
153
110
-
#### Step 3: Configure OAuth2 settings in Codefresh
154
+
#### Step 3: Configure OAuth2 settings for Custom Application in Codefresh
111
155
112
-
To complete custom provider authentication, configure the settings for the OAuth2 GitHub application in Codefresh. Configuring the settings creates a K8s ConfigMap that references the OAuth secret credentials. When configuring the settings, you can work in Form mode, or directly in the YAML manifest.
156
+
Configure the settings for the Custom OAuth2 Application in Codefresh. Configuring the settings creates a K8s ConfigMap that references the OAuth secret credentials. When configuring the settings, you can work in Form mode, or directly update the YAML manifest.
113
157
114
158
>Important:
115
159
> The values for all the settings in the ConfigMap are the `keys` in the secret file.
116
160
117
161
1. In the Codefresh UI, go to [Authentication](https://g.codefresh.io/2.0/account-settings/authentication?providerName=github){:target="\_blank"}.
118
162
The list always shows the default predefined Codefresh provider account and custom provider accounts created, organized by Runtime, Type (Codefresh or Custom) and Status.
119
-
1. From the list, select the runtime to which to apply the current configuration. The runtime must be identical to the runtime to which you saved the K8s secret.
163
+
1. From the list, select the Git provider and the runtime to which to apply the current configuration.
164
+
>The runtime must be identical to the runtime to which you saved the K8s secret.
120
165
1. Click **Edit** and then select **Use custom provider**.
121
166
> If you have managed clusters registered to the selected runtime, the authentication account is available to all the clusters.
122
167
The settings page is opened in **Form** mode.
@@ -132,13 +177,13 @@ To complete custom provider authentication, configure the settings for the OAuth
132
177
%}
133
178
134
179
{:start="4"}
135
-
1. Configure the settings for the **GitHub OAuth2 Application**, either in **Form** or in **YAML** modes:
180
+
1. Configure the settings for the **Git OAuth2 Application**, either in **Form** or in **YAML** modes:
136
181
* **Secret Name**: The name of the K8s secret file you created in the runtime cluster.
137
182
* **Secret Namespace**: The namespace in the runtime cluster where you created the K8s secret.
138
183
* **Application ID**: The `key` representing the OAuth application ID in the K8s secret. For example, `appId`.
139
184
* **Client ID**: The `key` representing the client ID in the K8s secret. For example, `clientId`.
140
185
* **Client Secret**: The `key` representing the client secret in the K8s secret. For example, `clientSecret`.
141
-
* **URL**: The `key` representing the provider URL in the K8s secret. For example, `url`.
186
+
* **URL**: The `key` representing the Git provider URL in the K8s secret. For example, `url`.
142
187
143
188
{:start="5"}
144
189
1. Click **Commit**.
@@ -160,10 +205,10 @@ To complete custom provider authentication, configure the settings for the OAuth
160
205
1. Optional. Enter a commit message.
161
206
1. At the bottom-right, click **Commit** once again.
162
207
163
-
You have completed the setup to authorize Codefresh as an OAuth App in GitHub.
208
+
You have completed the setup to authorize Codefresh as an OAuth App for your Git provider.
164
209
165
-
### Select authentication account for runtime
166
-
For a Git provider and a runtime account, switch between the Codefresh, Custom provider account if one exists, or enforce token-based authentication.
210
+
### Select authentication mechanism for runtime
211
+
For a Git provider and a runtime account, select the authentication mechanism: Codefresh account, Custom provider account if one exists, or token-based authentication.
167
212
168
213
1. In the Codefresh UI, go to [Authentication](https://g.codefresh.io/2.0/account-settings/authentication?providerName=github){:target="\_blank"}.
169
214
1. Select the runtime, and click  **Edit**.
Copy file name to clipboardExpand all lines: _docs/reference/git-tokens.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ Codefresh requires two types of Git tokens for authentication:
28
28
29
29
30
30
31
-
### Git runtime tokens
31
+
### Git runtime token scopes
32
32
The Git runtime token is mandatory for runtime installation.
33
33
34
34
{::nomarkdown}
@@ -55,16 +55,17 @@ The Git runtime token is mandatory for runtime installation.
55
55
56
56
#### Bitbucket Server runtime token scopes
57
57
58
-
*`Project admin`
59
-
*`Repository write`
60
-
*`Project read`
58
+
***Permissions**: `Read`
59
+
***Workspace membership**: `Read`
60
+
***Webhooks**: `Read and write`
61
+
***Repositories**: `Write`, `Admin`
61
62
62
63
{::nomarkdown}
63
64
</br></br>
64
65
{:/}
65
66
66
67
### Git personal tokens
67
-
The Git personal token is a user-specific personal access token per provisioned runtime. Unique to each user, it is required after installation to authenticate Git-based actions per runtime in Codefresh.
68
+
The Git personal token is a user-specific personal access token per provisioned runtime. Unique to each user, it may be required after to authenticate Git-based actions per runtime in Codefresh, based on how your admin has set up authentication for Git providers.
68
69
69
70
> If you have access to multiple runtimes, you can use the same personal access token for all the runtimes.
70
71
You must configure the token for each runtime.
@@ -100,8 +101,9 @@ The Git personal token is a user-specific personal access token per provisioned
0 commit comments