This example combines the microsoft, github and guest providers into a configuration that can be set up in RHDH, where the microsoft provider is set up for user login and the github provider is set up to authenticate against a couple different github organizations. The guest provider is also available to log into the app and examine the user login state.
To build and run the example locally the following will be needed:
- node 20.x
- yarn 3.x (3.8.6 was used to develop this)
- podman
This example consists of a number of dynamic plugin projects:
- custom-authentication-provider-module-backend: An authentication provider that sets up an alternate github authentication provider endpoint and configuration.
- custom-authentication-provider-module: A frontend dynamic plugin that contains an exported SignInPage component and API factory for the alternate github authentication provider, including a custom ScmAuth API factory setup.
- github-auth-provider-wrapper: A dynamic plugin wrapper project for the github authentication provider extension
- microsoft-auth-provider-wrapper: A dynamic plugin wrapper project for the microsoft authentication provider extension
The configuration supporting this setup is all in app-config.yaml
but it's important to know which sections affect the above plugins:
auth:
environment: development
providers:
guest:
dangerouslyAllowOutsideDevelopment: true
github:
development:
clientId: ${GITHUB_APP_CLIENT_ID}
clientSecret: ${GITHUB_APP_CLIENT_SECRET}
microsoft:
development:
clientId: ${AZURE_CLIENT_ID}
clientSecret: ${AZURE_CLIENT_SECRET}
tenantId: ${AZURE_TENANT_ID}
github-two:
development:
clientId: ${GITHUB_APP_TWO_CLIENT_ID}
clientSecret: ${GITHUB_APP_TWO_CLIENT_SECRET}
dynamicPlugins:
rootDirectory: dynamic-plugins-root
frontend:
custom-authentication-provider-module:
apiFactories:
- importName: ghTwoApi
- importName: scmAuthApi
components:
- name: SignInPage
importName: CustomSignInPage
providerSettings:
- title: Github Two
description: Sign in with GitHub Org Two
provider: github-two
After cloning this repo you can build the code using the following sequence of commands:
yarn install && yarn tsc && yarn build
Once built the next step is to export the built packages as dynamic plugins.
To export the plugins to the ./deploy
directory run:
yarn export-local
Use the environment variable PLUGIN_IMAGE_TAG
to change the image tag as needed.
This example needs a number of environment variables to run properly:
GITHUB_APP_CLIENT_ID
GITHUB_APP_CLIENT_SECRET
GITHUB_APP_TWO_CLIENT_ID
GITHUB_APP_TWO_CLIENT_SECRET
AZURE_CLIENT_ID
AZURE_CLIENT_SECRET
AZURE_TENANT_ID
The run-with-podman.sh
script is set up to substitute a dummy value for any of the above variables. To see the example in action, set the above variables to the appropriate values for your envrionment and run:
./run-with-podman.sh