Skip to content

Commit 0c935fb

Browse files
openshift-cherrypick-robotPatAKnighthmanwani-rhthemr0c
authored
[release-1.3] RHIDP-3969 Authenticating with GitHub (#613)
Co-authored-by: Patrick Knight <[email protected]> Co-authored-by: Heena Manwani <[email protected]> Co-authored-by: Fabrice Flore-Thébault <[email protected]>
1 parent 81351bd commit 0c935fb

9 files changed

+238
-75
lines changed

assemblies/assembly-auth-provider-github.adoc

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[id="assembly-auth-provider-github"]
2+
= Enabling the GitHub authentication provider
3+
4+
To authenticate users with GitHub or GitHub Enterprise:
5+
6+
. xref:enabling-authentication-with-github[Enable the GitHub authentication provider in {product-short}].
7+
. xref:provisioning-users-from-github-to-the-software-catalog[Provision users from GitHub to the software catalog].
8+
9+
include::modules/authentication/proc-enabling-authentication-with-github.adoc[leveloffset=+1]
10+
11+
12+
include::modules/authentication/proc-provisioning-users-from-github-to-the-software-catalog.adoc[leveloffset=+1]
13+

assemblies/assembly-enabling-authentication.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ include::assembly-authenticating-with-the-guest-user.adoc[leveloffset=+1]
5656
include::assembly-authenticating-with-rhsso.adoc[leveloffset=+1]
5757

5858

59-
include::assembly-auth-provider-github.adoc[leveloffset=+1]
59+
include::assembly-authenticating-with-github.adoc[leveloffset=+1]
6060

6161

6262
include::assembly-authenticating-with-microsoft-azure.adoc[leveloffset=+1]
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
[id="enabling-authentication-with-github"]
2+
= Enabling authentication with GitHub
3+
4+
To authenticate users with GitHub, enable the GitHub authentication provider in {product}.
5+
6+
.Prerequisites
7+
* You have link:https://docs.redhat.com/en/documentation/red_hat_developer_hub/{product-version}/html/administration_guide_for_red_hat_developer_hub/assembly-add-custom-app-file-openshift_admin-rhdh[added a custom {product-short} application configuration], and have sufficient permissions to modify it.
8+
* You have sufficient permissions in GitHub to create and manage a link:https://docs.github.com/en/apps/overview[GitHub App].
9+
10+
.Procedure
11+
. To allow {product-short} to authenticate with GitHub, create a GitHub App.
12+
Opt for a GitHub App instead of an OAuth app to use fine-grained permissions, gain more control over which repositories the application can access, and use short-lived tokens.
13+
14+
.. link:https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app[Register a GitHub App] with the following configuration:
15+
+
16+
* *GitHub App name*: Enter a unique name identifying your GitHub App, such as __<{product}>__-__<GUID>__.
17+
* *Homepage URL*: Your {product-short} URL: `pass:c,a,q[{my-product-url}]`.
18+
* *Authorization callback URL*: Your {product-short} authentication backend URL: `pass:c,a,q[{my-product-url}/api/auth/github/handler/frame]`.
19+
* *Webhook URL*: Your {product-short} URL: `pass:c,a,q[{my-product-url}]`.
20+
* *Webhook secret*: Provide a strong secret.
21+
* *Repository permissions*:
22+
** Enable `Read-only` access to:
23+
*** *Administration*
24+
*** *Commit statuses*
25+
*** *Contents*
26+
*** *Dependabot alerts*
27+
*** *Deployments*
28+
*** *Pull Requests*
29+
*** *Webhooks*
30+
+
31+
TIP: If you plan to make changes using the GitHub API, ensure that `Read and write` permissions are enabled instead of `Read-only`.
32+
33+
** Toggle other permissions as per your needs.
34+
35+
* *Organization permissions*:
36+
** Enable `Read-only` access to *Members*.
37+
38+
* For *Where can this GitHub App be installed?*, select `Only on this account`.
39+
40+
.. In the *General* -> *Clients secrets* section, click *Generate a new client secret*.
41+
42+
.. In the *General* -> *Private keys* section, click *Generate a private key*.
43+
44+
.. In the *Install App* tab, choose an account to install your GitHub App on.
45+
46+
.. Save the following values for the next step:
47+
48+
* **App ID**
49+
* **Client ID**
50+
* **Client secret**
51+
* **Private key**
52+
* **Webhook secret**
53+
54+
. To add your GitHub credentials to your {product-short} secrets, edit your {product-short} secrets, such as `secrets-rhdh`, and add the following key/value pairs:
55+
+
56+
`AUTH_GITHUB_APP_ID`:: Enter the saved **App ID**.
57+
`AUTH_GITHUB_CLIENT_ID`:: Enter the saved **Client ID**.
58+
+
59+
Optional: enter additional secrets. The additional secrets are not required for authentication, but for further integration with GitHub, including:
60+
+
61+
`GITHUB_HOST_DOMAIN`:: Enter your GitHub host domain: `pass:c[https://github.com]` unless you are using GitHub Enterprise.
62+
`GITHUB_ORGANIZATION`:: Enter your GitHub organization name, such as `__<your_github_organization_name>__'.
63+
`GITHUB_ORG_URL`:: Enter `$GITHUB_HOST_DOMAIN/$GITHUB_ORGANIZATION`.
64+
`GITHUB_CLIENT_SECRET`:: Enter the saved **Client Secret**.
65+
`GITHUB_PRIVATE_KEY_FILE`:: Enter the saved **Private key**.
66+
`GITHUB_WEBHOOK_SECRET`:: Enter the saved *Webhook secret*.
67+
68+
. To set up the GitHub authentication provider in your {product-short} custom configuration, edit your custom {product-short} ConfigMap such as `app-config-rhdh`, and add the following lines to the `app-config-rhdh.yaml` content:
69+
+
70+
--
71+
.`app-config-rhdh.yaml` fragment with mandatory fields to enable authentication with GitHub
72+
[source,yaml]
73+
----
74+
auth:
75+
environment: production
76+
providers:
77+
github:
78+
production:
79+
clientId: ${AUTH_GITHUB_CLIENT_ID}
80+
clientSecret: ${AUTH_GITHUB_CLIENT_SECRET}
81+
signInPage: github
82+
----
83+
84+
`environment: production`::
85+
Mark the environment as `production` to hide the Guest login in the {product-short} home page.
86+
87+
`clientId`, `clientSecret`::
88+
Use the {product-short} application information that you have created in GitHub and configured in OpenShift as secrets.
89+
90+
`sigInPage: github`::
91+
To enable the GitHub provider as default sign-in provider.
92+
93+
Optional: Consider adding the following optional fields:
94+
95+
`dangerouslyAllowSignInWithoutUserInCatalog: true`::
96+
To enable authentication without requiring to provision users in the {product-short} software catalog.
97+
+
98+
WARNING: Use `dangerouslyAllowSignInWithoutUserInCatalog` to explore {product-short} features, but do not use it in production.
99+
+
100+
.`app-config-rhdh.yaml` fragment with optional field to allow authenticating users absent from the software catalog
101+
[source,yaml]
102+
----
103+
auth:
104+
environment: production
105+
providers:
106+
github:
107+
production:
108+
clientId: ${AUTH_GITHUB_CLIENT_ID}
109+
clientSecret: ${AUTH_GITHUB_CLIENT_SECRET}
110+
signInPage: github
111+
dangerouslyAllowSignInWithoutUserInCatalog: true
112+
----
113+
114+
`callbackUrl`::
115+
The callback URL that GitHub uses when initiating an OAuth flow, such as: __<your_intermediate_service_url/handler>__.
116+
Define it when {product-short} is not the immediate receiver, such as in cases when you use one OAuth app for many {product-short} instances.
117+
+
118+
.`app-config-rhdh.yaml` fragment with optional `enterpriseInstanceUrl` field
119+
[source,yaml,subs="+quotes"]
120+
----
121+
auth:
122+
providers:
123+
github:
124+
production:
125+
callbackUrl: __<your_intermediate_service_url/handler>__
126+
----
127+
128+
`enterpriseInstanceUrl`::
129+
Your GitHub Enterprise URL.
130+
Requires you defined the `GITHUB_HOST_DOMAIN` secret in the previous step.
131+
+
132+
.`app-config-rhdh.yaml` fragment with optional `enterpriseInstanceUrl` field
133+
[source,yaml,subs="+quotes"]
134+
----
135+
auth:
136+
providers:
137+
github:
138+
production:
139+
enterpriseInstanceUrl: ${GITHUB_HOST_DOMAIN}
140+
----
141+
142+
--
143+
144+
.Verification
145+
. Go to the {product-short} login page.
146+
. Your {product-short} sign-in page displays *Sign in using GitHub* and the Guest user sign-in is disabled.
147+
. Log in with GitHub.
148+
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[id="provisioning-users-from-github-to-the-software-catalog"]
2+
= Provisioning users from GitHub to the software catalog
3+
4+
To authenticate users, {product} requires their presence in the software catalog.
5+
Consider configuring {product-short} to provision users from GitHub to the software catalog on schedule, rather than provisioning the users manually.
6+
7+
.Prerequisites
8+
* You have xref:enabling-authentication-with-github[enabled authentication with GitHub], including the following secrets:
9+
** `GITHUB_HOST_DOMAIN`
10+
** `GITHUB_ORGANIZATION`
11+
12+
.Procedure
13+
14+
* To enable GitHub member discovery, edit your custom {product-short} ConfigMap, such as `app-config-rhdh`, and add the following lines to the `app-config-rhdh.yaml` content:
15+
+
16+
--
17+
[id=githubProviderId]
18+
.`app-config.yaml` fragment with mandatory `github` fields
19+
[source,yaml]
20+
----
21+
dangerouslyAllowSignInWithoutUserInCatalog: false
22+
catalog:
23+
providers:
24+
github:
25+
providerId:
26+
organization: "${GITHUB_ORGANIZATION}"
27+
schedule:
28+
frequency:
29+
minutes: 30
30+
initialDelay:
31+
seconds: 15
32+
timeout:
33+
minutes: 15
34+
githubOrg:
35+
githubUrl: "${GITHUB_HOST_DOMAIN}"
36+
orgs: [ "${GITHUB_ORGANIZATION}" ]
37+
schedule:
38+
frequency:
39+
minutes: 30
40+
initialDelay:
41+
seconds: 15
42+
timeout:
43+
minutes: 15
44+
----
45+
46+
`dangerouslyAllowSignInWithoutUserInCatalog: false`::
47+
Allow authentication only for users present in the {product-short} software catalog.
48+
49+
`organization`, `githubUrl`, and `orgs`::
50+
Use the {product-short} application information that you have created in GitHub and configured in OpenShift as secrets.
51+
52+
`schedule.frequency`::
53+
To specify custom schedule frequency.
54+
Supports cron, ISO duration, and "human duration" as used in code.
55+
56+
`schedule.timeout`::
57+
To specify custom timeout.
58+
Supports ISO duration and "human duration" as used in code.
59+
60+
`schedule.initialDelay`::
61+
To specify custom initial delay.
62+
Supports ISO duration and "human duration" as used in code.
63+
--
64+
65+
.Verification
66+
. Check the console logs to verify that the synchronization is completed.
67+
+
68+
.Successful synchronization example:
69+
[source,json]
70+
----
71+
{"class":"GithubMultiOrgEntityProvider","level":"info","message":"Reading GitHub users and teams for org: rhdh-dast","plugin":"catalog","service":"backstage","target":"https://github.com","taskId":"GithubMultiOrgEntityProvider:production:refresh","taskInstanceId":"801b3c6c-167f-473b-b43e-e0b4b780c384","timestamp":"2024-09-09 23:55:58"}
72+
{"class":"GithubMultiOrgEntityProvider","level":"info","message":"Read 7 GitHub users and 2 GitHub groups in 0.4 seconds. Committing...","plugin":"catalog","service":"backstage","target":"https://github.com","taskId":"GithubMultiOrgEntityProvider:production:refresh","taskInstanceId":"801b3c6c-167f-473b-b43e-e0b4b780c384","timestamp":"2024-09-09 23:55:59"}
73+
----
74+
75+
. Log in with a GitHub account.
76+

modules/getting-started/con-github-app-overview.adoc

Lines changed: 0 additions & 5 deletions
This file was deleted.

modules/getting-started/proc-adding-github-to-frontend.adoc

Lines changed: 0 additions & 15 deletions
This file was deleted.

modules/getting-started/proc-configuring-github-app.adoc

Lines changed: 0 additions & 27 deletions
This file was deleted.

modules/getting-started/proc-registering-github-app.adoc

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)