|
1 | 1 | [id="enabling-authentication-with-your-custom-authentication-provider"] |
2 | 2 | = Enabling authentication with your custom authentication provider |
3 | 3 |
|
4 | | -You can extend {product} with your custom authentication provider by using your custom authentication backend and frontend plugins. |
5 | | -To authenticate users with your custom authentication provider, create, install and configure your custom authentication backend and frontend plugins in {product}. |
| 4 | +Out of the box {product} supports all the documented authentication providers, such as GitHub or Microsoft Azure. |
| 5 | +However, you can extend {product-short} with your custom authentication provider by using dynamic plugins that either adds more configuration options for an existing provider, or adds a new authentication provider altogether. |
6 | 6 |
|
7 | 7 | .Prerequisites |
8 | 8 | * You link:{configuring-book-url}[added a custom {product-short} application configuration], and have sufficient permissions to modify it. |
9 | 9 | * link:{installing-and-viewing-dynamic-plugins-url}#assembly-third-party-plugins[Exporting, packaging, and installing third-party plugins] knowledge. |
10 | 10 | * You collected the relevant information to connect to your custom authentication provider. |
11 | | -+ |
12 | | -[WARNING] |
13 | | -==== |
14 | | -This procedure is using a custom LDAP authentication provider as an example. |
15 | | -This example is not intended for production use. |
16 | | -==== |
17 | 11 |
|
18 | 12 | .Procedure |
19 | | - |
20 | | -. Add the identified key/value pairs to link:{plugins-configure-book-url}#provisioning-your-custom-configuration[your {product-short} secrets]. |
21 | | -.. To allow {product-short} to use plugins for authentication rather than the builtin authentication providers, set the `ENABLE_AUTH_PROVIDER_MODULE_OVERRIDE` environment variable to true. |
22 | | -`ENABLE_AUTH_PROVIDER_MODULE_OVERRIDE`:: `true` |
23 | | -.. To add your custom authentication provider credentials to {product-short}, add the identified key/value pairs. |
24 | | -+ |
25 | | -.Secrets for the LDAP example |
26 | | -==== |
27 | | -LDAP_URL:: Your LDAP server URL, such as `ldap://_<my_host>_:3893`. |
28 | | -LDAP_BIND_DN:: Your LDAP bind distinguished name, such as `cn=serviceuser,ou=svcaccts,dc=glauth,dc=com`. |
29 | | -LDAP_BIND_PASSWORD:: Your LDAP password, such as `mysecret`. |
30 | | -==== |
31 | | - |
32 | 13 | . Create your custom authentication provider backend plugin, that: |
33 | 14 | * Provides an authentication provider API. |
34 | 15 | * Bridges authentication to your custom authentication provider. |
35 | 16 | * Includes an example backend configuration in an `app-config.yaml`file. |
36 | | -+ |
37 | | --- |
38 | | -.LDAP backend plugin |
39 | | -==== |
40 | | -.`src/index.ts` wrapper re-exporting the original plugin |
41 | | -[source,javascript] |
42 | | ----- |
43 | | -export { default as default } from "@immobiliarelabs/backstage-plugin-ldap-auth-backend"; |
44 | | ----- |
45 | 17 |
|
46 | | -.`app-config.yaml` backend configuration |
47 | | -[source,yaml] |
48 | | ----- |
49 | | -auth: |
50 | | - environment: production |
51 | | - providers: |
52 | | - ldap: |
53 | | - production: |
54 | | - ldapAuthenticationOptions: |
55 | | - userSearchBase: ou=users,dc=glauth,dc=com |
56 | | - usernameAttribute: uid |
57 | | - adminDn: ${LDAP_BIND_DN} |
58 | | - adminPassword: ${LDAP_BIND_PASSWORD} |
59 | | - ldapOpts: |
60 | | - url: |
61 | | - - ${LDAP_URL} |
62 | | ----- |
63 | | -==== |
64 | | --- |
| 18 | + |
65 | 19 |
|
66 | 20 | . Create your custom authentication provider frontend plugin, that: |
67 | 21 | * Provides a custom `SignInPage` component. |
68 | 22 | The `SignInPage` component is the place in a {product-short} app where the frontend API reference is connected to the appropriate backend authentication provider API service. |
69 | 23 | * Provides an API client for the backend authentication provider service. |
70 | 24 | * Includes an example backend configuration in an `app-config.yaml`file. |
71 | | -+ |
72 | | --- |
73 | | -.LDAP frontend plugin |
74 | | -==== |
75 | | -The exported `SignInPage` component delegates to the `LDAPSignInPage` component that is provided by the `backstage-plugin-ldap-auth` package. |
76 | | -
|
77 | | -.`src/index.ts` wrapper re-exporting the original plugin |
78 | | -[source,javascript] |
79 | | ----- |
80 | | -export * from '@immobiliarelabs/backstage-plugin-ldap-auth'; |
81 | | -export { SignInPage } from './components/SignInPage/SignInPage'; |
82 | | ----- |
83 | | -
|
84 | | -.`src/components/SignInPage.ts` `SignInPage` component |
85 | | -[source,javascript] |
86 | | ----- |
87 | | -import React from 'react'; |
88 | | -import { SignInPageProps } from '@backstage/core-plugin-api'; |
89 | | -import { LdapAuthFrontendPage } from '@immobiliarelabs/backstage-plugin-ldap-auth'; |
90 | 25 |
|
91 | | -export function SignInPage(props: SignInPageProps): React.JSX.Element { |
92 | | - return <LdapAuthFrontendPage {...props} provider="ldap" />; |
93 | | -} |
94 | | ----- |
| 26 | +. link:{installing-and-viewing-dynamic-plugins-url}#assembly-third-party-plugins[Export, package, and install your custom plugins]. |
| 27 | +. Add your custom plugins configuration to your `dynamic-plugins.yaml` file. |
95 | 28 |
|
96 | | -.`app-config.yaml` frontend configuration |
97 | | -[source,yaml] |
| 29 | +. {product-short} users expect to see all authentication providers listed in the *User settings* section, *Authentication Providers* tab. |
| 30 | +To add entries for an authentication provider from a dynamic plugin, use the `providerSettings` configuration in your `{my-app-config-file}` file: |
| 31 | ++ |
| 32 | +[source,yaml,subs="+quotes"] |
98 | 33 | ---- |
99 | 34 | dynamicPlugins: |
100 | 35 | frontend: |
101 | | - immobiliarelabs-backstage-plugin-ldap-auth: |
102 | | - components: |
103 | | - - name: SignInPage |
104 | | - module: PluginRoot |
105 | | - importName: SignInPage |
| 36 | + _<package_name>_: |
| 37 | + providerSettings: |
| 38 | + - title: _<My Custom Auth Provider>_ |
| 39 | + description: _<Sign in using My Custom Auth Provider>_ |
| 40 | + provider: _<core.auth.my-custom-auth-provider>_ |
106 | 41 | ---- |
107 | | -==== |
108 | | --- |
109 | | - |
110 | | -. link:{installing-and-viewing-dynamic-plugins-url}#assembly-third-party-plugins[Export, package, and install your custom plugins]. |
111 | | -. Add your custom plugins configuration to `dynamic-plugins.yaml` in {product-short}. |
112 | 42 | + |
113 | | -.`dynamic-plugins.yaml` excerpt for LDAP catalog support |
114 | | -==== |
115 | | ----- |
116 | | -plugins: |
117 | | - - package: ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-ldap-dynamic |
118 | | - disabled: false |
119 | | - pluginConfig: |
120 | | - catalog: |
121 | | - providers: |
122 | | - ldapOrg: |
123 | | - default: |
124 | | - target: ${LDAP_URL} |
125 | | - bind: |
126 | | - dn: ${LDAP_BIND_DN} |
127 | | - secret: ${LDAP_BIND_PASSWORD} |
128 | | - users: |
129 | | - - dn: ou=users,dc=glauth,dc=com |
130 | | - options: |
131 | | - scope: sub |
132 | | - filter: (accountStatus=active) |
133 | | - attributes: ['*', '+'] |
134 | | - paged: false |
135 | | - map: |
136 | | - rdn: uid |
137 | | - name: uid |
138 | | - description: description |
139 | | - displayName: uid |
140 | | - email: mail |
141 | | - picture: <nothing, left out> |
142 | | - memberOf: memberOf |
143 | | - groups: |
144 | | - - dn: ou=groups,dc=glauth,dc=com |
145 | | - options: |
146 | | - scope: sub |
147 | | - filter: (gidNumber=*) |
148 | | - attributes: ['*', '+'] |
149 | | - paged: false |
150 | | - map: |
151 | | - rdn: uid |
152 | | - name: uid |
153 | | - uid: uid |
154 | | - displayName: uid |
155 | | - description: description |
156 | | - type: groupType |
157 | | - email: <nothing, left out> |
158 | | - picture: <nothing, left out> |
159 | | - memberOf: memberOf |
160 | | - members: member |
161 | | - schedule: |
162 | | - frequency: PT10M |
163 | | - timeout: PT10M |
164 | | -# optional, this is just to suppress any examples |
165 | | - import: {} |
166 | | - rules: |
167 | | - - allow: [Component, System, Group, Resource, Location, Template, API, User] |
168 | | - locations: [] |
169 | | - - package: ./local-plugins/immobiliarelabs-backstage-plugin-ldap-auth |
170 | | - disabled: false |
171 | | - pluginConfig: |
172 | | - dynamicPlugins: |
173 | | - frontend: |
174 | | - immobiliarelabs-backstage-plugin-ldap-auth: |
175 | | - components: |
176 | | - - name: SignInPage |
177 | | - module: PluginRoot |
178 | | - importName: SignInPage |
179 | | ----- |
180 | | -==== |
| 43 | +Each provider settings entry should define the following attributes: |
181 | 44 |
|
| 45 | +`title`:: The title for the authentication provider shown above the user's profile image if available. |
182 | 46 |
|
183 | | -. To set up your custom authentication provider, edit your custom {product-short} ConfigMap such as `app-config-rhdh`, and add the following lines to the `app-config-rhdh.yaml` content: |
184 | | -+ |
185 | | --- |
186 | | -.`app-config-rhdh.yaml` fragment with mandatory fields to enable authentication with |
187 | | -[source,yaml,subs="+attributes,+quotes"] |
188 | | ----- |
189 | | -auth: |
190 | | - environment: production |
191 | | - providers: |
192 | | - _<your_custom_provider_id>_: |
193 | | - production: |
194 | | - _<your_custom_provider_configuration>_ |
195 | | -signInPage: _<your_custom_provider_id>_ |
196 | | ----- |
| 47 | +`description`:: a short description of the authentication provider. |
| 48 | + |
| 49 | +`provider`:: The ID of the authentication provider as provided to the `createApiRef` API call. |
| 50 | +This value is used to look up the corresponding API factory for the authentication provider to connect the provider's Sign In/Sign Out button. |
197 | 51 |
|
198 | | -.`app-config.yaml` excerpt for the LDAP example |
199 | | -==== |
| 52 | + |
| 53 | +. Use a custom `SignInPage` component. |
| 54 | +{product-short} is using the `SignInPage` component to connect one or more authentication providers to the application sign-in process. |
| 55 | +By default, {product-short} has a static `SignInPage` that supports all the built-in authentication providers. |
| 56 | +To use a different authentication provider, for example from a dynamic plugin use the `signInPage` configuration in your `{my-app-config-file}` file: |
| 57 | ++ |
| 58 | +[source,yaml,subs="+quotes"] |
200 | 59 | ---- |
201 | | -auth: |
202 | | - environment: production |
203 | | - providers: |
204 | | - ldap: |
205 | | - production: |
206 | | - ldapAuthenticationOptions: |
207 | | - userSearchBase: ou=users,dc=glauth,dc=com |
208 | | - usernameAttribute: uid |
209 | | - adminDn: ${LDAP_BIND_DN} |
210 | | - adminPassword: ${LDAP_BIND_PASSWORD} |
211 | | - ldapOpts: |
212 | | - url: |
213 | | - - ${LDAP_URL} |
214 | | -signInPage: ldap |
| 60 | +dynamicPlugins: |
| 61 | + frontend: |
| 62 | + _<package_name>_: |
| 63 | + signInPage: |
| 64 | + importName: CustomSignInPage |
215 | 65 | ---- |
216 | | -==== |
217 | | - |
218 | | -`environment: production`:: |
219 | | -Mark the environment as `production` to hide the Guest login in the {product-short} home page. |
| 66 | ++ |
| 67 | +Only one `signInPage` is specified and used by the application, this configuration object supports the following properties: |
220 | 68 |
|
221 | | -`_<your_custom_provider_id>_` section:: |
222 | | -Use the {product-short} application information that you have created in your custom authentication provider and configured in OpenShift as secrets. |
| 69 | +`module`:: optional setting to specify which set of assets should be accessed from the dynamic plugin, defaults to `PluginRoot` |
223 | 70 |
|
224 | | -`sigInPage: _<your_custom_provider_id>_`:: |
225 | | -To enable the custom authentication provider as default sign-in provider. |
226 | | --- |
| 71 | +`importName`:: Required setting that should resolve to a component that returns a configured `SignInPage` component that connects the appropriate authentication provider factories, or a compatible custom implementation. |
227 | 72 |
|
228 | 73 | .Verification |
229 | 74 | . Go to the {product-short} login page. |
230 | | -. Your {product-short} sign-in page displays *Sign in using _<your_custom_authentication_provider_name>_* and the Guest user sign-in is disabled. |
| 75 | +. Your {product-short} sign-in page displays *_<Sign in using My Custom Auth Provider>_* and the Guest user sign-in is disabled. |
231 | 76 | . Log in with your custom authentication provider. |
232 | 77 |
|
0 commit comments