-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Gitlab authentication procedure using personal tokens (#1924)
* Add Gitlab authentication procedure using personal tokens * Missing files * Fixups * Rename doc * review-part-1 Signed-off-by: Michal Maléř <mmaler@redhat.com> * review Signed-off-by: Michal Maléř <mmaler@redhat.com> * Fixup filename and remove old * Fixup file * Add renamed file * Fixup * vale Signed-off-by: Michal Maléř <mmaler@redhat.com> Co-authored-by: Michal Maléř <mmaler@redhat.com>
- Loading branch information
1 parent
aa972a7
commit 6f60b6c
Showing
9 changed files
with
156 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
modules/end-user-guide/examples/snip_gitlab-personal-access-token-secret.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
pass:[<!-- vale Vale.Spelling = NO -->] | ||
|
||
pass:[<!-- vale Vale.Terms = NO -->] | ||
|
||
pass:[<!-- vale IBM.Usage = NO -->] | ||
|
||
pass:[<!-- vale IBM.PassiveVoice = NO -->] | ||
|
||
pass:[<!-- vale IBM.Slash = NO -->] | ||
|
||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: gitlab-personal-access-token-secret | ||
labels: | ||
app.kubernetes.io/part-of: che.eclipse.org | ||
app.kubernetes.io/component: scm-personal-access-token | ||
annotations: | ||
che.eclipse.org/expired-after: '-1' | ||
che.eclipse.org/che-userid: '355d1ce5-990e-401e-9a8c-094bca10b5b3' | ||
che.eclipse.org/scm-userid: '2' | ||
che.eclipse.org/scm-username: 'user-foo' | ||
che.eclipse.org/scm-url: 'https://gitlab.apps.cluster-example.com' | ||
data: | ||
token: Yzh5cEt6cURxUWVCa3FKazhtaHg= | ||
|
||
pass:[<!-- vale Vale.Spelling = YES -->] | ||
|
||
pass:[<!-- vale Vale.Terms = YES -->] | ||
|
||
pass:[<!-- vale IBM.Usage = YES -->] | ||
|
||
pass:[<!-- vale IBM.PassiveVoice = YES -->] | ||
|
||
pass:[<!-- vale IBM.Slash = YES -->] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...user-guide/pages/authenticating-on-scm-server-with-a-personal-access-token.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[id="authenticating-on-scm-server-with-a-personal-access-token"] | ||
// = Authenticating on scm server with a personal access token | ||
:navtitle: Authenticating on SCM Server with a personal access token | ||
:keywords: end-user-guide, authentication-on-scm-server-with-a-personal-access-token | ||
:page-aliases: .:authenticating-on-scm-server-with-a-personal-access-token | ||
|
||
include::partial$assembly_authenticating-on-scm-server-with-a-personal-access-token.adoc[] |
7 changes: 0 additions & 7 deletions
7
...ges/authentication-against-bitbucket-server-with-the-personal-access-token.adoc
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...artials/assembly_authenticating-on-scm-server-with-a-personal-access-token.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
|
||
:parent-context-of-authenticating-on-scm-server-with-a-personal-access-token: {context} | ||
|
||
[id="authenticating-on-scm-server-with-a-personal-access-token_{context}"] | ||
= Authenticating users on private repositories of SCM servers | ||
|
||
|
||
The following section describes how to configure user authentications for SCM servers. | ||
|
||
* xref:configuring_gitlab_authentication_{context}[] | ||
|
||
* xref:configuring_bitbucket_authentication_{context}[] | ||
|
||
|
||
|
||
include::partial$proc_configuring_bitbucket_authentication.adoc[leveloffset=+1] | ||
|
||
include::partial$proc_configuring_gitlab_authentication.adoc[leveloffset=+1] | ||
|
||
|
||
:context: {parent-context-of-authenticating-on-scm-server-with-a-personal-access-token} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
modules/end-user-guide/partials/proc_configuring_gitlab_authentication.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Module included in the following assemblies: | ||
// | ||
// authenticating-on-scm-server-with-a-personal-access-token | ||
|
||
[id="configuring_gitlab_authentication_{context}"] | ||
= Authenticating on GitLab servers | ||
|
||
Configuring authentication on the GitLab system is similar to Bitbucket. | ||
|
||
GitLab authentication is based on using personal access tokens. Each GitLab user is able to request several personal access tokens with different names, permissions, expiration times, and so on. Those tokens can be used to sign GitLab REST API calls and perform Git repository operations. | ||
|
||
See the link:https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#personal-access-tokens[GitLab documentation] for more details about personal access tokens. | ||
|
||
To allow GitLab authentication on {prod-short} side, personal tokens must be stored in the user's namespace in the form of | ||
a secret. The secret must look as follows: | ||
|
||
[source,yaml] | ||
---- | ||
include::example$snip_gitlab-personal-access-token-secret.adoc[] | ||
---- | ||
|
||
The main parts of the secret are: | ||
|
||
[cols=3*] | ||
|=== | ||
| Label | ||
| `app.kubernetes.io/component` | ||
| Indicates it is a SCM personal token secret. | ||
|
||
| Annotation | ||
| `che.eclipse.org/che-userid` | ||
| {prod} id of the user token belongs to | ||
|
||
| Annotation | ||
| `che.eclipse.org/scm-userid` | ||
| GitLab user id to which token belongs | ||
|
||
| Annotation | ||
| `che.eclipse.org/scm-username` | ||
| GitlLab user name to which token belongs | ||
|
||
| Annotation | ||
| `che.eclipse.org/scm-url` | ||
| GitLab server URL to which this token belong | ||
|
||
| Annotation | ||
| `che.eclipse.org/expired-after` | ||
| Personal access token expiration time | ||
|
||
| Data entry | ||
| `token` | ||
| Base-64 encoded value of the personal access token | ||
|
||
|=== | ||
|
||
NOTE: Encoding a string into the base64 format using the `base64` tool on Linux machines leads to adding the newline character to the end of the source string and causing a value to be unusable as the authentication header value after decoding. Avoid this by using `base64 -w0`, which removes newly added lines, or strip newlines explicitly using`tr -d \\n`. | ||
|
||
. To obtain a user ID from a secret, take a look into user profile page on GitLab web UI or make a call to a REST API URL: | ||
* For GitLab: | ||
+ | ||
[subs="+quotes,macros"] | ||
---- | ||
++https++://__<gitlab-hostname>__/api/v4/users?username=__<username>__ | ||
---- | ||
|
||
* For {prod-short} | ||
+ | ||
[subs="+macros,attributes"] | ||
---- | ||
{prod-url}/api/user | ||
---- | ||
|
||
* With the token credentials obtained from a secret, another secret is automatically created, allowing authorization to Git operations. This secret is mounted into a workspace container as a Git credentials file, and any additional configurations are not required to work with private Git repositories. | ||
|
||
* When a remote Git repository uses a self-signed certificate, add an additional server configuration. See: | ||
xref:installation-guide:deploying-che-with-support-for-git-repositories-with-self-signed-certificates.adoc[]. |