This documentation is for WSO2 API Manager 2.1.0. View documentation for the latest release.

All docs This doc
Skip to end of metadata
Go to start of metadata

Kerberos is a security protocol that has support built into various operating systems and open-source distributions (e.g.,  Ubuntu, Windows, RedHat, Open Solaris, etc). In addition, a majority of browsers support some Kerberos functions as well. As WSO2 API Manager uses the OAuth 2.0 protocol, the Kerberos OAuth2 grant type allows organizations to exchange a Kerberos ticket for an OAuth 2.0 token. Thereby, allowing organizations to re-use their existing Kerberos infrastructure, while easier adopting OAuth 2.0 within these organizations. 

Kerberos OAuth2 grant flow

The following section describes the flow involved in exchanging a Kerberos ticket for an OAuth2 token.

Kerberos-OAuth2 Grant Flow when using WSO2 API-M

  1. The Kerberos client requests the Kerberos Service Ticket from the Kerberos Key Distribution Center (KDC) to invoke the service.
    The Kerberos Key Distribution Center can be any Kerberos Server.
  2. The Kerberos Key Distribution Center sends a response with the Kerberos Service Ticket.
    If the client and the requested service is valid, the Key Distribution Center (KDC) sends a Kerberos ticket encrypted with the service owners private key. The API handles the exchanging of the Ticket Granting Ticket (TGT), Service Granting Ticket (SGT), and all other low level Kerberos details.
  3. The Kerberos client requests the OAuth2 token.
    The message format of the OAuth2 token request should be as follows:

    You can use one of the following two cURL commands to request for the OAuth2 token.

    curl -v -X POST -H "Authorization: Basic <base64-encoded-client-id>:<client-secret-value>" -k -d "grant_type=kerberos&kerberos_realm=<kerberos-realm>&kerberos_token=<kerberos-token>&scope=<scope>" -H "Content-Type:application/x-www-form-urlencoded" https://localhost:8243/token
    curl -u <client-id>:<client-secret> -k -d "grant_type=kerberos&kerberos_realm=<kerberos-realm>&kerberos_token=<kerberos-token>&scope=<scope>" -H "Content-Type:application/x-www-form-urlencoded" https://localhost:8243/token

    The  “scope=my_scope” is an optional parameter that you can add to the string in the token request body.

    POST /token HTTP/1.1
    Content-Type: application/x-www-form-urlencoded
    Authorization: Basic
  4. The Kerberos client receives the OAuth2 token.
    The Kerberos Grant validates the received token with the provided Identity Provider (IDP) credentials and if it is a valid token, it issues an OAuth2 token to the client.


Configuring Kerberos Grant with API Manager

Follow the instructions below to configure Kerberos Grant with WSO2 API Manager:

  1. Download the Keberos-grant JAR (kerberos-grant-1.0.0.jar).

  2. Copy the JAR into the <API-M_HOME>/repository/components/lib directory.

  3. Add following entry under <SupportedGrantTypes> in the <API-M_HOME>/repository/conf/identity/identity.xml file.

  4. Create a file named jaas.conf in the <API-M_HOME>/repository/conf/identity directory with the following content.

    Server { required
    }; Client { required
  5. Copy the following JARs into the <API-M_HOME>/repository/components/dropins directory.
  6. Configure OAuth2 for your client application with the Kerberos grant type.

    1. Start the WSO2 API-M server by navigating to the <API-M_HOME>/bin directory in your console and running one of the following scripts based on your OS.

      • On Windows: wso2server.bat --run

      • On Linux/Mac OS: sh

    2. Sign into the API Store.

    3. Click Applications and click on the name of the application that you want to configure the OAuth2 with the Kerberos grant type.

    4. Generate the Production Keys.

      1. Click Production Keys.

      2. Click on the Kerberos checkbox as shown in the screenshot. 

      3. Click Generate Keys to generate the keys.
    5. Generate the Sandbox Keys.

      1. Click Sandbox Keys.

      2. Click on the Kerberos checkbox.

      3. Click Generate Keys to generate the keys.

  7. Configure the Service Principal Name (SPNName) and Service Principal Password (SPNPassword)

    service principal name (SPN) is a unique identifier of a service instance. SPNs are used by Kerberos authentication to associate a service instance with a servicelogon account. This allows a client application to request that the serviceauthenticate an account even if the client does not have the account name.

    1. Sign in to the WSO2 API-M Management Console.

    2. Navigate to the Main menu, click Add under the Identity Provider menu.

    3. Add a new Identity Provider (IDP).

      The IDP name should be the name of the realm. Based on this example, it should be An identity provider is needed here to manage the KDC Service. It provides access to an identity stored in a Kerberos authentication server.

      • Identity Provider Name:

      • Aliashttps://
      • Server Principal Name: HTTP/[email protected]

      Adding an IDP in WSO2 API Manager

  8. Invoke the token endpoint using the message format discussed in step 3.

    Note that for users to be counted in the Registered Users for Application statistics which takes the number of users shared each of the Application, they should have to generate access tokens using Password Grant type.

  • No labels