Skip to content

Commit e5d0ec8

Browse files
committed
RHIDP-7794 Clarify authenticating and integrating with GitHub
Signed-off-by: Fabrice Flore-Thébault <[email protected]>
1 parent 2963f3c commit e5d0ec8

12 files changed

+271
-217
lines changed

assemblies/assembly-authenticating-with-github.adoc

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

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-rhbk.adoc[leveloffset=+1]
5757

5858

59-
include::assembly-authenticating-with-github.adoc[leveloffset=+1]
59+
include::modules/authentication/proc-enabling-authentication-with-github.adoc[leveloffset=+1]
6060

6161

6262
include::assembly-authenticating-with-microsoft-azure.adoc[leveloffset=+1]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[id='enabling-authentication']
2+
= Enabling authentication in {product}
3+
4+
5+
6+
include::modules/integrating-with-github/proc-enabling-github-repository-discovery.adoc[leveloffset=+1]
7+
8+
9+
10+

modules/authentication/proc-enabling-authentication-with-github.adoc

Lines changed: 104 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -12,106 +12,121 @@ To authenticate users with GitHub, enable the GitHub authentication provider in
1212
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.
1313

1414
.. 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`.
3215

33-
** Toggle other permissions as per your needs.
16+
GitHub App name::
17+
Enter a unique name identifying your GitHub App, such as `Authenticating-with-{product-very-short}-__<GUID>__`.
3418

35-
* *Organization permissions*:
36-
** Enable `Read-only` access to *Members*.
19+
Homepage URL::
20+
Enter your {product-short} URL: `pass:c,a,q[{my-product-url}]`.
3721

38-
* For *Where can this GitHub App be installed?*, select `Only on this account`.
22+
Authorization callback URL::
23+
Enter your {product-short} authentication backend URL: `pass:c,a,q[{my-product-url}/api/auth/github/handler/frame]`.
3924

40-
.. In the *General* -> *Clients secrets* section, click *Generate a new client secret*.
25+
Webhook URL:: Enter your {product-short} URL: `pass:c,a,q[{my-product-url}]`.
26+
27+
Webhook secret::
28+
Not required.
4129

42-
.. In the *General* -> *Private keys* section, click *Generate a private key*.
30+
Repository permissions::
31+
Not required.
32+
33+
Organization permissions::
34+
Enable `Read-only` access to *Members*.
35+
36+
Where can this GitHub App be installed?::
37+
Select `Only on this account`.
38+
39+
.. In the *General* -> *Clients secrets* section, click *Generate a new client secret*.
4340

4441
.. In the *Install App* tab, choose an account to install your GitHub App on.
4542

4643
.. Save the following values for the next step:
4744

48-
* **App ID**
4945
* **Client ID**
5046
* **Client secret**
51-
* **Private key**
52-
* **Webhook secret**
5347

5448
. To add your GitHub credentials to {product-short}, add the following key/value pairs to link:{configuring-dynamic-plugins-book-url}#provisioning-your-custom-configuration[your {product-short} secrets]:
5549
+
56-
`AUTH_GITHUB_APP_ID`:: Enter the saved **App ID**.
57-
`AUTH_GITHUB_CLIENT_ID`:: Enter the saved **Client ID**.
58-
//`GITHUB_HOST_DOMAIN`:: Enter your GitHub host domain: `github.com` unless you are using GitHub Enterprise.
59-
`GITHUB_ORGANIZATION`:: Enter your GitHub organization name, such as `__<your_github_organization_name>__'.
60-
`GITHUB_ORG_URL`:: Enter `$GITHUB_HOST_DOMAIN/$GITHUB_ORGANIZATION`.
61-
`GITHUB_CLIENT_SECRET`:: Enter the saved **Client Secret**.
62-
`GITHUB_PRIVATE_KEY_FILE`:: Enter the saved **Private key**.
63-
`GITHUB_WEBHOOK_URL`:: Enter your {product-short} URL: `pass:c,a,q[{my-product-url}]`.
64-
`GITHUB_WEBHOOK_SECRET`:: Enter the saved *Webhook secret*.
65-
66-
. . To set up the GitHub authentication provider and enable integration with the GitHub API in your {product-short} custom configuration, edit your custom {product-short} config map such as `{my-app-config-config-map}`, and add the following lines to the `{my-app-config-file}` file content:
50+
`AUTHENTICATION_GITHUB_CLIENT_ID`::
51+
Enter the saved **Client ID**.
52+
`AUTHENTICATION_GITHUB_CLIENT_SECRET`::
53+
Enter the saved **Client Secret**.
54+
`AUTHENTICATION_GITHUB_HOST_DOMAIN`::
55+
Enter the GitHub host domain: `github.com`.
56+
`AUTHENTICATION_GITHUB_ORGANIZATION`::
57+
Enter your GitHub organization name, such as `__<your_github_organization_name>__'.
58+
59+
. Enable the `backstage-plugin-catalog-backend-module-github-org` plugin.
6760
+
68-
.`{my-app-config-file}` file fragment with mandatory fields to enable authentication with GitHub
61+
.`dynamic-plugins.yaml` file fragment
62+
[code,yaml]
63+
----
64+
plugins:
65+
- package: './dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-org'
66+
disabled: false
67+
----
68+
69+
. To provision GitHub users and groups to the {product-short} software catalog, add the `catalog.providers.githubOrg` section to your custom {product-short} `{my-app-config-file}` configuration file:
70+
+
71+
--
72+
[id=githubProviderId]
73+
.`{my-app-config-file}` fragment with mandatory `catalog.providers.githubOrg` fields
6974
[source,yaml]
7075
----
71-
auth:
72-
environment: production # <1>
76+
catalog:
7377
providers:
74-
github:
75-
production:
76-
clientId: ${AUTH_GITHUB_CLIENT_ID} # <2>
77-
clientSecret: ${AUTH_GITHUB_CLIENT_SECRET}
78-
integrations:
79-
github:
80-
- host: ${GITHUB_HOST_DOMAIN}
81-
apps:
82-
- appId: ${AUTH_GITHUB_APP_ID}
83-
clientId: ${AUTH_GITHUB_CLIENT_ID}
84-
clientSecret: ${GITHUB_CLIENT_SECRET}
85-
webhookUrl: ${GITHUB_WEBHOOK_URL}
86-
webhookSecret: ${GITHUB_WEBHOOK_SECRET}
87-
privateKey: |
88-
${GITHUB_PRIVATE_KEY_FILE}
89-
signInPage: github # <3>
78+
githubOrg:
79+
githubUrl: "${GITHUB_HOST_DOMAIN}"
80+
orgs: [ "${GITHUB_ORGANIZATION}" ]
81+
schedule:
82+
frequency:
83+
minutes: 30
84+
initialDelay:
85+
seconds: 15
86+
timeout:
87+
minutes: 15
9088
----
91-
<1> Mark the environment as `production` and disable the Guest login option in the {product-short} login page.
92-
<2> Apply the GitHub credentials configured in your {product-short} secrets.
93-
<3> To enable the GitHub provider as your {product-short} sign-in provider.
9489

95-
.. Optional: Consider adding the following optional fields:
90+
`githubUrl` and `orgs`::
91+
Use the {product-short} application information that you have created in GitHub and configured in OpenShift as secrets.
9692

97-
`callbackUrl`::
98-
The callback URL that GitHub uses when initiating an OAuth flow, such as: __<your_intermediate_service_url/handler>__.
99-
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.
93+
`schedule.frequency`::
94+
Enter your schedule frequency, in the cron, ISO duration, or "human duration" format.
95+
96+
`schedule.timeout`::
97+
Enter your schedule timeout, in the ISO duration or "human duration" format.
98+
99+
`schedule.initialDelay`::
100+
Enter your schedule initial delay, in the ISO duration or "human duration" format.
101+
--
102+
103+
. To set up the GitHub authentication provider, add the `auth.providers.github` section to the `{my-app-config-file}` file content:
100104
+
101-
.`{my-app-config-file}` file fragment with optional `enterpriseInstanceUrl` field
102-
[source,yaml,subs="+quotes"]
105+
.`{my-app-config-file}` file fragment with mandatory fields to enable authentication with GitHub
106+
[source,yaml]
103107
----
104108
auth:
109+
environment: production
105110
providers:
106111
github:
107112
production:
108-
callbackUrl: __<your_intermediate_service_url/handler>__
113+
clientId: ${AUTH_GITHUB_CLIENT_ID}
114+
clientSecret: ${AUTH_GITHUB_CLIENT_SECRET}
115+
signInPage: github
109116
----
110-
111-
////
112-
`enterpriseInstanceUrl`::
113-
Your GitHub Enterprise URL.
114-
Requires you defined the `GITHUB_HOST_DOMAIN` secret in the previous step.
117+
+
118+
`environment: production`::
119+
Mark the environment as `production` and disable the Guest login option in the {product-short} login page.
120+
`clientId: ${AUTH_GITHUB_CLIENT_ID}` and `clientSecret: ${AUTH_GITHUB_CLIENT_SECRET}`::
121+
Apply the GitHub credentials configured in your {product-short} secrets.
122+
`signInPage: github`::
123+
To enable the GitHub provider as your {product-short} sign-in provider.
124+
+
125+
Optional: Consider adding the following optional fields:
126+
+
127+
`callbackUrl`::
128+
Enter the callback URL that GitHub uses when initiating an OAuth flow, such as: __<your_intermediate_service_url/handler>__.
129+
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.
115130
+
116131
.`{my-app-config-file}` file fragment with optional `enterpriseInstanceUrl` field
117132
[source,yaml,subs="+quotes"]
@@ -120,12 +135,11 @@ auth:
120135
providers:
121136
github:
122137
production:
123-
enterpriseInstanceUrl: ${GITHUB_HOST_DOMAIN}
138+
callbackUrl: __<your_intermediate_service_url/handler>__
124139
----
125-
////
126140

127141
`sessionDuration`::
128-
Lifespan of the user session.
142+
Enter the user session lifespan.
129143
Enter a duration in `ms` library format (such as '24h', '2 days'), ISO duration, or "human duration" as used in code.
130144
+
131145
.`app-config-rhdh.yaml` fragment with optional `sessionDuration` field
@@ -138,14 +152,16 @@ auth:
138152
sessionDuration: { hours: 24 }
139153
----
140154

141-
`signIn` ::
155+
`signIn`::
142156

143157
`resolvers`:::
144-
After successful authentication, the user signing in must be resolved to an existing user in the {product-short} catalog. To best match users securely for your use case, consider configuring a specific resolver. Enter the resolver list to override the default resolver: `usernameMatchingUserEntityName`.
158+
After successful authentication, the user signing in must be resolved to an existing user in the {product-short} catalog.
159+
To best match users securely for your use case, consider configuring a specific resolver.
160+
Enter the resolver list to override the default resolver: `usernameMatchingUserEntityName`.
145161
+
146162
The authentication provider tries each sign-in resolver in order until it succeeds, and fails if none succeed.
147163
+
148-
WARNING: In production mode, only configure one resolver to ensure users are securely matched.
164+
WARNING: In production mode, only configure one resolver to ensure users are securely matched.
149165

150166
`resolver`::::
151167
Enter the sign-in resolver name.
@@ -174,55 +190,21 @@ auth:
174190
resolvers:
175191
- resolver: usernameMatchingUserEntityName
176192
dangerouslyAllowSignInWithoutUserInCatalog: true
177-
integrations:
178-
github:
179-
- host: ${GITHUB_HOST_DOMAIN}
180-
apps:
181-
- appId: ${AUTH_GITHUB_APP_ID}
182-
clientId: ${AUTH_GITHUB_CLIENT_ID}
183-
clientSecret: ${GITHUB_CLIENT_SECRET}
184-
webhookUrl: ${GITHUB_WEBHOOK_URL}
185-
webhookSecret: ${GITHUB_WEBHOOK_SECRET}
186-
privateKey: |
187-
${GITHUB_PRIVATE_KEY_FILE}
188193
signInPage: github
189194
----
190195

191-
[TIP]
192-
====
193-
To enable GitHub integration with a different authentication provider, complete the following configurations:
194-
195-
* Add the GitHub provider to the existing `auth` section.
196-
* Keep the `signInPage` section from your authentication provider configuration.
197-
198-
.`{my-app-config-file}` file fragment with mandatory fields to enable GitHub integration and use a different authentication provider
199-
[source,yaml,subs="+quotes"]
196+
.Verification
197+
. To verify user and group provisioning, check the console logs.
198+
+
199+
.Successful synchronization example:
200+
[source,json]
200201
----
201-
auth:
202-
environment: production
203-
providers:
204-
github:
205-
production:
206-
clientId: ${AUTH_GITHUB_CLIENT_ID}
207-
clientSecret: ${AUTH_GITHUB_CLIENT_SECRET}
208-
__<your_other_authentication_providers_configuration>__
209-
integrations:
210-
github:
211-
- host: ${GITHUB_HOST_DOMAIN}
212-
apps:
213-
- appId: ${AUTH_GITHUB_APP_ID}
214-
clientId: ${AUTH_GITHUB_CLIENT_ID}
215-
clientSecret: ${GITHUB_CLIENT_SECRET}
216-
webhookUrl: ${GITHUB_WEBHOOK_URL}
217-
webhookSecret: ${GITHUB_WEBHOOK_SECRET}
218-
privateKey: |
219-
${GITHUB_PRIVATE_KEY_FILE}
220-
signInPage: __<your_main_authentication_provider>__
202+
{"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"}
203+
{"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"}
221204
----
222-
====
223205

224-
.Verification
225-
. Go to the {product-short} login page.
226-
. Your {product-short} sign-in page displays *Sign in using GitHub* and the Guest user sign-in is disabled.
227-
. Log in with GitHub.
206+
. To verify GitHub authentication:
207+
.. Go to the {product-short} login page.
208+
.. Your {product-short} sign-in page displays *Sign in using GitHub* and the Guest user sign-in is disabled.
209+
.. Log in with a GitHub account.
228210

0 commit comments

Comments
 (0)