Apidog

All-in-one Collaborative API Development Platform

API Design

API Documentation

API Debugging

API Mocking

API Automated Testing

How to Configure Kerberos Authentication in Apidog for API Testing

Scarlett Clarke

Scarlett Clarke

Updated on November 13, 2024

Having trouble with Kerberos configurations? Having Kerberos preauthentication failures that keep you up at night? Only to face another authentication error just when you thought everything was working?

You’re not alone. Even the most seasoned system administrators know the unique frustrations that come with setting up Kerberos authentication. It plays a crucial role in enterprise security, acting as the backbone of authentication protocols for organizations of all sizes. But that doesn’t make it any less tricky to get right.

While testing APIs that use Kerberos authentication, development teams often face technical challenges. Currently, Postman doesn't include built-in support for Kerberos-authenticated endpoints, while Apidog offers native support for both Kerberos and NTLM authentication protocols, allow you to get started with testing Kerberos-Authenticated APIs on Windows, Mac, Linux straightforwardly:

button

Before we get started, let's quickly review the concepts of Kerberos Authentication Protocol.

What is Kerberos Authentication Protocol?

Kerberos is a network security authentication protocol developed by MIT. It has become a built-in authentication technology in Microsoft Windows and is used by many organizations for Single Sign-On (SSO), securely transmitting user identity data to applications.

How Does Kerberos Authentication Work?

Kerberos authentication is a complex process with several components we must understand:

  • KDC: Key Distribution Center, including AS and TGS components. In Windows environments, this role is typically assumed by the domain controller.
  • AS: Authentication Server, responsible for initial authentication, verifying user identity, and issuing TGT.
  • TGT: Ticket Granting Ticket, issued by AS to users who have passed initial authentication, used to request specific service tickets from TGS without re-entering passwords.
  • TGS: Ticket Granting Service, a component of KDC, responsible for verifying TGTs and issuing service tickets for specific services.

To better understand the relationship between these components, we can simplify the Kerberos authentication process into the following steps:

  1. When a user logs in, the client sends an authentication request to the AS.
  2. After verifying the user's identity, AS issues a TGT.
  3. When the user needs to access the specific service, they use the TGT to request a service ticket from the TGS.
  4. TGS verifies the TGT and issues a service ticket for the specific service the user is trying to access.
  5. The user uses this service ticket to access the required service.

In this process, KDC acts as a whole, containing AS and TGS as its two main functional components. TGT and service tickets are key credentials used to prove identity and authorize access during this process.

This design allows users to perform initial authentication only once (obtaining a TGT) and request different service tickets multiple times within the TGT's validity period, achieving Single Sign-On (SSO) functionality while maintaining high security.

How Does Kerberos Authentication Work?

Benefits of Kerberos Authentication

Using Kerberos as an authentication service offers numerous advantages, particularly in terms of security:

  • Centralized authentication service: All authentication is managed by a central server (KDC), simplifying user management and security policy enforcement, and facilitating auditing and monitoring of authentication attempts.
  • Mutual authentication: Kerberos provides mutual verification, where both client and server verify each other's identity.
  • Single Sign-On (SSO): Users only need to authenticate once to access multiple services, avoiding password transmission and enhancing security.
  • Limited ticket validity: Actual passwords are never sent over the network; instead, encrypted tickets are used. Tickets are time-stamped and have a limited lifetime controlled by administrators. Automatic ticket renewal without user intervention enhances security without compromising convenience.
  • Reduced server load: Users only need to authenticate once to access multiple services, and servers don't need to handle password verification for each request, improving overall system performance.

These advantages make Kerberos the preferred choice for enterprise-level authentication, especially in Windows environments and large-scale networks where security, efficiency, and user experience are crucial.

Testing Kerberos-Authenticated APIs with Apidog on macOS

Let's walk through the practical steps of using Apidog to test a Kerberos-authenticated API endpoint on macOS.

Step 1: Preparation

