Table of contents
1.
Introduction
2.
Security Assertion Markup Language
2.1.
Existing Identity Management Systems Authentication
2.2.
Configuring Identity Providers
2.3.
Change Identity Providers
2.4.
Supported Identity Management Systems
2.5.
SAML Configuration Settings
2.6.
Troubleshooting
3.
Sign In with LDAP
3.1.
Steps of Signing in
4.
Sign In with LDAP
4.1.
Connect
4.2.
User Search
4.3.
Filtering Users to Sign In
4.4.
Sign In Bind 
4.5.
Group Search
4.6.
Configuration Overview
5.
Frequently Asked Questions
5.1.
How do I add a user to the Chef server?
5.2.
How does the Chef client authenticate with the Chef server?
5.3.
How are nodes configured in Chef?
5.4.
How does Chef Server index the attributes sent by a chef-client?
6.
Conclusion
Last Updated: Mar 27, 2024

Chef User Authentication

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Chef Automate can combine with several services to authenticate users and use their existing members to decide on Chef Automate permissions. This blog will teach us about Chef Authentication Concepts. The Security Assertion Markup Language and the Lightweight Directory Access Protocol will be the primary topics covered here.

Chef User Authentication

Security Assertion Markup Language

Chef Automate can work with existing Security Assertion Markup Language, also known as SAML services, to certify users and determine their Chef Automate permissions based on their current group memberships.

Existing Identity Management Systems Authentication

Chef Automate supports both externally managed users from an IdP and local users. In the same instance, you can configure one LDAP service or MSAD for a more straightforward configuration of Active Directory configurations and one SAML IdP. You do not need to configure an external IdP if you solely use Chef Automate's local users and teams.

Configuring Identity Providers

We should make two actions to configure chef authentication for your Chef Automate installation:

  1. We would need to build a TOML file with your partial SAML settings.
  2. On the command line, use chef-automate config patch "/path/to/your-file.toml>" to apply your update.

Change Identity Providers

To modify your configured IdP, follow these steps:

  1. Step 1: "Run chef-automate config show config.toml".
  2. Step 2: "Edit config.toml" to replace the "dex.v1.sys.connectors" section with the config values for your new identity provider.
  3. Step 3: Run "chef-automate config set config.toml" to set your updated config.

We should note that users that sign in using SAML will have a session period of 24 hours before having to sign in again.

Single chef user authorization in multiple groups

Supported Identity Management Systems

Chef Automate supports SAML interactions using the Dex library. Dex for IdP-initiated SAML logins does not endorse these IdPs. As a result, Chef Automate will not be able to enable IdP-initiated SAML logins with specific IdPs. 

The "unsupported auth mode" error occurs when you attempt to sign in with an unsupported IdP-supported SAML login. Return to the standard SP-initiated login mode and continue configuring Chef Automate SAML.

Below we have lists of some supported systems:

  1. Tivoli Federated Identity Manager
  2. OneLogin
  3. Ping
  4. Office365
  5. OKTA
  6. Azure AD

SAML Configuration Settings

The SAML configuration options are as follows:

[dex.v1.sys.connectors.saml]
ca_contents = "<here we put our ca contents>" #must needed
sso_url = "<the SSO URL is put here>" #must needed
email_attr = "<email attribute is put here>" #must needed
username_attr = "<the username attribute is put here>" #must needed
groups_attr = "<the groups attribute is put here>" # choice
allowed_groups = ["group1", "group 2"] # choice
entity_issuer = "<the entity issuer is added here>" # choice
name_id_policy_format = "<put here based on accepted format>" # choice

We should ensure that "ca_contents" contain a copy of the certificate used to sign the SAML claims. The certificate should be a PEM-encoded string.

Setting "allowed_groups" enable SAML sign-in for members of the listed groups while discarding all user groups that are not on the list. We must add groups to the "allowed_groups" list for Chef Automate.

In the configuration example above, users belonging to "group1" or "group2" may sign in to Chef Automate, and those groups will appear as "team:saml:group1" and "team:saml:group2," respectively. Unlisted "group3" users would not have access to Chef Automate. Chef Automate supports utilising SAML to authenticate users and assign access to SAML groups.

Troubleshooting

Error: "Unsupported auth mode

When using an unsupported IdP-supported SAML login, the "unsupported auth mode" error occurs.

To address this issue, return to the standard SP-initiated login mode.

Chef Automate uses the Dex library to support SAML connections. Dex does not support IdP-initiated SAML logins with these IdPs. Chef Automate does not allow IdP-initiated SAML logins utilising the previously mentioned IdPs.

Sign In with LDAP

Now we will read about signing in with Lightweight Directory Access Protocol. The user must enter their sign-in information. Chef Automate begins a sequence of operations after the user enters a username and password at the sign-in screen.

Steps of Signing in

This series of steps complete the sign-in process are:

  1. Connect
  2. Bind
  3. User Search
  4. Sign in Bind
  5. Group Search

Sign In with LDAP

Chef Automate allows you to define permissions for LDAP users and groups.

Connect

Chef Automate must establish a secure TCP connection to your LDAP service. It will connect to the host specified in your TOML settings, such as:

host = "ldap.corp.com"
host = "ldap.corp.com:10636"

The TLS configuration determines whether the validity of the server's Transport Layer Security certificate is enforced. Chef Automate will not communicate with the LDAP service if an authorised certificate is not given. The CA certificate may indeed be used to validate the host's certificate.

User Search

Chef Automate will attempt to retrieve the directory name of the user trying to sign in after successfully binding.

To do so, it will search for an entry with "username_attr" equal to the username that attempted to sign in, using the configured base "base_user_search_dn."

