Built-in User Authentication and Authorization Configuration and Usage in HugeGraph
Overview
HugeGraph provides StandardAuthenticator for multi-user authentication and access control based on users, groups, operations, and resources.
Initialization creates the admin superuser. Administrators create users, groups, and resources, then grant or revoke permissions.
Users receive read, write, delete, and execute permissions through their groups.
A resource describes accessible data using type, label, and properties. Conditions within one resource are combined with AND; multiple resources are
combined with OR.
This relationship grants a user read access to data for Beijing.
Configure User Authentication
By default, HugeGraph does not enable user authentication, and it needs to be enabled by modifying the configuration file.
Production requires authentication
HugeGraph disables user authentication by default. In production, enable authentication and authorization, set a strong non-default administrator password,
maintain the Server IP allowlist, and grant minimum permissions. Do not expose Gremlin, Cypher, or other query endpoints directly to the public network.
Standard Server configuration writes authentication-proxy audit records to audit-*.log; retain these files and restrict read access. auth.audit_log_rate
limits per-user output rather than serving as a dedicated audit-log on/off switch.
Use StandardAuthenticator for built-in access control, or implement HugeAuthenticator to connect an existing identity system.
HugeGraph uses HTTP Basic Authentication. The value after
Basic is the Base64 encoding of username:password. With curl, pass the credentials directly through -u:
Protect Basic Authentication credentials
Basic Authentication only Base64-encodes username:password; it does not encrypt credentials. Use HTTPS for network transmission. See HTTPS
configuration.
JWT risks in older versions
HugeGraph-Server versions before 1.5.0 have JWT-related security risks in Auth mode. Upgrade affected versions or change the JWT secretKey according to that
version’s requirements.
auth.token_secret is read from the authentication graph’s configuration. The default graph is hugegraph, so its file is normally
conf/graphs/hugegraph.properties; if auth.graph_store changes, use that graph’s properties file.
The core configuration defaults to 32 random bytes encoded as Base64 and does not write that default back to the file. Independently generated defaults cannot
remain consistent across restarts or Server nodes. To preserve existing tokens across restarts or validate the same token on multiple nodes, explicitly
configure the same strong random secret in each authentication graph configuration.
Server encodes this string as UTF-8 for JJWT’s HS256 signer, which requires at least 32 bytes. This is a byte-length requirement; an arbitrary 32-character string need not have sufficient randomness. The command below generates 32 random bytes and Base64-encodes them locally.
Generate the secret locally and transfer it securely into the authentication graph configuration. Do not commit the actual secret or expose it in public logs:
Token lifetime is controlled by auth.token_expire, defaulting to 86400 seconds.
Both auth.token_expire and auth.token_secret belong to the authentication graph specified by auth.graph_store. Entries with the same names in
rest-server.properties do not override that graph configuration.
StandardAuthenticator Mode
StandardAuthenticator stores users and password hashes in the backend and checks access by role.
After updating these three configurations, initialize authentication and restart Server.
Set the authenticator and REST configuration path in conf/gremlin-server.yaml.
Set the authenticator and authentication graph in conf/rest-server.properties.
auth.graph_store names the graph that stores authentication data. It must match a graph configuration in conf/graphs/.
Set gremlin.graph in conf/graphs/<graph>.properties for each protected graph.
For authorization API usage, see the Authentication API documentation.
Custom User Authentication System
Implement org.apache.hugegraph.auth.HugeAuthenticator and point both authenticator configurations to that implementation to connect an existing identity
system.
Switching authentication mode
Use this sequence for a local persistent backend such as RocksDB, after applying the configuration above.
HStore/PD deployments create the administrator through the PD startup path. Set auth.admin_pa for that deployment instead of using local interactive
initialization.
Stop Server.
Initialize authentication data.
Enter a strong password when prompted to create
admin. Existing graph data is retained. Ifadminalready exists, this command does not reset its password. Keep the existing storage directory.Start Server and check authentication.
curl prompts for the password. Correct credentials should return HTTP 200; missing or incorrect credentials should return HTTP 401. If startup fails, check the logs and authentication graph configuration before retrying.
Enable authentication with Docker
For a new container, choose either Docker run or Docker Compose. For an existing container, see enabling authentication in existing containers.
When deploying with Docker, the official image supports enabling authentication
directly via environment variables (applicable to the official /hugegraph-server layout).
Replace the placeholder below with your image tag or digest:
Execute the command and enter a strong administrator password when prompted. Avoid committing plaintext passwords into shared Compose files. Persist the JWT secret in the authentication graph configuration as described above. Use the same value across all nodes.
Docker run
Create a new container and publish its REST port only on the local host.
The entrypoint configures authentication, initializes the backend on first startup, and starts Server. Continue with checking authentication.
Docker Compose
Save the following as compose.yaml. Compose rejects missing required variables to avoid starting an unauthenticated service by accident.
Start the service in the same terminal.
Set these variables again before recreating the container. Retain its data volumes and persist the configuration required by your deployment. Continue with checking authentication.
Existing containers
Use this path for an official Server container that ran without authentication and uses a local persistent backend.
Back up its data first. Confirm that the configuration, backend data, and conf-bak are all in mounted persistent volumes.
The official image declares /hugegraph-server as a volume; inspect the mounts of custom images first.
HStore/PD and external authentication services use their own administrator initialization paths.
Stop the original container and open a maintenance container with the same image and volumes.
Keep the original container stopped so two JVMs do not open the local database at once.
--entrypoint bashopens a shell without starting Server.Configure authentication and initialize it inside the maintenance container.
On its first run,
enable-auth.shsaves the original configuration inconf-bakand updates authentication and the defaulthugegraphgraph. Ifconf-bakalready exists, the script skips its changes. Check all three configurations under StandardAuthenticator mode. Configure other authentication graphs manually. Write a strong random JWT secret to the authentication graph configuration as described above, then initialize it.Enter the administrator password when prompted, then exit after initialization succeeds.
Start the original container from the host.
Retain the
docker/init_completemarker. Later changes to thePASSWORDenvironment variable do not change the stored administrator password.
Check authentication
Once Server is running, execute the following requests from the host to verify. -u admin prompts interactively for the password:
Requests without credentials should return 401 Unauthorized, while requests with the correct password return 200 OK (incorrect passwords also return 401).
Note: Current master URLs include /graphspaces/DEFAULT; for 1.7.0 and older versions, omit the graphspace prefix (use /graphs/hugegraph/... directly).
If unauthenticated requests still return 200, authentication is not active; inspect configuration and restart Server.