Companies that employ Kerberos authentication typically set up accounts for each employee in their AD. These organizations provide their staff with essential Kerberos-related information, which usually includes:

  1. Account:Typically based on the employee's name, often formatted as firstname.lastname or another company-specified format. For instance, my account is Scarlett@APIDOG.LOCAL.
  2. Password: A personal password for login purposes. It's usually required to be changed upon first login for security reasons.
  3. Kerberos Realm: Generally the uppercase version of the company's domain name. For example: APIDOG.LOCAL.
  4. KDC Server Address: This is the address of the Kerberos Key Distribution Center. It's typically either the Fully Qualified Domain Name (FQDN) or IP address of the domain controller. Examples include ills7i8hyt2.apidog.local or 192.168.1.100.

This information enables employees to authenticate using the Kerberos protocol, granting them secure access to various company network resources and services. Additionally, it's crucial to ensure that you have downloaded and registered the latest version of Apidog before proceeding.

It's important to note that the web version of Apidog doesn't support this feature due to browser limitations. Therefore, make sure you've downloaded the latest version of the Apidog desktop client.

Modify your local DNS for Kerberos authenticationEndpoints using Kerberos authentication are typically accessed within an internal network. Therefore, we need to configure our DNS server to point to the AD server address. This configuration facilitates subsequent access to these endpoints.

Step 2: Configure /etc/krb5.conf File

The krb5.conf file is the primary configuration file for Kerberos, usually located at /etc/krb5.conf. Here you can configure the KDC server address, AS, and mapping of Kerberos realm hostnames.

Check if this file exists on your machine by entering the following command in the terminal:

cat /etc/krb5.conf

If it shows "No such file or directory," you need to create this file.

If you have nano installed, you can create and edit the file directly in nano. Of course, feel free to use any text editor you're comfortable with.

nano /etc/krb5.conf

Then, save the following configuration content in the file:

[libdefaults]
    default_realm = APIDOG.LOCAL  # Your Kerberos realm name, typically the uppercase form of your organization's domain name

[realms]
    EXAMPLE.COM = {
        kdc = ills7i8hyt2.apidog.local # KDC server address, assumed here to be the FQDN of the domain controller
        admin_server = ills7i8hyt2.apidog.local # Usually the same as the KDC
    }

[domain_realm]
    .apidog.local = APIDOG.LOCAL  # Mapping between domain name and Kerberos realm name, left side is lowercase
    apidog.local = APIDOG.LOCAL

After saving, you've successfully configured the /etc/krb5.conf file on your machine and can proceed to the next step.

Step 3: Log in to AD Account

macOS comes with both CLI and GUI tools for Kerberos. The GUI tool is called Ticket Viewer. We can use either of these tools to log in.

Open Ticket Viewer by typing "Ticket Viewer" in Spotlight search. Choose "Add Identity," enter the company-provided account and password, and you've successfully logged into AD. Note that login accounts have a time limit; you'll need to click the refresh button to "renew" the identity after it expires.

Log in to AD Account

Alternatively, you can log in directly using CLI:

# Obtain a Ticket for an AD account
kinit <username@domain>
# Check local Tickets
klist

After successful login, you can test the endpoint in Apidog.

Step 4: Configure Auth in Apidog

Open Apidog and create "New Request."

Open Apidog and create "New Request."

Enter the API endpoint URL you want to test, then click "Auth" below and select "Kerberos" as the type.

Configure Auth in Apidog

You'll see that configuring Kerberos authentication only requires filling in an SPN (Service Principal Name). The SPN mainly consists of the KDC server address and Kerberos realm name. In the input box, enter HTTP + / + KDC server address + @ + Kerberos realm name.

configuring Kerberos authentication

After filling this in, click send. You should see a successful response, and you can continue with your testing.

Testing Kerberos-Authenticated APIs with Apidog on macOS

In the event of encountering 401 error, it is advisable to verify the following points:

  • DNS Configuration: Ensure that the DNS settings are correctly configured.
  • Kerberos Setup: Verify the accuracy of the Kerberos configuration.
  • Credential Validity: Confirm that the account credentials (username and password) are valid and active.
  • API Access Permissions: Check whether you have the necessary permissions to access the specific API in question.
  • Ticket Expiration: Examine if the Kerberos ticket has expired. If so, you may need to renew it.
the event of encountering 401 error

