1. Overview of authentication methods in Foreman
Foreman includes native support for authentication with a username and password. If you require additional methods of authentication, configure your Foreman server to use an external authentication source.
Username and password | Single sign-on (SSO) | One-time password (OTP) | Time-based one-time password (TOTP) | PIV cards | Additional details | |
---|---|---|---|---|---|---|
Active Directory (direct integration) |
Yes |
Yes |
No |
No |
No |
Configuring Kerberos SSO for Active Directory users in Foreman |
FreeIPA |
Yes (Linux and Active Directory users) |
Yes (Linux users only) |
No |
No |
No |
|
Quarkus-based Keycloak |
Yes |
Yes |
Yes |
Yes |
Yes |
Configuring SSO and 2FA with Wildfly-based Keycloak in Foreman |
Wildfly-based Keycloak |
Yes |
Yes |
Yes |
Yes |
Yes |
Configuring SSO and 2FA with Wildfly-based Keycloak in Foreman |
LDAP |
Yes |
No |
No |
No |
No |
Configuring an LDAP server as an external identity provider for Foreman |
2. Accessing Foreman
After Foreman has been installed and configured, use a browser to log in to the Foreman web UI interface. From the Foreman web UI, you can manage and monitor your Foreman infrastructure.
2.1. Logging in to the Foreman web UI
Use the web user interface to log in to Foreman for further configuration.
-
Ensure that the Katello root CA certificate is installed in your browser. For more information, see Importing the Katello root CA certificate.
-
Access Foreman server using a web browser pointed to the fully qualified domain name:
https://foreman.example.com/
-
Enter the user name and password created during the configuration process. If a user was not created during the configuration process, the default user name is admin.
-
If you have problems logging in, you can reset the password. For more information, see Resetting the administrative user password.
2.2. Importing the Katello root CA certificate
The first time you log in to Foreman, you might see a warning informing you that you are using the default self-signed certificate and you might not be able to connect this browser to Foreman until the root CA certificate is imported in the browser. Use the following procedure to locate the root CA certificate on Foreman and to import it into your browser.
To use the CLI instead of the Foreman web UI, see CLI Procedure.
-
Your Foreman is installed and configured.
-
Identify the fully qualified domain name of your Foreman server:
# hostname -f
-
Access the
pub
directory on your Foreman server using a web browser pointed to the fully qualified domain name:https://foreman.example.com/pub
-
When you access Foreman for the first time, an untrusted connection warning displays in your web browser. Accept the self-signed certificate and add the Foreman URL as a security exception to override the settings. This procedure might differ depending on the browser being used. Ensure that the Foreman URL is valid before you accept the security exception.
-
Select
katello-server-ca.crt
. -
Import the certificate into your browser as a certificate authority and trust it to identify websites.
-
From the Foreman CLI, copy the
katello-server-ca.crt
file to the machine you use to access the Foreman web UI:# scp /var/www/html/pub/katello-server-ca.crt username@hostname:remotefile
-
In the browser, import the
katello-server-ca.crt
certificate as a certificate authority and trust it to identify websites.
2.3. Resetting the administrative user password
Use the following procedures to reset the administrative password to randomly generated characters or to set a new administrative password.
-
Log in to the base operating system where Foreman server is installed.
-
Enter the following command to reset the password:
# foreman-rake permissions:reset Reset to user: admin, password: qwJxBptxb7Gfcjj5
-
Use this password to reset the password in the Foreman web UI.
-
Edit the
~/.hammer/cli.modules.d/foreman.yml
file on Foreman server to add the new password:# vi ~/.hammer/cli.modules.d/foreman.yml
Unless you update the ~/.hammer/cli.modules.d/foreman.yml
file, you cannot use the new password with Hammer CLI.
-
Log in to the base operating system where Foreman server is installed.
-
To set the password, enter the following command:
# foreman-rake permissions:reset password=new_password
-
Edit the
~/.hammer/cli.modules.d/foreman.yml
file on Foreman server to add the new password:# vi ~/.hammer/cli.modules.d/foreman.yml
Unless you update the ~/.hammer/cli.modules.d/foreman.yml
file, you cannot use the new password with Hammer CLI.
2.4. Setting a custom message on the Foreman web UI login page
You can change the default text on the login page to a custom message you want your users to see every time they access the page. For example, your custom message might be a warning required by your company.
-
In the Foreman web UI, navigate to Administer > Settings, and click the General tab.
-
Enter your custom message in the Login page footer text field.
-
Click Submit.
-
Log out of the Foreman web UI and verify that the custom message is now displayed on the login page.
3. Configuring Kerberos SSO with FreeIPA in Foreman
FreeIPA is an open-source identity management solution that provides centralized authentication, authorization, and account management services. With Foreman, you can integrate Foreman server with your existing FreeIPA server to enable FreeIPA users to authenticate to Foreman.
With your FreeIPA server configured as an external identity provider, users defined in FreeIPA can log in to Foreman with their FreeIPA credentials. If cross-forest trust is configured between FreeIPA and Active Directory, Active Directory users can also log in to Foreman.
FreeIPA users can log in using the following methods:
-
Username and password
-
Kerberos single sign-on
When cross-forest trust is configured between FreeIPA and Active Directory, Active Directory users can log in to Foreman with their user principal name (UPN) and password.
For information about FreeIPA, including its cross-forest trust functionality, see Red Hat Enterprise Linux 9 Planning Identity Management and Red Hat Enterprise Linux 9 Installing Identity Management.
3.1. Enrolling Foreman server in a FreeIPA domain
Create a host entry for your Foreman server system in the FreeIPA LDAP and configure the system to be a client in your FreeIPA domain.
-
An existing FreeIPA server
-
FreeIPA user account with privileges to enroll new FreeIPA hosts
-
On the FreeIPA server:
-
Create a host entry for the Foreman server system.
For more information, see Red Hat Enterprise Linux 9 Managing IdM users, groups, hosts, and access control rules.
-
Create an entry for the HTTP service for Foreman server. This enables access to the keytab file by creating a service principal for your Foreman server.
For more information on creating a service entry in FreeIPA, see Red Hat Enterprise Linux 9 Managing IdM users, groups, hosts, and access control rules.
-
-
On your Foreman server, configure the system as client in the FreeIPA domain. This includes ensuring that the system meets the necessary prerequisites, installing the necessary packages, and running the
ipa-client-install
utility.For more information, see Red Hat Enterprise Linux 9 Installing Identity Management.
NoteTo install packages on your Foreman server, use the
foreman-installer
utility.
-
On your Foreman server, check that you are able to resolve a user defined on the FreeIPA server. For example, to check the
admin
user that FreeIPA creates by default:$ id admin
On the FreeIPA server, a user named admin who has administrative privileges on the FreeIPA server prepares a host entry for the Foreman server system:
-
Authenticate as the FreeIPA admin user:
# kinit admin
-
Optional: Verify that you have authenticated successfully:
# klist
-
Create a host entry from the command line. Specify that you want to use a random password for the enrollment.
# ipa host-add --random foreman-server.example.com -------------------------------------------------- Added host "foreman-server.example.com" -------------------------------------------------- Host name: foreman-server.example.com Random password: W5YpARl=7M.n Password: True Keytab: False Managed by: ipa-server.example.com
-
Enable access to the keytab file by creating a service principal for your Foreman server:
# ipa service-add HTTP/foreman-server.example.com
On the Foreman server system, a user with Foreman administrative privileges enrolls the system into the FreeIPA domain:
-
Install the FreeIPA client packages:
# dnf install ipa-client
-
Configure the Foreman server system a client in FreeIPA by using the random password produced by
ipa host-add
in a previous step:# ipa-client-install --password 'W5YpARl=7M.n'
-
Verify that you are able to resolve the FreeIPA
admin
user from your Foreman server:$ id admin
3.2. Configuring the FreeIPA authentication source on Foreman server
Enable FreeIPA users to access Foreman by configuring FreeIPA as an authentication provider on your Foreman server.
-
Foreman server running on a system that is enrolled in the FreeIPA domain.
-
To enable access to the Foreman web UI only:
# foreman-installer \ --foreman-ipa-authentication=true
-
To enable access to the Foreman web UI and the Foreman API, including Hammer CLI:
# foreman-installer \ --foreman-ipa-authentication-api=true \ --foreman-ipa-authentication=true
WarningEnabling access to both the Foreman web UI and the Foreman API poses a security risk. After the FreeIPA user enters
kinit
to receive a Kerberos ticket-granting ticket (TGT), an attacker might obtain an API session. The attack is possible even if the user did not previously enter the Foreman login credentials anywhere, for example in the browser. -
To disable external authentication with FreeIPA, reset the options. For example, to disable access to the Foreman API and Hammer CLI:
# foreman-installer --reset-foreman-ipa-authentication-api
-
Log in to Foreman web UI by entering the credentials of a user defined in FreeIPA.
3.3. Configuring host-based access control for FreeIPA users logging in to Foreman
You can use host-based access control (HBAC) rules to manage access control within your FreeIPA domain. In FreeIPA, HBAC rules define which users can access which hosts and which services can be used to gain access.
For example, you can configure HBAC on the FreeIPA server to limit access to Foreman server only to selected users or user groups. By configuring a HBAC rule in the FreeIPA domain, you can ensure Foreman does not create database entries for users who should not have access.
-
FreeIPA user account with privileges to configure HBAC rules
-
On the FreeIPA server, configure HBAC control. For more information, see Red Hat Enterprise Linux 9 Managing IdM users, groups, hosts, and access control rules.
-
Create a HBAC service for Foreman server.
-
Create a new HBAC rule to define the required access control. Add the following FreeIPA entities to the HBAC rule:
-
The HBAC service for Foreman server
-
The Foreman server host
-
The users or user groups to whom you want to grant access
-
-
Make sure the default FreeIPA
allow_all
rule is disabled.
-
-
On your Foreman server, load the host-based access control rules from FreeIPA:
# foreman-installer --foreman-pam-service=foreman-prod
-
Log in to the Foreman web UI as a user defined in FreeIPA.
-
If the user is included in the HBAC rule, Foreman web UI will grant access.
-
If the user is not included in the HBAC rule, Foreman web UI will not grant access.
-
-
For more information about the
allow_all
rule and configuring HBAC in FreeIPA, see Host-based access control (HBAC) in FreeIPA documentation.
On the FreeIPA server, a user with administrative privileges configures a HBAC rule to allow selected users access to Foreman server:
-
Authenticate as the user with privileges required to configure HBAC rules:
$ kinit admin
-
Optional: Verify that you have authenticated successfully:
$ klist
-
Create a new HBAC service named
foreman-prod
:$ ipa hbacsvc-add foreman-prod
-
Create a new HBAC rule:
$ ipa hbacrule-add allow-foreman-prod
-
Add the following FreeIPA entities to the HBAC rule:
-
The
foreman-prod
HBAC service:$ ipa hbacrule-add-service allow-foreman-prod --hbacsvcs=foreman-prod
-
The Foreman server host:
$ ipa hbacrule-add-host allow-foreman-prod --hosts=foreman.example.com
-
The users or user groups to whom you want to grant access:
$ ipa hbacrule-add-user allow-foreman-prod --user=ipa-user
-
-
Optional: Verify the status of the rule:
$ ipa hbacrule-find foreman-prod $ ipa hbactest --user=ipa-user --host=foreman.example.com --service=foreman-prod
-
Disable the default
allow_all
rule:
$ ipa hbacrule-disable allow_all
On Foreman server, a Foreman administrator re-runs foreman-installer to load the host-based access control rules from FreeIPA:
# foreman-installer --foreman-pam-service=foreman-prod
3.4. Configuring Hammer CLI to accept FreeIPA credentials
Configure the Foreman Hammer CLI tool to use FreeIPA to authenticate users.
-
You have enabled FreeIPA access to the Foreman API. For more information, see Configuring the FreeIPA authentication source on Foreman server.
-
Open the
~/.hammer/cli.modules.d/foreman.yml
file on your Foreman server and update the list offoreman
parameters:-
To enforce session usage, enable
:use_sessions:
::foreman: :use_sessions: true
With this configuration, you will need to initiate an authentication session manually with
hammer auth login negotiate
. -
Alternatively, to enforce session usage and also negotiate authentication by default:
:foreman: :default_auth_type: 'Negotiate_Auth' :use_sessions: true
With this configuration, Hammer will negotiate authentication automatically when you enter the first
hammer
command.
-
3.5. Logging in to Hammer CLI with FreeIPA credentials
Authenticate to the Foreman Hammer CLI with your FreeIPA username and password.
-
You have configured Hammer CLI to accept FreeIPA credentials. For more information, see Configuring Hammer CLI to accept FreeIPA credentials in Installing Foreman Server with Katello nightly plugin on Enterprise Linux.
-
Authenticate as a user defined in FreeIPA to obtain a Kerberos ticket-granting ticket (TGT):
$ kinit FreeIPA_user
WarningIf you enabled access to the Foreman API and the Foreman web UI when you were configuring FreeIPA as the authentication provider for Foreman, an attacker might now obtain an API session after the user receives the Kerberos TGT. The attack is possible even if the user did not previously enter the Foreman login credentials anywhere, for example in the browser.
-
If Hammer is not configured to negotiate authentication, initiate an authentication session manually:
$ hammer auth login negotiate
Note
|
If you destroy the active Kerberos ticket, for example with |
-
Use any
hammer
command to check that the system does not ask you to authenticate. For example:$ hammer host list
-
For more information about authenticating with Hammer, see
hammer auth --help
.
3.6. Logging in to the Foreman web UI with FreeIPA credentials in Mozilla Firefox
You can use Mozilla Firefox to log in to the Foreman web UI with your FreeIPA credentials.
Use the latest stable Mozilla Firefox browser.
-
You have FreeIPA authentication configured in your Foreman environment. For more information, see Installing Foreman Server with Katello nightly plugin on Enterprise Linux.
-
The host on which you are using Mozilla Firefox is a client in the FreeIPA domain.
-
Your Mozilla Firefox is configured for Single Sign-On (SSO).
-
Obtain the Kerberos ticket granting ticket (TGT):
$ kinit user Password for user@EXAMPLE.COM:
-
In Mozilla Firefox, go to the URL of your Foreman server.
-
You are logged in automatically.
Alternatively:
-
In your browser address bar, enter the URL of your Foreman server.
-
Enter your username and password.
3.7. Logging in to the Foreman web UI with FreeIPA credentials in Chrome
You can use Chrome to log in to the Foreman web UI with your FreeIPA credentials.
Use the latest stable Chrome browser.
-
You have FreeIPA authentication configured in your Foreman environment. For more information, see Installing Foreman Server with Katello nightly plugin on Enterprise Linux.
-
The host on which you are using Chrome is a client in the FreeIPA domain.
-
Enable the Chrome browser to use Kerberos authentication:
$ google-chrome --auth-server-whitelist="*.example.com" --auth-negotiate-delegate-whitelist="*.example.com"
NoteInstead of allowlisting the whole domain, you can also allowlist a specific Foreman server.
-
Obtain the Kerberos ticket-granting ticket (TGT):
$ kinit user Password for user@EXAMPLE.COM:
-
In Chrome, go to the URL of your Foreman server.
-
You are logged in automatically.
Alternatively:
-
In your browser address bar, enter the URL of your Foreman server.
-
Enter your username and password.
3.8. Configuring a cross-forest trust between FreeIPA and Active Directory for Foreman
When your FreeIPA deployment includes a cross-forest trust with Active Directory (AD), configure host-based access control (HBAC) and the System Security Services Daemon (SSSD) to enable AD users to log in to Foreman.
-
An existing FreeIPA server with a cross-forest trust with AD established. For more information, see Red Hat Enterprise Linux 8 Installing trust between IdM and AD.
On your FreeIPA server:
-
Enable HBAC:
-
Create an external group and add the AD group to it.
-
Add the new external group to a POSIX group.
-
Use the POSIX group in a HBAC rule.
-
On your FreeIPA server and all replicas in your FreeIPA topology, configure SSSD to transfer additional attributes of AD users:
-
Add the AD user attributes to the nss and domain sections in
/etc/sssd/sssd.conf
. For example:[domain/EXAMPLE.com] ... krb5_store_password_if_offline = True ldap_user_extra_attrs=email:mail, lastname:sn, firstname:givenname [nss] user_attributes=+email, +firstname, +lastname [ifp] allowed_uids = ipaapi, root user_attributes=+email, +firstname, +lastname
-
Clear the SSSD cache:
-
Stop SSSD:
# systemctl stop sssd
-
Clear the cache:
# sss_cache -E
-
Start SSSD:
# systemctl start sssd
-
-
Verify the AD attributes value by using the
dbus-send
command on your Foreman server and on your FreeIPA server. Make sure that both outputs match.# dbus-send --print-reply --system --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe org.freedesktop.sssd.infopipe.GetUserAttr string:ad-user@ad-domain array:string:email,firstname,lastname
4. Configuring SSO and 2FA with Wildfly-based Keycloak in Foreman
Note
|
The default Keycloak distribution is now based on Quarkus. Quarkus-based Keycloak replaces Wildfly-based Keycloak in Foreman deployments. For information about configuring Quarkus-based Keycloak authentication, see Configuring SSO and 2FA with Quarkus-based Keycloak in Foreman. For information about migrating from Wildfly-based Keycloak to Quarkus-based Keycloak, see Migrating to Quarkus distribution. |
Keycloak is an open-source identity and access management solution that provides authentication features, such as single sign-on functionality, user federation, and centralized authentication management. With Wildfly-based Keycloak, you can integrate Foreman server with your existing Keycloak server to delegate user authentication and authorization to Keycloak.
Keycloak users can log in using the following login methods:
-
User name and password in Foreman web UI and Hammer CLI
-
Time-based one-time password (TOTP)
-
PIV cards
4.1. Prerequisites for configuring Foreman with Wildfly-based Keycloak authentication
-
A Keycloak account with administrative privileges.
-
A Keycloak server that uses HTTPS instead of HTTP.
-
If the certificates or the CA are self-signed, ensure that they are added to the end-user certificate truststore.
-
A Keycloak realm created for Foreman user accounts, for example
Foreman_Realm
. -
Users imported or added to Keycloak. For more information about importing or creating users, see the Red Hat Single Sign-On Server Administration Guide.
4.2. Registering Foreman as a client of Keycloak
Users defined in Keycloak can authenticate to Foreman by using the Foreman web UI or by using Hammer CLI. Each authentication method requires you to register a separate Foreman client to Keycloak. If you want users to authenticate by using both Foreman web UI and Hammer CLI, you must register two different Foreman clients to Keycloak.
On your Foreman server:
-
Install the packages required for registering a Keycloak client:
# dnf install mod_auth_openidc keycloak-httpd-client-install python3-lxml
-
Choose the authentication method you want Keycloak users to use when authenticating to Foreman:
-
If you want users to authenticate by using the Foreman web UI:
-
Create a client for Foreman. Use
foreman-openidc
as the application name.# keycloak-httpd-client-install --app-name foreman-openidc \ --keycloak-server-url "https://keycloak.example.com" \ --keycloak-admin-username "admin" \ --keycloak-realm "Foreman_Realm" \ --keycloak-admin-realm master \ --keycloak-auth-role root-admin \ -t openidc -l /users/extlogin --force
-
Configure Foreman to use Keycloak as an authentication source for Foreman web UI:
# foreman-installer --foreman-keycloak true \ --foreman-keycloak-app-name "foreman-openidc" \ --foreman-keycloak-realm "Foreman_Realm"
-
-
If you want users to authenticate by using the Hammer CLI:
-
Create a client for Foreman. Use
hammer-openidc
as the application name.# keycloak-httpd-client-install --app-name hammer-openidc \ --keycloak-server-url "https://keycloak.example.com" \ --keycloak-admin-username "admin" \ --keycloak-realm "Foreman_Realm" \ --keycloak-admin-realm master \ --keycloak-auth-role root-admin \ -t openidc -l /users/extlogin --force
-
Configure Foreman to use Keycloak as an authentication source for Hammer CLI:
# foreman-installer --foreman-keycloak true \ --foreman-keycloak-app-name "hammer-openidc" \ --foreman-keycloak-realm "Foreman_Realm"
-
Reset Keycloak support to the default value to ensure that users are not authenticated also in Foreman web UI:
# foreman-installer --reset-foreman-keycloak
-
-
-
Restart the
httpd
service:# systemctl restart httpd
Note
|
To disable Keycloak authentication in Foreman, reset Keycloak support to the default value by using |
4.3. Configuring the Foreman client in Wildfly-based Keycloak
Configure the Foreman client in Wildfly-based Keycloak with valid redirect URIs and mappers.
In the Keycloak web UI:
-
Go to the realm created for Foreman users. Navigate to Clients and click the Foreman client.
-
Configure access type:
-
If you are configuring a client that will provide Foreman web UI authentication, select confidential from the Access Type list.
-
If you are configuring a client that will provide Hammer CLI authentication, select public from the Access Type list.
-
-
Configure Valid redirect URI addresses:
-
If you are configuring a client that will provide Foreman web UI authentication:
-
You will see a pre-defined URI:
https://foreman.example.com/users/extlogin/redirect_uri
. Do not change or remove this URI. -
Add another URI below the pre-defined URI:
https://foreman.example.com/users/extlogin
-
-
If you are configuring a client that will provide Hammer CLI authentication:
-
You will see a pre-defined URI:
https://foreman.example.com/users/extlogin/redirect_uri
. Do not change or remove this URI. -
Add another URI below the pre-defined URI:
urn:ietf:wg:oauth:2.0:oob
-
-
-
Click Save.
-
On the Mappers tab, click Create to add an audience mapper.
-
From the Mapper Type list, select Audience.
-
From the Included Client Audience list, select the Foreman client.
-
-
Click Save.
-
On the Mappers tab, click Create to add a group mapper so that you can specify authorization in Foreman based on group membership.
-
From the Mapper Type list, select Group Membership.
-
In the Token Claim Name field, enter groups.
-
Set the Full group path setting to
OFF
.
-
-
Click Save.
-
For more information about configuring Wildfly-based Keycloak clients, see Red Hat Single Sign-On Server Administration Guide.
4.4. Configuring a Foreman client to provide Foreman web UI authentication with Keycloak
If you are configuring a client that will provide Foreman web UI authentication to your Foreman deployment, delegate authentication to the Keycloak server and add Keycloak as an external authentication source in Foreman.
-
Ensure that the Access Type setting in the Foreman client in the Wildfly-based Keycloak web UI is set to confidential. For more information, see Configuring the Foreman client in Wildfly-based Keycloak.
In the Foreman web UI:
-
Navigate to Administer > Settings.
-
On the Authentication tab, configure the following settings:
-
Authorize login delegation: Set to
Yes
. -
Authorize login delegation auth source user autocreate: Set to
External
. -
Login delegation logout URL: Set to
https://foreman.example.com/users/extlogout
. -
OIDC Algorithm: For example, set to
RS256
. -
OIDC Audience: Set to the client ID for Keycloak.
-
OIDC Issuer: Set to
https://keycloak.example.com/auth/realms/Foreman_Realm
. -
OIDC JWKs URL: Set to
https://keycloak.example.com/auth/realms/Foreman_Realm/protocol/openid-connect/certs
.
-
-
Navigate to Administer > Authentication Sources.
-
From the External menu, select Edit.
-
On the Locations tab, add the locations that you want to be able to use the Keycloak authentication source.
-
On the Organizations tab, add the organizations that you want to be able to use the Keycloak authentication source.
-
Click Submit.
-
4.5. Configuring a Foreman client to provide Hammer CLI authentication with Keycloak
If you are configuring a client that will provide Hammer CLI authentication to your Foreman deployment, delegate authentication to the Keycloak server and add Keycloak as an external authentication source in Foreman.
-
Ensure that the Access Type setting in the Foreman client in the Wildfly-based Keycloak web UI is set to public. For more information, see Configuring the Foreman client in Wildfly-based Keycloak.
-
Obtain the values to configure Foreman settings from the following URL:
https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration
. Replace Foreman_Realm with the name of the Keycloak realm created for your Foreman server.
On the Foreman client registered to Keycloak:
-
Set the login delegation to
true
so that users can authenticate using the Open IDC protocol:$ hammer settings set --name authorize_login_delegation --value true
-
Set the login delegation logout URL:
$ hammer settings set --name login_delegation_logout_url \ --value https://foreman.example.com/users/extlogout
-
Set the algorithm for encoding: For example, to use the
RS256
algorithm:$ hammer settings set --name oidc_algorithm --value 'RS256'
-
Add the value for the Hammer client in the Open IDC audience:
$ hammer settings set --name oidc_audience \ --value "['foreman.example.com-hammer-openidc']"
NoteIf you register several Keycloak clients to Foreman, ensure that you append all audiences in the array. For example:
$ hammer settings set --name oidc_audience \ --value "['foreman.example.com-foreman-openidc', 'foreman.example.com-hammer-openidc']"
-
Set the value for the Open IDC issuer:
$ hammer settings set --name oidc_issuer \ --value "https://keycloak.example.com/auth/realms/KEYCLOAK_REALM"
-
Set the value for Open IDC Java Web Token (JWT):
$ hammer settings set --name oidc_jwks_url \ --value "https://keycloak.example.com/auth/realms/KEYCLOAK_REALM/protocol/openid-connect/certs"
-
Retrieve the ID of the Keycloak authentication source:
$ hammer auth-source external list
-
Set the location and organization:
$ hammer auth-source external update \ --id My_Authentication_Source_ID \ --location-ids My_Location_ID \ --organization-ids My_Organization_ID
4.6. Configuring Foreman with Keycloak for TOTP authentication
If you want users to authenticate with time-based one-time passwords (TOTP), configure an OTP policy for the Foreman realm in Keycloak.
-
In the Keycloak web UI, navigate to the Foreman realm.
-
Navigate to Authentication.
-
On the Policies tab, click the OTP Policy tab. Ensure that the Supported Applications field includes FreeOTP or Google Authenticator.
-
Configure the OTP settings to suit your requirements.
-
On Required Actions tab, enable the Set as default action setting for the Configure OTP action.
-
For more information, see Red Hat Single Sign-On Server Administration Guide or Red Hat build of Keycloak Server Administration Guide.
4.7. Configuring Keycloak settings for authentication with PIV cards
If you want users to authenticate with PIV cards, configure Keycloak for authentication with PIV cards and configure the operating system for PIV cards on each user system.
In the Keycloak web UI:
-
Navigate to the Authentication tab.
-
From the Flows list, select Browser.
-
Click Copy to copy this flow.
-
In the Copy Authentication Flow window, enter a new name for the flow and click OK.
-
In the copied flow, delete the Username Password Form and OTP Form entries.
-
Click Add execution.
-
From the Provider list, select X509/Validate Username Form.
-
Click Save.
-
-
In the X509/Validate Username Form row, select ALTERNATIVE. Click Actions > Config.
-
In the Alias field, enter a name for this configuration.
-
From the User Identity Source list, select Subject’s Common Name,
-
From the User mapping method list, select Username or Email.
-
Click Save.
-
-
Navigate to Authentication > Bindings.
-
From the Browser Flow list, select the created flow.
On each system from which you want users to log in to with PIV cards:
-
Install the
opensc
package:-
On Debian or Ubuntu:
# apt install opensc
-
On Enterprise Linux 8+:
# dnf install opensc
-
On Enterprise Linux 7:
# yum install opensc
-
On OpenSUSE and SUSE Linux Enterprise Server:
# zypper install opensc
-
-
Make sure Mozilla Firefox is installed.
-
In Mozilla Firefox main menu, click Settings.
-
On the Privacy and Security tab, click Security Devices.
-
Click Load.
-
In the Load PKCS#11 Device Driver window, enter /usr/lib64/pkcs11/opensc-pkcs11.so in the Module filename field.
-
Click OK.
-
-
If the PIV card is connected to system, restart the
pcscd
service.
4.8. Optional: Configuring external group mapping for Keycloak authentication
To implement the role-based access control (RBAC), create a group in Foreman, assign a role to this group, and then map an Keycloak group to the Foreman group. As a result, anyone in the given group in Keycloak will log in under the corresponding Foreman group.
For example, you can configure users of the Foreman-admin user group defined in Active Directory to authenticate as users with administrator privileges on Foreman.
If you do not configure group mapping, every user will receive the Default role permissions.
-
In the Foreman web UI, navigate to Administer > User Groups.
-
Click Create User Group.
-
In the Name field, enter a name for the user group. Enter a name that is different from the Active Directory user group name.
-
Do not add any users or user groups to the new group in Foreman web UI.
-
-
On the Roles tab, select Administer.
-
On the External Groups tab, click Add external user group.
-
In the Name field, enter the name of the Active Directory group.
-
From the Auth Source drop-down menu, select EXTERNAL.
-
-
Click Submit.
4.9. Logging in to Foreman configured with Keycloak as an authentication source
With Keycloak configured as an external authentication source for Foreman, users defined in a Keycloak realm can log in to Foreman server. The particular login methods available to users depend on how you configured integration between Keycloak and Foreman.
To authenticate to the Foreman web UI:
-
In your browser, go to
https://foreman.example.com
and enter your credentials.
To authenticate to the Foreman web UI by using Keycloak TOTP:
-
In your browser, log in to Foreman. Foreman redirects you to the Keycloak login screen.
-
Enter your username and password, and click Log In.
-
On your first login attempt, Keycloak requests you to configure your client by scanning the bar code and entering your PIN. Once authenticated, your browser redirects you back to Foreman and logs you in.
To authenticate to the Foreman CLI with Hammer:
-
Ensure that Hammer is configured to enforce session usage in
~/.hammer/cli.modules.d/foreman.yml
::foreman: :use_sessions: true
-
Initiate an authentication session with
hammer auth login oauth
:$ hammer auth login oauth \ --oidc-token-endpoint 'https://keycloak.example.com/auth/realms/Foreman_realm/protocol/openid-connect/token' \ --oidc-authorization-endpoint 'https://keycloak.example.com/auth' \ --oidc-client-id 'foreman.example.com-hammer-openidc' \ --oidc-redirect-uri urn:ietf:wg:oauth:2.0:oob
To authenticate to the Foreman CLI with Hammer by using Keycloak TOTP:
-
Ensure that Hammer is configured to enforce session usage in
~/.hammer/cli.modules.d/foreman.yml
::foreman: :use_sessions: true
-
Initiate an authentication session by using
--two-factor
withhammer auth login oauth
:$ hammer auth login oauth \ --two-factor \ --oidc-token-endpoint 'https://keycloak.example.com/auth/realms/Foreman_realm/protocol/openid-connect/token' \ --oidc-authorization-endpoint 'https://keycloak.example.com/auth' \ --oidc-client-id 'foreman.example.com-hammer-openidc' \ --oidc-redirect-uri urn:ietf:wg:oauth:2.0:oob
-
You will be prompted to enter a success code. To retrieve the success code, navigate to the URL that the command returns.
-
Enter the success code in CLI.
To log in to the Foreman web UI using the Keycloak PIV cards:
-
In Mozilla Firefox, log in to Foreman and enter your credentials.
-
When prompted, enter the PIN of the PIV card.
-
Choose the certificate for authentication. Browser verifies this certificate with Keycloak. Once authenticated, browser redirects you back to Foreman and logs you in.
5. Configuring SSO and 2FA with Quarkus-based Keycloak in Foreman
Quarkus-based Keycloak is an open-source identity and access management solution that provides authentication features, such as single sign-on functionality, user federation, and centralized authentication management. With Quarkus-based Keycloak, you can integrate Foreman server with your existing Quarkus-based Keycloak server to delegate user authentication and authorization to Quarkus-based Keycloak.
Keycloak users can log in using the following login methods:
-
User name and password in Foreman web UI and Hammer CLI
-
Time-based one-time password (TOTP), an implementation of two-factor authentication (2FA)
-
PIV cards
For information about Keycloak, see Keycloak documentation.
5.1. Prerequisites for configuring Foreman with Quarkus-based Keycloak authentication
-
A Keycloak account with administrative privileges.
-
A Keycloak server that uses HTTPS instead of HTTP and has been initialized with the
--http-relative-path=/auth
context path. To access a Keycloak server initialized with--http-relative-path=/auth
from its web UI, go tohttps://keycloak.example.com:8443/auth
.NoteTo use a different context path, make manual adjustments after the initialisation with
/auth
or configure theforeman-openidc_oidc_keycloak_Foreman_Realm.conf
file of the HTTPd service manually. For more information about configuring a different context path, see the Red Hat build of Keycloak Administration Guide. -
If the certificates or the CA are self-signed, add them to the end-user certificate truststore.
-
A Keycloak realm created for Foreman user accounts, for example
Foreman_Realm
. -
Users imported or added to Keycloak. For more information on importing or creating users, see the Red Hat build of Keycloak Administration Guide.
5.2. Registering Foreman as a client of Keycloak
Users defined in Keycloak can authenticate to Foreman by using one of the following methods:
-
The Foreman web UI
-
Hammer CLI
Choose one of these methods to enable in your Foreman deployment.
On your Foreman server:
-
Install the packages required for registering a Keycloak client:
# dnf install mod_auth_openidc keycloak-httpd-client-install python3-lxml
-
Choose the authentication method you want Keycloak users to use when authenticating to Foreman:
-
If you want users to authenticate by using the Foreman web UI:
-
Create a client for Foreman. Use
foreman-openidc
as the application name.# keycloak-httpd-client-install --app-name foreman-openidc \ --keycloak-server-url "https://keycloak.example.com" \ --keycloak-admin-username "admin" \ --keycloak-realm "Foreman_Realm" \ --keycloak-admin-realm master \ --keycloak-auth-role root-admin \ -t openidc -l /users/extlogin --force
-
Configure Foreman to use Keycloak as an authentication source for Foreman web UI:
# foreman-installer --foreman-keycloak true \ --foreman-keycloak-app-name "foreman-openidc" \ --foreman-keycloak-realm "Foreman_Realm"
-
-
If you want users to authenticate by using the Hammer CLI:
-
Create a client for Foreman. Use
hammer-openidc
as the application name.# keycloak-httpd-client-install --app-name hammer-openidc \ --keycloak-server-url "https://keycloak.example.com" \ --keycloak-admin-username "admin" \ --keycloak-realm "Foreman_Realm" \ --keycloak-admin-realm master \ --keycloak-auth-role root-admin \ -t openidc -l /users/extlogin --force
-
Configure Foreman to use Keycloak as an authentication source for Hammer CLI:
# foreman-installer --foreman-keycloak true \ --foreman-keycloak-app-name "hammer-openidc" \ --foreman-keycloak-realm "Foreman_Realm"
-
Reset Keycloak support to the default value to ensure that users are not authenticated also in Foreman web UI:
# foreman-installer --reset-foreman-keycloak
-
-
-
Restart the
httpd
service:# systemctl restart httpd
Note
|
To disable Keycloak authentication in Foreman, reset Keycloak support to the default value by using |
5.3. Configuring the Foreman client in Quarkus-based Keycloak
Configure the Foreman client in Quarkus-based Keycloak with valid redirect URIs and mappers.
In the Quarkus-based Keycloak web UI:
-
Go to the realm created for Foreman users.
-
Navigate to Clients and click the Foreman client.
-
On the Settings tab for the Foreman client, configure the access type and redirect addresses:
-
If you are configuring a client that will provide Foreman web UI authentication:
-
Enable Client authentication.
-
You will see a pre-defined URI:
https://foreman.example.com/users/extlogin/redirect_uri
. Do not change or remove this URI. -
Add another URI below the pre-defined URI:
https://foreman.example.com/users/extlogin
-
-
If you are configuring a client that will provide Hammer CLI authentication:
-
Ensure Client authentication is disabled.
-
You will see a pre-defined URI:
https://foreman.example.com/users/extlogin/redirect_uri
. Do not change or remove this URI. -
Add another URI below the pre-defined URI:
urn:ietf:wg:oauth:2.0:oob
-
-
-
On the Client Scopes tab for the Foreman client, locate the client scope dedicated to the Foreman client named
client-name-dedicated
. Start editing the client scope.-
On the Mappers tab for
client-name-dedicated
, add a new mapper by configuration. Select the Audience mapper type.-
From the Included Client Audience list, select the Foreman client.
-
Enable Add to ID token.
-
Click Save.
-
-
Add another mapper by configuration. Select the Group Membership mapper type. This adds a group mapper so that you can specify authorization in Foreman based on group membership.
-
In the Token Claim Name field, enter groups.
-
Disable Full group path.
-
Click Save.
-
-
-
For more information about configuring Quarkus-based Keycloak clients, see Red Hat build of Keycloak Server Administration Guide.
5.4. Configuring a Foreman client to provide Foreman web UI authentication with Keycloak
If you are configuring a client that will provide Foreman web UI authentication to your Foreman deployment, delegate authentication to the Keycloak server and add Keycloak as an external authentication source in Foreman.
-
Ensure that the Client authentication setting in the Foreman client in the Quarkus-based Keycloak web UI is enabled. For more information, see Configuring the Foreman client in Quarkus-based Keycloak.
In the Foreman web UI:
-
Navigate to Administer > Settings.
-
On the Authentication tab, configure the following settings:
-
Authorize login delegation: Set to
Yes
. -
Authorize login delegation auth source user autocreate: Set to
External
. -
Login delegation logout URL: Set to
https://foreman.example.com/users/extlogout
. -
OIDC Algorithm: For example, set to
RS256
. -
OIDC Audience: Set to the client ID for Keycloak.
-
OIDC Issuer: Set to
https://keycloak.example.com:8443/auth/realms/Foreman_Realm
. -
OIDC JWKs URL: Set to
https://keycloak.example.com:8443/auth/realms/Foreman_Realm/protocol/openid-connect/certs
.
-
-
Navigate to Administer > Authentication Sources.
-
From the External menu, select Edit.
-
On the Locations tab, add the locations that you want to be able to use the Keycloak authentication source.
-
On the Organizations tab, add the organizations that you want to be able to use the Keycloak authentication source.
-
Click Submit.
-
5.5. Configuring a Foreman client to provide Hammer CLI authentication with Keycloak
If you are configuring a client that will provide Hammer CLI authentication to your Foreman deployment, delegate authentication to the Keycloak server and add Keycloak as an external authentication source in Foreman.
-
Ensure that the Client authentication setting in the Foreman client in the Quarkus-based Keycloak web UI is disabled. For more information, see Configuring the Foreman client in Quarkus-based Keycloak.
-
Obtain the values to configure Foreman settings from the following URL:
https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration
. Replace Foreman_Realm with the name of the Keycloak realm created for your Foreman server.
On the Foreman client registered to Keycloak:
-
Set the login delegation to
true
so that users can authenticate using the Open IDC protocol:$ hammer settings set --name authorize_login_delegation --value true
-
Set the login delegation logout URL:
$ hammer settings set --name login_delegation_logout_url \ --value https://foreman.example.com/users/extlogout
-
Set the algorithm for encoding: For example, to use the
RS256
algorithm:$ hammer settings set --name oidc_algorithm --value 'RS256'
-
Add the value for the Hammer client in the Open IDC audience:
$ hammer settings set --name oidc_audience \ --value "['foreman.example.com-hammer-openidc']"
NoteIf you register several Keycloak clients to Foreman, ensure that you append all audiences in the array. For example:
$ hammer settings set --name oidc_audience \ --value "['foreman.example.com-foreman-openidc', 'foreman.example.com-hammer-openidc']"
-
Set the value for the Open IDC issuer:
$ hammer settings set --name oidc_issuer \ --value "https://keycloak.example.com/auth/realms/KEYCLOAK_REALM"
-
Set the value for Open IDC Java Web Token (JWT):
$ hammer settings set --name oidc_jwks_url \ --value "https://keycloak.example.com/auth/realms/KEYCLOAK_REALM/protocol/openid-connect/certs"
-
Retrieve the ID of the Keycloak authentication source:
$ hammer auth-source external list
-
Set the location and organization:
$ hammer auth-source external update \ --id My_Authentication_Source_ID \ --location-ids My_Location_ID \ --organization-ids My_Organization_ID
5.6. Configuring Foreman with Keycloak for TOTP authentication
If you want users to authenticate with time-based one-time passwords (TOTP), configure an OTP policy for the Foreman realm in Keycloak.
-
In the Keycloak web UI, navigate to the Foreman realm.
-
Navigate to Authentication.
-
On the Policies tab, click the OTP Policy tab. Ensure that the Supported Applications field includes FreeOTP or Google Authenticator.
-
Configure the OTP settings to suit your requirements.
-
On Required Actions tab, enable the Set as default action setting for the Configure OTP action.
-
For more information, see Red Hat Single Sign-On Server Administration Guide or Red Hat build of Keycloak Server Administration Guide.
5.7. Configuring Keycloak settings for authentication with PIV cards
If you want users to authenticate with PIV cards, configure Keycloak for authentication with PIV cards and configure the operating system for PIV cards on each user system.
In the Keycloak web UI:
-
Navigate to the Authentication tab.
-
From the Flows list, select Browser.
-
Click Copy to copy this flow.
-
In the Copy Authentication Flow window, enter a new name for the flow and click OK.
-
In the copied flow, delete the Username Password Form and OTP Form entries.
-
Click Add execution.
-
From the Provider list, select X509/Validate Username Form.
-
Click Save.
-
-
In the X509/Validate Username Form row, select ALTERNATIVE. Click Actions > Config.
-
In the Alias field, enter a name for this configuration.
-
From the User Identity Source list, select Subject’s Common Name,
-
From the User mapping method list, select Username or Email.
-
Click Save.
-
-
Navigate to Authentication > Bindings.
-
From the Browser Flow list, select the created flow.
On each system from which you want users to log in to with PIV cards:
-
Install the
opensc
package:-
On Debian or Ubuntu:
# apt install opensc
-
On Enterprise Linux 8+:
# dnf install opensc
-
On Enterprise Linux 7:
# yum install opensc
-
On OpenSUSE and SUSE Linux Enterprise Server:
# zypper install opensc
-
-
Make sure Mozilla Firefox is installed.
-
In Mozilla Firefox main menu, click Settings.
-
On the Privacy and Security tab, click Security Devices.
-
Click Load.
-
In the Load PKCS#11 Device Driver window, enter /usr/lib64/pkcs11/opensc-pkcs11.so in the Module filename field.
-
Click OK.
-
-
If the PIV card is connected to system, restart the
pcscd
service.
5.8. Optional: Configuring external group mapping for Keycloak authentication
To implement the role-based access control (RBAC), create a group in Foreman, assign a role to this group, and then map an Keycloak group to the Foreman group. As a result, anyone in the given group in Keycloak will log in under the corresponding Foreman group.
For example, you can configure users of the Foreman-admin user group defined in Active Directory to authenticate as users with administrator privileges on Foreman.
If you do not configure group mapping, every user will receive the Default role permissions.
-
In the Foreman web UI, navigate to Administer > User Groups.
-
Click Create User Group.
-
In the Name field, enter a name for the user group. Enter a name that is different from the Active Directory user group name.
-
Do not add any users or user groups to the new group in Foreman web UI.
-
-
On the Roles tab, select Administer.
-
On the External Groups tab, click Add external user group.
-
In the Name field, enter the name of the Active Directory group.
-
From the Auth Source drop-down menu, select EXTERNAL.
-
-
Click Submit.
5.9. Logging in to Foreman configured with Keycloak as an authentication source
With Keycloak configured as an external authentication source for Foreman, users defined in a Keycloak realm can log in to Foreman server. The particular login methods available to users depend on how you configured integration between Keycloak and Foreman.
To authenticate to the Foreman web UI:
-
In your browser, go to
https://foreman.example.com
and enter your credentials.
To authenticate to the Foreman web UI by using Keycloak TOTP:
-
In your browser, log in to Foreman. Foreman redirects you to the Keycloak login screen.
-
Enter your username and password, and click Log In.
-
On your first login attempt, Keycloak requests you to configure your client by scanning the bar code and entering your PIN. Once authenticated, your browser redirects you back to Foreman and logs you in.
To authenticate to the Foreman CLI with Hammer:
-
Ensure that Hammer is configured to enforce session usage in
~/.hammer/cli.modules.d/foreman.yml
::foreman: :use_sessions: true
-
Initiate an authentication session with
hammer auth login oauth
:$ hammer auth login oauth \ --oidc-token-endpoint 'https://keycloak.example.com/auth/realms/Foreman_realm/protocol/openid-connect/token' \ --oidc-authorization-endpoint 'https://keycloak.example.com/auth' \ --oidc-client-id 'foreman.example.com-hammer-openidc' \ --oidc-redirect-uri urn:ietf:wg:oauth:2.0:oob
To authenticate to the Foreman CLI with Hammer by using Keycloak TOTP:
-
Ensure that Hammer is configured to enforce session usage in
~/.hammer/cli.modules.d/foreman.yml
::foreman: :use_sessions: true
-
Initiate an authentication session by using
--two-factor
withhammer auth login oauth
:$ hammer auth login oauth \ --two-factor \ --oidc-token-endpoint 'https://keycloak.example.com/auth/realms/Foreman_realm/protocol/openid-connect/token' \ --oidc-authorization-endpoint 'https://keycloak.example.com/auth' \ --oidc-client-id 'foreman.example.com-hammer-openidc' \ --oidc-redirect-uri urn:ietf:wg:oauth:2.0:oob
-
You will be prompted to enter a success code. To retrieve the success code, navigate to the URL that the command returns.
-
Enter the success code in CLI.
To log in to the Foreman web UI using the Keycloak PIV cards:
-
In Mozilla Firefox, log in to Foreman and enter your credentials.
-
When prompted, enter the PIN of the PIV card.
-
Choose the certificate for authentication. Browser verifies this certificate with Keycloak. Once authenticated, browser redirects you back to Foreman and logs you in.
6. Configuring Kerberos SSO for Active Directory users in Foreman
If the base system of your Foreman server is connected directly to Active Directory (AD), you can configure AD as an external authentication source for Foreman. Direct AD integration means that a Linux system is joined directly to the AD domain where the identity is stored.
AD users can log in using the following methods:
-
Username and password
-
Kerberos single sign-on
Note
|
You can also connect your Foreman deployment to AD in the following ways:
|
6.1. Configuring the Active Directory authentication source on Foreman server
Enable Active Directory (AD) users to access Foreman by configuring the corresponding authentication provider on your Foreman server.
-
The base system of your Foreman server must be joined to an Active Directory (AD) domain. To enable AD users to sign in with Kerberos single sign-on, use the System Security Services Daemon (SSSD) and Samba services to join the base system to the AD domain:
Install the following packages on Foreman server:
# dnf install adcli krb5-workstation oddjob-mkhomedir oddjob realmd samba-winbind-clients samba-winbind samba-common-tools samba-winbind-krb5-locator sssd
Specify the required software when joining the AD domain:
# realm join AD.EXAMPLE.COM --membership-software=samba --client-software=sssd
For more information on direct AD integration, see Connecting RHEL systems directly to AD using Samba Winbind.
-
Define AD realm configuration in a location where foreman-installer expects it:
-
Create a directory named
/etc/ipa/
:# mkdir /etc/ipa/
-
Create the
/etc/ipa/default.conf
file with the following contents to configure the Kerberos realm for the AD domain:[global] realm = AD.EXAMPLE.COM
-
-
Configure the Apache keytab for Kerberos connections:
-
Update the
/etc/samba/smb.conf
file with the following settings to configure how Samba interacts with AD:[global] workgroup = AD.EXAMPLE realm = AD.EXAMPLE.COM kerberos method = system keytab security = ads
-
Add the Kerberos service principal to the keytab file at
/etc/httpd/conf/http.keytab
:# KRB5_KTNAME=FILE:/etc/httpd/conf/http.keytab net ads keytab add HTTP -U Administrator -s /etc/samba/smb.conf
-
-
Configure the System Security Services Daemon (SSSD) to use the AD access control provider to evaluate and enforce Group Policy Object (GPO) access control rules for the
foreman
PAM service:-
In the
[domain/ad.example.com]
section of your/etc/sssd/sssd.conf
file, configure thead_gpo_access_control
andad_gpo_map_service
options as follows:[domain/ad.example.com] ad_gpo_access_control = enforcing ad_gpo_map_service = +foreman
For more information on GPOs, see the following documents:
-
How SSSD interprets GPO access control rules in Integrating RHEL systems directly with Windows Active Directory (RHEL 9)
-
How SSSD interprets GPO access control rules in Integrating RHEL systems directly with Windows Active Directory (RHEL 8)
-
-
Restart SSSD:
# systemctl restart sssd
-
-
Enable the authentication source:
# foreman-installer --foreman-ipa-authentication=true
-
To verify that AD users can log in to Foreman by entering their credentials, log in to Foreman web UI at https://foreman.example.com. Enter the user name in the user principal name (UPN) format, for example:
ad_user@AD.EXAMPLE.COM
. -
To verify that AD users can authenticate by using Kerberos single sign-on:
-
Obtain a Kerberos ticket-granting ticket (TGT) on behalf of an AD user:
$ kinit ad_user@AD.EXAMPLE.COM
-
Verify user authentication by using your TGT:
$ curl -k -u : --negotiate https://foreman.example.com/users/extlogin <html><body>You are being <a href="foreman.example.com/hosts">redirected</a>.</body></html>
-
-
sssd-ad(5)
man page on your system -
For information about configuring Mozilla Firefox for Kerberos, see Configuring Firefox to use Kerberos for single sign-on in Red Hat Enterprise Linux 9 Configuring authentication and authorization in RHEL.
7. Configuring an LDAP server as an external identity provider for Foreman
Lightweight Directory Access Protocol (LDAP) is a set of open protocols used to access centrally stored information over a network. With Foreman, you can use one or multiple LDAP directories for external authentication.
Note
|
While you can configure the LDAP server integrated with FreeIPA as an external authentication source, FreeIPA users will not be able to log in by using single sign-on. Instead, consider configuring FreeIPA as an external identity provider. For more information, see Configuring Kerberos SSO with FreeIPA in Foreman. |
Important
|
Users cannot use both FreeIPA and LDAP as an authentication method. After a user authenticates by using one of these methods, they cannot use the other method. To change the authentication method for a user, remove the automatically created user from Foreman. |
7.1. Configuring TLS for secure LDAP
If Foreman uses TLS to establish a secure LDAP connection (LDAPS), you must obtain the CA certificates of your LDAP server and add them to the trusted CA list on the base operating system of your Foreman server.
If your LDAP server uses a certificate chain with intermediate certificate authorities, you must obtain all root and intermediate certificates and add them to the trusted CA list.
-
Obtain the CA certificate from the LDAP Server:
-
If you use Active Directory Certificate Services, export the Enterprise PKI CA Certificate using the Base64 encoded X.509 format. See How to configure Active Directory authentication with
TLS
on Foreman for information on creating and exporting a CA certificate from an Active Directory server. -
Download the LDAP server certificate to a temporary location on the Foreman server, such as
/tmp/example.crt
. You will remove the certificate when finished.The filename extensions
.cer
and.crt
are only conventions and can refer to DER binary or PEM ASCII format certificates.
-
-
Add the LDAP server certificate to the system truststore:
-
Import the certificate:
# cp /tmp/example.crt /etc/pki/tls/source/anchors
-
Update the certificate authority truststore:
# update-ca-trust extract
-
-
Delete the downloaded LDAP certificate from the temporary location on your Foreman server.
-
For more information about adding certificates to the system truststore, see Using shared system certificates in Red Hat Enterprise Linux 9 Securing networks.
7.2. Configuring Foreman to use LDAP
Configure an LDAP authentication source to enable users to log in to Foreman with their existing LDAP credentials.
-
Your LDAP server complies with the RFC 2307 schema.
-
Your user account has the following permissions:
-
view_authenticators
,create_authenticators
,edit_authenticators
-
view_locations
,assign_locations
-
view_organizations
,assign_organizations
-
-
On your Foreman server, enable the Network Information System (NIS) service so that SELinux does not block outgoing LDAP connections:
# setsebool -P nis_enabled on
-
In the Foreman web UI, navigate to Administer > Authentication Sources.
-
From the LDAP menu, select Create.
-
On the LDAP server tab, enter the details of your LDAP server.
For TLS encrypted connections, select LDAPS to enable encryption.
-
On the Account tab, enter the account information and domain name details.
-
On the Attribute mappings tab, map LDAP attributes to Foreman attributes.
-
On the Locations tab, select the locations you want Foreman to assign to users created from the LDAP authentication source. These locations are available to users after they log in for the first time.
-
On the Organizations tab, select the organizations you want Foreman to assign to users created from the LDAP authentication source. These locations are available to users after they log in for the first time.
-
Click Submit.
-
If you did not select Automatically Create Accounts In Foreman on the Account tab, create user accounts manually. For more information, see Creating a User in Administering Foreman.
-
If you selected Automatically Create Accounts In Foreman, LDAP users can now log in to Foreman using their LDAP accounts and passwords.
-
After users log in for the first time, the Foreman administrator must assign roles to them manually. For more information about assigning appropriate roles to user accounts, see Assigning Roles to a User in Administering Foreman.
7.3. Example settings for LDAP connections
This example uses a dedicated service account called redhat that has bind, read, and search permissions on the user and group entries.
-
Account Username: DOMAIN\redhat
-
Account password: P@ssword
-
Base DN: DC=example,DC=COM
-
Login name attribute: userPrincipalName
-
First name attribute: givenName
-
Last name attribute: sn
-
Email address attribute: mail
-
Photo attribute: thumbnailPhoto
The userPrincipalName
attribute allows the use of whitespace in usernames. The sAMAccountName
attribute, which provides backwards compatibility with legacy Microsoft systems, does not allow the use of whitespace in usernames.
This example uses a dedicated service account called redhat that has bind, read, and search permissions on the user and group entries.
-
Account Username: uid=redhat,cn=users,cn=accounts,dc=example,dc=com
-
Base DN: dc=example,dc=com
-
Groups Base DN: cn=groups,cn=accounts,dc=example,dc=com
-
Login name attribute: uid
-
First name attribute: givenName
-
Last name attribute: sn
-
Email address attribute: mail
This example uses a dedicated service account called redhat that has bind, read, and search permissions on the user and group entries.
-
Account Username: uid=redhat,ou=users,dc=example,dc=com
-
Base DN: dc=example,dc=com
-
Groups Base DN: cn=employee,ou=userclass,dc=example,dc=com
-
Login name attribute: uid
-
First name attribute: givenName
-
Last name attribute: sn
-
Email address attribute: mail
7.4. Example LDAP filters
You are using the following LDAP directory structure:
DC=Domain,DC=Example | |----- CN=Users | |----- CN=Group1 |----- CN=Group2 |----- CN=User1 |----- CN=User2 |----- CN=User3
Group membership is defined as follows:
-
Group1
includes usersUser1
andUser3
-
Group2
includes usersUser2
andUser3
For example, you can define the following search filters:
Search result (users) | Filter |
---|---|
User1 |
(distinguishedName=cn=User1,cn=Users,dc=domain,dc=example) |
User1, User3 |
(memberOf=cn=Group1,cn=Users,dc=domain,dc=example) |
User2, User3 |
(memberOf=cn=Group2,cn=Users,dc=domain,dc=example) |
User1, User2, User3 |
(|(memberOf=cn=Group1,cn=Users,dc=domain,dc=example)(memberOf=cn=Group2,cn=Users,dc=domain,dc=example)) |
User1, User2, User3 |
(memberOf:1.2.840.113556.1.4.1941:=cn=Users,dc=domain,dc=example) |
Because group Users
is a nested group that contains groups Group1
and Group2
, the filter must include memberOf:1.2.840.113556.1.4.1941:=
before the nested group name. This enables you to filter all users from the nested group.
8. Important user and group account information for Active Directory accounts
All user and group accounts must be local accounts. This is to ensure that there are no authentication conflicts between local accounts on your Foreman server and accounts in your Active Directory domain.
Your system is not affected by this conflict if your user and group accounts exist in both /etc/passwd
and /etc/group
files.
For example, to check if entries for puppet
, apache
, foreman
and foreman-proxy
groups exist in both /etc/passwd
and /etc/group
files, enter the following commands:
# grep 'puppet\|apache\|foreman\|foreman-proxy' /etc/passwd /etc/group
9. Configuring external user groups
Foreman does not associate external users with their user group automatically. You must create a user group with the same name as in the external source on Foreman. Members of the external user group then automatically become members of the Foreman user group and receive the associated permissions.
The configuration of external user groups depends on the type of external authentication.
To assign additional permissions to an external user, add this user to an internal user group that has no external mapping specified. Then assign the required roles to this group.
-
If you use an LDAP server, configure Foreman to use LDAP authentication. For more information, see Configuring an LDAP server as an external identity provider for Foreman.
When using external user groups from an LDAP source, you cannot use the
$login
variable as a substitute for the account user name. You must use either an anonymous or dedicated service user. -
If you use a FreeIPA or AD server, configure Foreman to use FreeIPA or AD authentication. For more information, see Configuring External Authentication in Installing Foreman Server with Katello nightly plugin on Enterprise Linux.
-
Ensure that at least one external user authenticates for the first time.
-
Retain a copy of the external group names you want to use. To find the group membership of external users, enter the following command:
# id username
-
In the Foreman web UI, navigate to Administer > User Groups, and click Create User Group.
-
Specify the name of the new user group. Do not select any users to avoid adding users automatically when you refresh the external user group.
-
Click the Roles tab and select the roles you want to assign to the user group. Alternatively, select the Administrator checkbox to assign all available permissions.
-
Click the External groups tab, then click Add external user group, and select an authentication source from the Auth source drop-down menu.
Specify the exact name of the external group in the Name field.
-
Click Submit.
10. Refreshing external user groups for LDAP
To set the LDAP source to synchronize user group membership automatically on user login, in the Auth Source page, select the Usergroup Sync option. If this option is not selected, LDAP user groups are refreshed automatically through a scheduled cron job synchronizing the LDAP Authentication source every 30 minutes by default.
If the user groups in the LDAP Authentication source change in the lapse of time between scheduled tasks, the user can be assigned to incorrect external user groups. This is corrected automatically when the scheduled task runs.
Use this procedure to refresh the LDAP source manually.
-
In the Foreman web UI, navigate to Administer > Usergroups and select a user group.
-
On the External Groups tab, click Refresh to the right of the required user group.
-
Enter the following command:
# foreman-rake ldap:refresh_usergroups
11. Refreshing external user groups for FreeIPA or AD
External user groups based on FreeIPA or AD are refreshed only when a group member logs in to Foreman. It is not possible to alter user membership of external user groups in the Foreman web UI, such changes are overwritten on the next group refresh.