Skip to content

Commit 5001ccf

Browse files
committed
docs: removed ldap example, and added content from https://github.com/redhat-developer/rhdh/pull/2446/files
Signed-off-by: Fabrice Flore-Thébault <[email protected]>
1 parent ca8b0dd commit 5001ccf

File tree

1 file changed

+37
-192
lines changed

1 file changed

+37
-192
lines changed
Lines changed: 37 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -1,232 +1,77 @@
11
[id="enabling-authentication-with-your-custom-authentication-provider"]
22
= Enabling authentication with your custom authentication provider
33

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

77
.Prerequisites
88
* You link:{configuring-book-url}[added a custom {product-short} application configuration], and have sufficient permissions to modify it.
99
* link:{installing-and-viewing-dynamic-plugins-url}#assembly-third-party-plugins[Exporting, packaging, and installing third-party plugins] knowledge.
1010
* 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-
====
1711

1812
.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-
3213
. Create your custom authentication provider backend plugin, that:
3314
* Provides an authentication provider API.
3415
* Bridges authentication to your custom authentication provider.
3516
* 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-
----
4517

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+
6519

6620
. Create your custom authentication provider frontend plugin, that:
6721
* Provides a custom `SignInPage` component.
6822
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.
6923
* Provides an API client for the backend authentication provider service.
7024
* 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';
9025

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

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"]
9833
----
9934
dynamicPlugins:
10035
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>_
10641
----
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}.
11242
+
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:
18144

45+
`title`:: The title for the authentication provider shown above the user's profile image if available.
18246

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

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"]
20059
----
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
21565
----
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:
22068

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

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

22873
.Verification
22974
. 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.
23176
. Log in with your custom authentication provider.
23277

0 commit comments

Comments
 (0)