Hi guys,
I’ve currently managed to get user authentication working using OIDC directly from Entra ID. I’ve seen this issue come around on the community a couple times, no one seems to have got this working, so I thought I’d share the steps I took to configure it.
There are a few holes in this, haven’t got a few things like like app-initiated IDP sign-out and pulling in groups from Entra ID working, but at a very base level I’ve got user authentication and user auto-creation working. Below are the steps I took to configure this, both on the Entra and Foreman side. This has been tested on Foreman 3.11, with both Foreman and Foreman-Katello installs.
Configuring Entra ID
-
In the Entra admin center, navigate to Identity → Applications → App registrations.
-
Create a new app registration. Give the application a name (e.g. Foreman). Configure the Redirect URI to “Web” and “https://your-foreman-fqdn/users/extlogin/redirect-uri". Click “Register”.
- Take note of the Application ID and Tenant ID, you’ll need them later.
-
Navigate to Authentication. Enable ID tokens and click “Save”.
-
Navigate to Certificates & secrets. Generate a new client secret.
- Take note of the Client Secret you just generated, you’ll need it later.
-
Navigate to Token configuration. Click “Add optional claim” and add the “email”, “given_name”, “family_name”, and
“preferred_username” claims. You will need to turn on the MS Graph “email” and “profile”
permissions when prompted. -
Navigate to API permissions. Grant admin consent for your organisation to the MS Graph API permissions.
Configuring Foreman
- Install the OIDC module.
dnf install -y mod_auth_openidc
- Create the OIDC config file for Apache in
/etc/httpd/conf.d/05-foreman-ssl.d/example_openidc.conf
OIDCProviderMetadataURL https://login.microsoftonline.com/<tenant-id>/v2.0/.well-known/openid-configuration
OIDCClientID <application-ID>
OIDCClientSecret <application-secret>
OIDCRedirectURI https://<your-foreman-fqdn>/users/extlogin/redirect_uri
OIDCCryptoPassphrase <random-string>
OIDCRemoteUserClaim preferred_username
OIDCScope "openid email profile"
OIDCResponseType id_token
<Location /users/extlogin>
AuthType openid-connect
Require valid-user
LogLevel debug
RequestHeader set REMOTE_USER %{OIDC_CLAIM_preferred_username}e
RequestHeader set REMOTE_USER_EMAIL %{OIDC_CLAIM_email}e
RequestHeader set REMOTE_USER_FIRSTNAME %{OIDC_CLAIM_given_name}e
RequestHeader set REMOTE_USER_LASTNAME %{OIDC_CLAIM_family_name}e
</Location>
- Load the
authn_core_module
andauthz_user_module
, by adding the following lines in/etc/httpd/conf.modules.d/10-auth_openidc.conf
.
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_user_module modules/mod_authz_user.so
- Navigate to Administer → Settings → Authentication in the Foreman Web UI, and configure
the following settings;
Authorize login delegation = Yes
Authorize login delegation auth source user autocreate = External
OIDC JWKs URL = https://login.microsoftonline.com/*tenant-id*/discovery/v2.0/keys
OIDC Audience = application-ID
OIDC Issuer = https://login.microsoftonline.com/*tenant-id*/v2.0
OIDC Algorithm = RS256
- Restart the Apache Web Server
systemctl restart httpd
- Test at https://your-foreman-fqdn/users/extlogin