Skip to content

Commit 83c7260

Browse files
authored
Cf pats oauth admin setup (#249)
* Update oath for git providers Added gitlab and bitbucket * Update oauth2 setup Content update with scopes and steps for new Git providers supported * Update oauth-setup.md * Update oauth-setup.md * Update oauth-setup.md * Update oauth-setup.md * Update oauth-setup.md
1 parent f2a5055 commit 83c7260

File tree

5 files changed

+110
-63
lines changed

5 files changed

+110
-63
lines changed

_data/home-content.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
localurl: /docs/administration/add-users/
119119
- title: Single Sign-On
120120
localurl: /docs/administration/single-sign-on/
121-
- title: Set up OAuth2 authentication
121+
- title: Set up OAuth2 authentication for Git providers
122122
localurl: /docs/administration/oauth-setup/
123123
- title: User settings
124124
localurl: /docs/administration/user-settings/

_data/nav.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
url: "/add-users"
142142
- title: User settings
143143
url: "/user-settings"
144-
- title: Set up OAuth2 authentication
144+
- title: Set up OAuth2 authentication for Git providers
145145
url: "/oauth-setup"
146146
- title: Authorize access to organizations/projects
147147
url: "/hosted-authorize-orgs"

_docs/administration/oauth-setup.md

Lines changed: 99 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,42 @@
11
---
2-
title: "Set up OAuth2 authentication"
2+
title: "Set up OAuth2 authentication for Git providers"
33
description: ""
44
group: administration
55
toc: true
66
---
77

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.
109

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.
1111

12-
Codefresh supports OAuth2 or Personal Access Tokens (PATs) for authentication:
13-
14-
* OAuth2 with Codefresh OAuth Application or custom OAuth2 Application
12+
{% include
13+
image.html
14+
lightbox="true"
15+
file="/images/authentication/authentication-list.png"
16+
url="/images/authentication/authentication-list.png"
17+
alt="Git provider authentication accounts"
18+
caption="Git provider authentication accounts"
19+
max-width="80%"
20+
%}
1521

16-
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:
1923

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.
2129

2230
* 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+
2434

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.
2537

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).
2840