It will obtain different properties with the identifiers "user_id_attr," "email_attr," and "user_display_name_attr" that have been configured.

Filtering Users to Sign In

You can narrow down the user search even further by passing a valid LDAP filter to "user_query_filter." As an example,

user_query_filter = "(objectClass=person)"

which will be linked one after the other using the sign-in screen's search filter based on the specified username The contents of "user_query_filter" are expanded to "(&user_query_filter_value>)" so that it can pass in multiple filters.

For example, assume you only wanted members of a specific Active Directory group to be able to sign in to Chef Automate. You could create a "user_query+filter" with various filters in that scenario.

Sign In Bind 

When the user directory entry search is finished, the LDAP connector will attempt to bind as the user entry using the given password.

For example, if the "bob:bobspassword" sign-in resulted in a successful user search, returning "cn=bob,ou=People,dc=corp,dc=com," the following things are to bind using that DN and the password "bobspassword."

Group Search

Finally, after the user has been validated, their internal record is supplemented with LDAP-provided groups. This is achieved by running another search using the identical bind DN and password used for the user search.

A basic DN must be provided, similar to a user search, and we can filter the by providing an extra filter :

base_group_search_dn = "ou=Groups,dc=corp,dc=com"
group_query_filter = "(objectClass=group)"

Knowing that your directory server's structure determines the correct setup options is vital.

The "base_group_search_dn" option is not required. Users authenticating via Microsoft Active Directory (MSAD) Lightweight Directory Access Protocol (LDAP) server will not be members of any teams if it is not given.

Configuration Overview

We may find the complete setup and more information on all Lightweight Directory Access Protocol (LDAP) configuration options.

[dex.v1.sys.connectors.ldap]  
#Setup for querying your LDAP server

ca_contents = "<your ca contents>"
 host = "<your host>"

#The DN and password you want to bind to your LDAP server for
#Chef Automate to look for users. Also, look for their organisation #membership.
bind_password = "<your bind_password>"

#When performing 'chef-automate' instructions, bind password can
#alternatively be provided via the AUTOMATE_SECRET_LDAP_PASSWORD #environment variable.
base_user_search_dn = "<this is our base user search DN>"

#User Query looks for LDAP users to authenticate for Chef Automate.
#The starting point for the user query. Chef Automate will use this as the
#basic DN when looking for people to authenticate with on your LDAP #server.
username_attr = "<this is our username attribute>"

#Optional Step LDAP query filter to use when looking for users to log in.
#This will be paired with the username attr filter mentioned earlier.
user_query_filter = "<this is the user query filter>"

#Using LDAP to populate the Chef Automate User Which LDAP
#information is used to populate the username in a user's Chef Automate session.
#This is when chef user authentication is successful.
user_id_attr = "<this is the userid attribute>"

#Optional:defines which LDAP field,upon chef user authentication,
#populates the email in a user's Chef Automate session.
email_attr = "<here goes the email attribute>"

#Optional: specifies which LDAP data should be used to populate the
#display name in a user's Chef Automate session after successful #chef user authentication.
#If not supplied, "name" is used as the default.
user_display_name_attr = "<the user display name attribute>"

#Group Query looks for an authenticated user's LDAP group membership.
#The starting point for the group membership inquiry.
#Chef Automate will use this as the basic DN to search for LDAP group
#membership for a given LDAP user.
base_group_search_dn = "<the base group search DN>"

#The following two fields assign a user to a group. If the settings are applied,
#you will get a group membership.
#Optional: The LDAP field is used to filter group membership. The default
#value is "member."
filter_groups_by_user_attr = "<this is the groups to filter by user attribute>"

#The LDAP field from the authenticated user that you want to utilise as
#input to the above filter. The default value is "DN."
filter_groups_by_user_value = "<here goes groups to filter by user value>"

#You can define an additional LDAP filter to filter group membership
#results.
group_query_filter = "<here goes group query filter>"

#The LDAP information on the group you want to utilise as the Chef
#Automate Team name. The default value is "name."
group_display_name_attr = "<here is the group display name attribute>"

Frequently Asked Questions

How do I add a user to the Chef server?

To make a user, use the create argument. This procedure will generate an RSA key pair for the specified user. The public key will be saved on the Chef server, while the private key will be shown on STDOUT or written to a specified file. The private key should get copied to the system for the user as "/etc/chef/client."

How does the Chef client authenticate with the Chef server?

Every request sent to the Chef server by the chef-client must get authenticated using the Chef server API and a private key. When the chef-client sends a request to the Chef server, it affirms the request with a private key stored in "/etc/chef/client. pem."

How are nodes configured in Chef?

The node object is made up of the run-list and node properties, which are kept in a JSON file on the Chef server. During each chef-client run, the chef-client obtains a copy of the node object from the Chef server and stores an updated copy on the Chef server at the end of each chef-client run.

How does Chef Server index the attributes sent by a chef-client?

Following the rebuild of the node object, all of its attributes get compared. Then the node is updated based on attribute priority. The node object that defines the node's current state is posted to the Chef server at the end of each chef-client run so it may be indexed for search.

Conclusion

In the article, we learned about the Chef user Authentication Concept. We read about SAML and LDAP. We also saw their identity management systems and also read about their configuration settings. We found ways to troubleshoot problems that may pop up. Visit our blogs on Chef to find out more. Go inside to find out how to configure the Chef infra server and manage the Chef infra server. If you want to dive deeper, find out about Chef Habitat Installation and Common Terms related to Chef InSpec. Explore Coding Ninjas Studio to find more exciting stuff. Happy Coding!

Thank you
Live masterclass