Systematically reviewing these elements can help identify and resolve the root cause of the authentication failure, facilitating successful API access.

Configuring Kerberos Authentication in Apidog for Windows Environments

Domain-Joined Windows Systems

For Windows systems already connected to a domain, Apidog seamlessly integrates with existing Kerberos authentication configurations. No additional setup is required to begin testing Kerberos-authenticated APIs.

Domain Configuration Process

For systems that require domain joining, follow these configuration steps:

Prerequisites

  • Administrative privileges
  • Valid domain credentials
  • Network access to domain controllers

Configuration Steps

  1. Configure DNS settings to point to domain DNS servers
  2. Access Windows domain settings through System Settings > Access Work or School
  3. Complete domain joining process using authorized credentials

Using Apidog to Test NTLM-Authenticated APIs

Windows Server environments often use both Kerberos and NTLM authentication methods. While Kerberos, introduced with Windows 2000, is the preferred choice due to its stronger security, NTLM remains relevant for its speed in small networks and compatibility with older systems.

Many companies use both protocols, with NTLM serving as a backup when Kerberos fails, ensuring optimal flexibility.

Apidog supports both authentication methods, with NTLM configuration being particularly simple - requiring just one step and working identically across Windows and macOS systems.

Step 1: Preparation & Modify Local DNS

NTLM authentication doesn't require as much information; we only need the company-provided account and password. And, don't forget to ensure you've downloaded and registered the latest version of Apidog.

As with Kerberos authentication, since the endpoints are typically accessed internally, we need to configure the DNS server to the AD server address.

Step 2: Configure Auth in Apidog

Surprisingly, NTLM authentication doesn't require any additional configuration. We can directly configure and complete the test in Apidog.

In the "Auth" section, select "NTLM Authentication" as the type. You'll see two text boxes to fill in: username and password. Simply enter your account credentials.

Using Apidog to Test NTLM-Authenticated APIs

Click on the "Send" button to complete the process.

Conclusion

Modern enterprise API development demands robust authentication mechanisms, with Kerberos and NTLM serving as cornerstone protocols in Windows environments. Kerberos authentication provides superior security through its ticket-based system, offering enhanced protection against replay attacks and man-in-the-middle vulnerabilities. When combined with NTLM's legacy support and simplified authentication process, organizations gain comprehensive coverage for their authentication needs across diverse system architectures.

Enterprise developers and QA teams working with Windows Server environments benefit from implementing both authentication protocols in their testing strategy. Kerberos excels in large-scale deployments where security is paramount, while NTLM ensures backward compatibility and serves as a reliable fallback mechanism. This dual-protocol approach maximizes authentication flexibility while maintaining security standards across the enterprise infrastructure.

For teams seeking to streamline their API testing workflow with these enterprise authentication protocols, Apidog provides native support for both Kerberos and NTLM authentication, enabling seamless integration with existing Windows domain infrastructures.

button
How To Use Pynt For API Security TestingTutorials

How To Use Pynt For API Security Testing

Pynt’s ability to blend ease of use with advanced security testing makes it a preferred tool for both small development teams and large enterprises. In this guide, we'll learn about how to use Pynt to make our APIs safe.

@apidog

November 6, 2024

How to Log API Endpoints Using Python FastAPITutorials

How to Log API Endpoints Using Python FastAPI

FastAPI is a modern, high-performance web framework for building APIs with Python 3.7+ based on standard Python type hints. It offers several advantages: * High Performance: FastAPI is designed for speed, leveraging asynchronous programming to handle thousands of requests per second. * Automatic Documentation: It automatically generates interactive API documentation using Swagger UI and ReDoc. * Type Checking: FastAPI uses Python’s type hints to provide automatic data validation and serializ

@apidog

November 4, 2024

A Brief Guide to APISIX Plugin Orchestration & Gateway ConfigurationTutorials

A Brief Guide to APISIX Plugin Orchestration & Gateway Configuration

Apache APISIX is a robust, cloud-native API gateway designed to streamline the management of APIs and microservices. We'll take a look at APISIX's Plugin Orchestration & Gateway Configuration in this article.

@apidog

November 1, 2024