> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/maiagent-user-guide/en/org/sso/sso-eip.md). Agents can also search and read this documentation through its [MCP server](https://docs.maiagent.ai/~gitbook/mcp).

# EIP Integration

Connect your existing enterprise authentication system through EIP integration, with flexible parameter passing and automatic role synchronization

EIP (Enterprise Information Portal) provides a flexible enterprise integration solution that connects to your existing authentication system through an API.

**Target audience**: Enterprises with a self-built authentication system, or organizations that need custom integration logic

**Key advantages**:

* A simpler integration process
* Flexible parameter passing, not limited to fixed parameter names
* Integration can be adapted to your enterprise needs
* Supports automatic role synchronization

## Setup Steps <a href="#setup-steps" id="setup-steps"></a>

### 1. Fill in EIP Settings in the MaiAgent Backend <a href="#step-1-fill-eip-settings" id="step-1-fill-eip-settings"></a>

After selecting the <mark style="color:blue;">EIP</mark> authentication type, fill in the following fields:

| Field                                                       | Required | Description                                                                                  |
| ----------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------- |
| <mark style="color:blue;">Authentication Source Name</mark> | Yes      | The English identifier of the authentication source, e.g., `company-eip`                     |
| <mark style="color:blue;">Server URL</mark>                 | Yes      | The authentication API endpoint of the EIP server, e.g., `https://eip.internal.com/api/auth` |

After completing the fields, the system will automatically generate the **Login URL** in the following format:

```
https://{frontend-domain}/auth/eip?serverUrl={EIP server URL}
```

### 2. Configure the EIP Server <a href="#step-2-configure-eip-server" id="step-2-configure-eip-server"></a>

Make sure your EIP server is able to:

1. Receive the payload parameters sent by MaiAgent (both GET and POST methods are supported)
2. Verify the user's identity based on the payload content
3. Return user information in the following format:

```json
{
  "email": "user@company.com",
  "name": "王小明",
  "groupIds": ["group-a", "group-b"]
}
```

| Response field | Required | Description                                                                                                                                             |
| -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `email`        | Yes      | The user's email address, used as the unique identifier                                                                                                 |
| `name`         | Yes      | The user's display name. Login fails if it is not returned; the display name is updated with this value on every login                                  |
| `groupIds`     | No       | A list of role IDs (UUIDs) the user belongs to, used to automatically synchronize MaiAgent roles. See [Automatic Role Synchronization](#role-auto-sync) |

### 3. Test the Login Flow <a href="#step-3-test-login-flow" id="step-3-test-login-flow"></a>

Test using the Login URL plus the parameters generated by your EIP system:

```
# Example 1: With SessionId (legacy compatibility)
https://{frontend-domain}/auth/eip?serverUrl=https://eip.company.com&sessionId=abc123

# Example 2: Without SessionId (supported in the new version)
https://{frontend-domain}/auth/eip?serverUrl=https://eip.company.com&userId=12345&token=xyz789

# Example 3: Custom parameters
https://{frontend-domain}/auth/eip?serverUrl=https://eip.company.com&customParam1=value1&customParam2=value2
```

{% hint style="info" %}
`sessionId` is an optional parameter in the latest version. The system automatically collects all query parameters in the URL except `serverUrl` as the payload and sends them to the EIP server for verification.
{% endhint %}

### 4. Save Settings <a href="#step-4-save-settings" id="step-4-save-settings"></a>

After confirming the test passes, click <mark style="color:blue;">Save</mark> in the MaiAgent backend to complete the setup.

## EIP Parameter Handling Logic <a href="#eip-parameter-handling" id="eip-parameter-handling"></a>

When MaiAgent receives an EIP login request, it handles it as follows:

1. Separate the `serverUrl` parameter
2. Collect all other query parameters into a `payload` object
3. Append the fixed parameters (`op=maiagent`, `type=json`) to the `payload` and send it to the EIP server
4. The EIP server supports both GET and POST for receiving requests; you can specify which one in the payload through the `method` field

## Login Failure Messages <a href="#error-messages" id="error-messages"></a>

After a user is redirected from EIP to MaiAgent, the screen first shows "EIP login in progress..."; if it fails, the reason is shown below in red text:

| On-screen message                                            | Common cause                                                                | Resolution                                                                                                                                    |
| ------------------------------------------------------------ | --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| 缺少必要的參數 (serverUrl) (Missing required parameter (serverUrl)) | The redirect URL is missing the `serverUrl` parameter                       | Check the redirect URL generated on the EIP side; `serverUrl` must point to your EIP authentication endpoint                                  |
| API 登入失敗 (API login failed)                                  | MaiAgent did not obtain valid user data after verifying with the EIP server | Confirm that the EIP side returns fields such as `email` and `name` as described in [Configure the EIP Server](#step-2-configure-eip-server)  |
| API 登入過程發生錯誤 (An error occurred during API login)            | MaiAgent cannot reach `serverUrl`, or EIP returned an error                 | Confirm that the MaiAgent server can reach the EIP authentication endpoint (firewall, certificate), then check the error logs on the EIP side |

## EIP Redirect Paths <a href="#eip-redirect-path" id="eip-redirect-path"></a>

EIP login supports two paths. They behave identically and use query parameters in the same way:

| Path                 | Description                                                                    |
| -------------------- | ------------------------------------------------------------------------------ |
| `/auth/eip`          | Standard path                                                                  |
| `/auth/eip/redirect` | Compatibility path, for EIP setups whose redirect URL must end with `redirect` |

## Automatic Role Synchronization <a href="#role-auto-sync" id="role-auto-sync"></a>

EIP integration supports automatic role synchronization, which is one of the most powerful features of EIP:

1. The enterprise includes a `groupIds` role list in the user information returned by EIP
2. After receiving it, MaiAgent automatically assigns the user to the corresponding roles
3. Only **roles assigned by EIP** are replaced: roles previously assigned to this user by EIP but not in the current list are removed first, then the roles in the list are added. Roles manually assigned by administrators in the backend and roles assigned by LDAP or SCIM are preserved
4. Synchronization happens on every login, ensuring that EIP-managed roles stay consistent with the enterprise side

| `groupIds` returned by EIP     | Result                                     |
| ------------------------------ | ------------------------------------------ |
| A list of role IDs             | The roles assigned by EIP become this list |
| An empty array `[]`            | All roles assigned by EIP are removed      |
| The field is missing or `null` | Roles are left unchanged                   |

{% hint style="warning" %}
`groupIds` represents "the complete list of roles EIP wants to assign": any role not in the list that was previously assigned by EIP will be removed at the next login. Make sure the role list returned by the EIP side is complete.
{% endhint %}

{% hint style="info" %}
If `groupIds` contains a role ID that has not been created in MaiAgent, the system returns a validation error. We recommend creating the corresponding roles in MaiAgent in advance.
{% endhint %}

## EIP Security Notes <a href="#eip-security-notes" id="eip-security-notes"></a>

* Always verify all parameters on the EIP server side; do not rely on client-side verification alone
* Make sure verification tokens have an expiration time to prevent replay attacks
* Always use HTTPS connections to protect sensitive information in transit
* The EIP server should validate all received parameters to prevent injection attacks

## Settings Quick Reference <a href="#settings-quick-reference" id="settings-quick-reference"></a>

| Field                      | Required | Format                                                    | Example                            |
| -------------------------- | -------- | --------------------------------------------------------- | ---------------------------------- |
| Authentication Source Name | Yes      | Lowercase letters and digits + hyphens, max 31 characters | `company-eip`                      |
| Server URL                 | Yes      | HTTPS URL                                                 | `https://eip.company.com/api/auth` |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.maiagent.ai/maiagent-user-guide/en/org/sso/sso-eip.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