2941
{% include
3042
image.html
@@ -33,42 +45,71 @@ The authentication accounts created for a provider are displayed in the [Authent
3345
url="/images/authentication/authentication-list.png"
3446
alt="Git provider authentication accounts"
3547
caption="Git provider authentication accounts"
36-
max-width="60%"
48+
max-width="80%"
3749
%}
38-
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).
4052

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.
4155

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)
4460

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+
{:/}
4964

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
5175
Create and register an OAuth App under your organization to authorize Codefresh.
5276

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:
78+
79+
* [GitHub](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app){:target="\_blank"}:
80+
* For **Authorization callback URL**, enter this value:
81+
`<ingressHost>/app-proxy/api/git-auth/github/callback`
82+
where:
83+
`<ingressHost>` is the IP address or URL of the ingress host in the runtime cluster.
84+
* Make sure **Enable Device Flow** is _not_ selected.
85+
* Select **Register application**.
86+
The client ID is automatically generated, and you are prompted to generate the client secret.
87+
* Select **Generate a new client secret**, and copy the generated secret.
88+
89+
* [GitLab Cloud and Server](https://docs.gitlab.com/ee/integration/oauth_provider.html#user-owned-applications){:target="\_blank"}:
90+
* For **Redirect URI**, enter this value:
91+
`<ingressHost>/app-proxy/api/git-auth/gitlab/callback`
92+
where:
93+
`<ingressHost>` is the IP address or URL of the ingress host in the runtime cluster.
94+
95+
* [Bitbucket Server](https://confluence.atlassian.com/adminjiraserver0902/configure-an-outgoing-link-1168853925.html){:target="\_blank"}:
96+
* For **Callback URL**, enter this value:
97+
`<ingressHost>/app-proxy/api/git-auth/bitbucket-server/callback`
98+
where:
99+
`<ingressHost>` is the IP address or URL of the ingress host in the runtime cluster.
54100

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:
57-
`<ingressHost>/app-proxy/api/git-auth/github/callback`
58-
where:
59-
`<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
67106

68-
You need them to create the K8s secret for the GitHub OAuth2 application.
107+
{::nomarkdown}
108+
<br>
109+
{:/}
69110

70111
#### 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`).
72113

73114
> All fields in the secret _must be_ encoded in `base64`.
74115
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
77118
**Before you begin**
78119

79120
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+
84125

85126
**How to**
86127

@@ -96,27 +137,31 @@ metadata:
96137
labels:
97138
codefresh_io_entity: git-pat-obtainer-sec
98139
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
103144
```
104145
105146
{:start="2"}
106147
1. Apply the secret to the runtime cluster:
107148
`kubectl apply -f <filename>`
108149

150+
{::nomarkdown}
151+
<br>
152+
{:/}
109153

110-
#### Step 3: Configure OAuth2 settings in Codefresh
154+
#### Step 3: Configure OAuth2 settings for Custom Application in Codefresh
111155

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.
113157

114158
>Important:
115159
> The values for all the settings in the ConfigMap are the `keys` in the secret file.
116160

117161
1. In the Codefresh UI, go to [Authentication](https://g.codefresh.io/2.0/account-settings/authentication?providerName=github){:target="\_blank"}.
118162
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.
120165
1. Click **Edit** and then select **Use custom provider**.
121166
> If you have managed clusters registered to the selected runtime, the authentication account is available to all the clusters.
122167
The settings page is opened in **Form** mode.
@@ -132,13 +177,13 @@ To complete custom provider authentication, configure the settings for the OAuth
132177
%}
133178

134179
{: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:
136181
* **Secret Name**: The name of the K8s secret file you created in the runtime cluster.
137182
* **Secret Namespace**: The namespace in the runtime cluster where you created the K8s secret.
138183
* **Application ID**: The `key` representing the OAuth application ID in the K8s secret. For example, `appId`.
139184
* **Client ID**: The `key` representing the client ID in the K8s secret. For example, `clientId`.
140185
* **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`.
142187

143188
{:start="5"}
144189
1. Click **Commit**.
@@ -160,10 +205,10 @@ To complete custom provider authentication, configure the settings for the OAuth
160205
1. Optional. Enter a commit message.
161206
1. At the bottom-right, click **Commit** once again.
162207

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.
164209

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.
167212

168213
1. In the Codefresh UI, go to [Authentication](https://g.codefresh.io/2.0/account-settings/authentication?providerName=github){:target="\_blank"}.
169214
1. Select the runtime, and click ![](/images/administration/users/icon-Edit.png?display=inline-block) **Edit**.

_docs/reference/git-tokens.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Codefresh requires two types of Git tokens for authentication:
2828

2929

3030

31-
### Git runtime tokens
31+
### Git runtime token scopes
3232
The Git runtime token is mandatory for runtime installation.
3333

3434
{::nomarkdown}
@@ -55,16 +55,17 @@ The Git runtime token is mandatory for runtime installation.
5555

5656
#### Bitbucket Server runtime token scopes
5757

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`
6162

6263
{::nomarkdown}
6364
</br></br>
6465
{:/}
6566

6667
### 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.
6869

6970
> If you have access to multiple runtimes, you can use the same personal access token for all the runtimes.
7071
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
100101

101102
#### Bitbucket Server personal user token scopes
102103

103-
* `Project read`
104-
* `Repository write`
104+
* **Permissions**: `Read`
105+
* **Workspace membership**: `Read`
106+
* **Repositories**: `Write`, `Admin`
105107

106108
### Related articles
107109
[User settings]({{site.baseurl}}/docs/administration/user-settings/)
27.9 KB
Loading

0 commit comments

Comments
 (0)