Matrix

This plugin integrates AdminJS with Matrix, enabling users to log in to the AdminJS panel using Matrix accounts through the MatrixAuthProvider.

To ensure that only authorized personnel can manage administrative functions, users must have administrative privileges in Matrix to authenticate and access AdminJS Matrix features.

➡️ Authentication - Matrix User Authentication


Features

  • Seamless integration between AdminJS and Matrix.

  • Authentication via Matrix user accounts.

  • Resource management for Matrix users, rooms, and devices.

Installation

Install the package using npm:

Environment Variables

Configure the following environment variables, preferably in a .env file:

Setup

1. Import reflect-metadata

Import at the very beginning of your application’s entry file (e.g., app.ts):

2. Create Matrix Resources

Create resource files in src/resources/matrix/.

Example of general resource configuration:

matrix-device.resource.ts

matrix-room.resource.ts

matrix-user.resource.ts

3. Register Resources in AdminJS

Example src/admin/options.ts:

4. Register Components

In src/admin/component-loader.ts:

Authentication Methods

There are three ways to handle authentication with this plugin:

Method 1: Token-based Authentication

Add the Matrix token to your authentication provider (src/admin/auth-provider.ts):

Obtain your Matrix token by logging into Matrix. Execute this command on a machine that has access to the Matrix server:

Ensure the Matrix user is already registered and has administrative privileges. This command should be executed directly on the Matrix server as it's a built-in Matrix-Synapse tool:

Note: The path to the homeserver.yaml file may vary depending on your Matrix installation. Common locations include:

/etc/matrix-synapse/homeserver.yaml /data/homeserver.yaml (if using Docker) Note: This method uses a single shared token for all AdminJS users, which remains valid indefinitely unless manually revoked.

Method 2: Matrix User Authentication

Authentication - Matrix User Authentication

  • Using this authentication method, ensure that the user's account has administrative privileges in Matrix.

Method 3: Custom Authentication Provider

You can also create a custom provider and manually handle tokens. Here's an example implementation of a custom authentication provider based on email and password:

Contributing

Contributions to the @adminjs/matrix plugin are welcome. Please submit pull requests or open issues on GitHub for bug fixes, improvements, or new features.

License

This plugin is licensed under the MIT License.

Last updated