restheart-accounts
RESTHeart|
Note
|
|
restheart-accounts is a RESTHeart plugin that adds application-level account management to any RESTHeart deployment.
It covers the full user lifecycle — registration, email verification, team invitations, password reset, and Google OAuth social login — as a set of configurable HTTP endpoints backed by the existing MongoDB user collection (mongoRealmAuthenticator).
The plugin is designed to be a first-class RESTHeart module: all features are opt-in, configured exclusively via restheart.yml, and produce standard JWT tokens that integrate transparently with the existing RESTHeart security pipeline.
Endpoints
| Method | URI | Auth | Description |
|---|---|---|---|
|
|
public |
Signup with email + password; creates user and team |
|
|
public |
Verify email via token link; auto-login |
|
|
public |
Request password reset link (always 202) |
|
|
public |
Apply reset token; auto-login |
|
|
owner / admin |
Invite a user to the caller’s team |
|
|
public |
Accept invitation, set password; auto-login |
|
|
owner / admin |
Re-send an expired invitation (email in request body) |
|
|
public |
Redirect browser to the OAuth provider’s consent screen |
|
|
public |
OAuth callback: exchange code, upsert user, set JWT cookie |
Installation
-
Build the plugin JAR:
mvn package -DskipTests -
Copy
target/restheart-accounts.jarandtarget/lib/*.jarto RESTHeart’splugins/directory. -
Add the plugin configuration to
restheart.yml(see Configuration). -
Start RESTHeart. The
accountsInitializerruns automatically at startup and ensures the required MongoDB collections and indexes are in place.
Multi-tenancy
restheart-accounts supports multi-tenant deployments without any custom code in the plugin itself.
All services check for request attributes injected by an upstream interceptor (such as AuthDbResolver or TenantConfigInterceptor) and use them in place of the static configuration values.
| Request attribute | Overrides | Effect |
|---|---|---|
|
|
Users and teams are read from and written to this database |
|
|
The JWT authentication cookie is scoped to this domain |
|
|
Application name used in email subjects and bodies |
|
|
Base URL used in transactional email links |
|
|
Redirect target after successful auto-login |
|
file path / built-in template |
Inline HTML string for the email-verification template (stored in MongoDB) |
|
file path / built-in template |
Inline HTML string for the password-reset template |
|
file path / built-in template |
Inline HTML string for the invitation template |
|
|
Per-tenant Google OAuth client ID |
|
|
Per-tenant Google OAuth client secret |
When an attribute is absent the plugin falls back to the corresponding static value in accountsConfig / oauthConfig.
A typical multi-tenant setup (e.g. restheart-cloud) has two interceptors running at REQUEST_BEFORE_EXCHANGE_INIT:
-
AuthDbResolver— maps the incoming hostname to the correctoverride-users-dbandoverride-cookie-domain. -
TenantConfigInterceptor— reads theconfs/{srvId}.accountsMongoDB document and attaches the remaining override attributes (app-name,frontend-url, per-tenant templates, per-tenant OAuth credentials).
Neither interceptor is part of restheart-accounts; they belong to the deployment layer (e.g. restheart-cloud-server).
No configuration changes to the plugin are needed per tenant.
OAuth & MCP
restheart-accounts implements social login via the /auth/oauth/* endpoints, with built-in support for Google and GitHub and a Java SPI for registering custom providers.
The plugin exchanges the OAuth authorization code (using ScribeJava) for user information, creates or updates the user document in MongoDB, and issues a RESTHeart JWT cookie — no custom OAuth logic required in the client.
This is distinct from RESTHeart’s built-in OAuth 2.1 authorization server, which is part of RESTHeart core and exposes standard endpoints (/authorize, /token, /introspect, etc.) intended for tool and client authentication — primarily for MCP (Model Context Protocol) integrations.
The two systems serve different purposes and operate completely independently.
See OAuth 2.0 Social Login for setup instructions for all providers, including the custom provider SPI.
Dependencies
-
RESTHeart ≥ 9.3 with
mongoRealmAuthenticatorandjwtTokenManagerenabled. -
An SMTP provider configured via the
ermessection (required for all email-based flows). -
OAuth provider credentials (optional — required only for the providers enabled under
oauthConfig.providers).