Setting Up the LEXolution REST API in IAM

This description applies from LEXolution version 9.7 onward.

The LEXolution REST API is an interface that allows third-party service provider applications to read data from or write data to LEXolution. Before a service provider can connect, you need to set up access for them in the STP Cloud's Identity Admin (IAM). This access is called a Client (shown as "Application" in the interface).

For information on how the service provider logs in afterward, see Logging in to LEXolution via REST API. The available API functions are described in REST API Reference.

REST API IAM 01
REST API IAM 01

How the Networks Interact

  • "Service Provider Network" can also be the "Customer Network" if the service provider's application runs on-premise at your site.
  • "Service Provider Network" can also be the cloud.
  • If the service provider's software does not run on the same network as the LEXolution server (on-premise at your site), you must open the port for the LEXolution REST API. Only then can the service provider access it from outside.

OAuth2 Login Options

The service provider can connect to the LEXolution REST API in two ways.

Logging in as a Public Client

  • Login is interactive. The user enters their username and password and must give consent if required.
  • After the initial login, they can receive a Refresh Token, which keeps them logged in even when offline.
  • The user must exist in LEXolution. Depending on the RestApiUserIdIsEmail setting:
    • The login name matches the user's email address in LEXolution (Users.Email), or
    • the user ID in the token matches the user's XId in LEXolution (Users.XId). In this case, the local user management should be linked to the cloud user management.
  • A technical user can also impersonate a LEXolution user, meaning they act on that user's behalf.

Logging in as a Confidential Client

  • Login is not interactive. The service provider authenticates using a client secret that you define in advance in IAM. You need to share this secret with the service provider.
  • This is suited for automated processes that require no user input — for example, a scheduled data export to or from LEXolution.
  • In LEXolution, the Confidential Client is logged in as the technical system user StpAdmin.
  • It can also impersonate users if you assign it the kms.impersonation scope.

Client Configuration

In the future, you will be able to create clients (Public or Confidential) yourself. For now, this is still handled by STP (the IAM team).

  1. Log in to your STP Cloud tenant in a browser — for example, the STPPDE tenant.

    REST API IAM 02
    REST API IAM 02

    The URL shown in the image is stp-cloud-dev.de, which is the development environment. In production, the URL for Germany is stp-cloud.de — for example, Tenant1.stp-cloud.de.

  2. With administrator rights, you will see the Identity Admin. Click on it and select Applications (Clients) on the left.

    REST API IAM 03
    REST API IAM 03
  3. Click New Application.

  4. Choose a Display Name and set the status to Enabled.

    REST API IAM 04
    REST API IAM 04

Setting Up a Confidential Client

For a Confidential Client (login without user interaction), leave the remaining settings at their default values until you reach Allowed Grant Types.

  1. Under Allowed Grant Types, select Client Credentials.

  2. Under Allowed Scopes, choose:

    • API / KMS REST / REST API Read all if the service provider should have read-only access.
    • API / KMS REST / REST API Read/write all if the service provider should be able to read and write.
    • API / KMS REST / REST API Impersonate users if the service provider should be able to read or write as any LEXolution user. Without this scope, the service provider always reads and writes as the technical system user StpAdmin.
    REST API IAM 05
    REST API IAM 05
  3. Set a pre-shared secret (client secret). This is the password the service provider will use to gain access. Make sure to share it with them.

    REST API IAM 06
    REST API IAM 06
  4. Leave Requires Client Secret enabled.

    REST API IAM 07
    REST API IAM 07
  5. Click Save.

Important: The service provider needs the Value (unhashed) to log in, not the Value. The Value (unhashed) is only available immediately after the secret is created. The system only stores a cryptographic hash in the Value field. Neither the system nor STP has access to the Value (unhashed), and it cannot be recovered from the Value. Make sure to note it down right away.

Note: Currently, scopes are still assigned by the IAM team. This only works in the root tenant.

Setting Up a Public Client

For a Public Client (login with user interaction), you can configure additional settings after enabling the client.

REST API IAM 08
REST API IAM 08
Setting Effect and recommendation
Requires user consent The user must explicitly consent to the login.
Requires Proof Key for Code Exchange (PKCE) Enable this setting for enhanced security.
Allow access tokens via browser Allows access tokens to be passed through the browser.
Include user properties in ID token Allows the service provider to display information about the logged-in user, such as their email address.
User XId property If the STP Cloud user management is linked to local user management, the XId identifies the user. Otherwise, the email address is used.
Restrict access to internal host only Limits access to the internal host.
Allow offline access Enables Refresh Tokens. The user only needs to log in once. When the session expires after one hour, the system renews it automatically. An optional consent may be required at each login. If your service provider uses, for example, the Microsoft Authentication Library (MSAL), this setting must be enabled.

Continue as follows:

  1. Under Allowed Grant Types, select Authorization Code.

  2. Under Allowed Scopes, always select the first three scopes shown (ID / User profile, ID / Your user email address, ID / Your user identifier). From the remaining three, choose as you would for a Confidential Client:

    • API / KMS REST / REST API Read all for read-only access,
    • API / KMS REST / REST API Read/write all for read and write access,
    • API / KMS REST / REST API Impersonate users to allow the service provider to read or write as any LEXolution user.
    REST API IAM 09
    REST API IAM 09
  3. Enter at least one Redirect URI. This is the address of the service provider's application. After a successful login, the STP Cloud redirects the user there and passes an authorization code or token. This grants the application access to the LEXolution REST API. When using Postman or the .NET sample application from STP, the value doesn't matter, but it must be present. Example:

    REST API IAM 10
    REST API IAM 10
  4. Disable Requires Client Secret. A Public Client does not need a secret, because each user logs in with their own password.

  5. Leave all other settings at their defaults and save.

Important: If the service provider should have read-only access for some users and read/write access for others, assign both scopes to the client. You can then define who can read and who can write at the user or user group level.

Note: Currently, scopes are still assigned by the IAM team.

For the Public Client to be usable, users and user groups must also be set up in User Management (see the next section).

License, Users, and User Groups

For users to be able to use the Public Client to access the LEXolution REST API, your tenant must first have the appropriate license.

  1. Open Tenant Admin with administrator rights.

    REST API IAM 11
    REST API IAM 11
  2. Check the license list to confirm that the KMS REST API license is present. STP assigns this license to you.

    REST API IAM 12
    REST API IAM 12
  3. Open User Management. Assign the appropriate LEXolution REST API roles to your user groups there.

    REST API IAM 13
    REST API IAM 13

    The roles correspond to the scopes:

    REST API IAM 14
    REST API IAM 14
    • KMS REST API read all: Users in the group have read-only access.
    • KMS REST API read/write all: Users in the group can read and write.
    • KMS REST API impersonate users: Users in the group can read or write as any LEXolution user. This is useful for groups containing technical users. It's best to create a dedicated group called "Technical Users" for this purpose.

Intersection Logic

The service provider only receives the scopes that have been granted at every level involved. What counts is the intersection of the client, user, and license. If Requires user consent is checked, the user's consent also factors in.

Example: Service Provider 1 should have read-only access, and Service Provider 2 should have read and write access (each using Public Clients). Assign the following:

Level Scope
Client – Service Provider 1 Read all
Client – Service Provider 2 Read/write all
Users who use both service providers Read all and Read/write all

It is not enough to grant users only Read/write all.

------------------------------------------------------------------------------------------------------------------
This article has been automatically translated by an AI and may therefore contain errors.

Related to