- Home
- Docs
- Installation and configuration
- Enterprise
- Docker version
- Configuring JWT for ONLYOFFICE Docs
Configuring JWT for ONLYOFFICE Docs
To protect documents from unauthorized access, ONLYOFFICE editors use the JSON Web Token (JWT). The token is added in the configuration when the Document Editor is initialized and during the exchange of commands between internal ONLYOFFICE Docs services. The secret key is used to sign the JSON web token and validate the token upon the request to ONLYOFFICE Docs.
To protect your documents, specify your own secret key in the ONLYOFFICE Docs configuration file, then specify the same secret key in the connector settings. If you are using a version earlier than 7.2, you will also need to enable token validation.
For Linux/Windows: Configure ONLYOFFICE Docs
-
Open the
local.jsonfile with any available text editor.- For Linux —
/etc/onlyoffice/documentserver/local.json - For Windows —
%ProgramFiles%\ONLYOFFICE\DocumentServer\config\local.json
- For Linux —
-
If you are using a version earlier than 7.2, enable token validation by changing the
falsevalue totruein three sections:services.CoAuthoring.token.enable.browserservices.CoAuthoring.token.enable.request.inboxservices.CoAuthoring.token.enable.request.outbox
-
Specify your own secret key by replacing the secret value with your own text string in three sections. The secret key must be identical across all three sections.
services.CoAuthoring.secret.inbox.stringservices.CoAuthoring.secret.outbox.stringservices.CoAuthoring.secret.session.string
{ "services": { "CoAuthoring": { "token": { "enable": { "request": { "inbox": true, "outbox": true }, "browser": true } }, "secret": { "inbox": { "string": "<your_secret_key>" }, "outbox": { "string": "<your_secret_key>" }, "session": { "string": "<your_secret_key>" } } } } } - Save your changes.
-
Restart the services for the config changes to take effect:
systemctl restart ds-converter ds-docservice ds-metrics
For Docker: Use environment variables
For Docker deployments, use environment variables in the docker run command instead of editing local.json directly.
/etc/onlyoffice/documentserver/local.json, JWT will be enabled again and the secret key will be re-generated during server restart. Always use environment variables to configure JWT in Docker deployments.To apply new environment variables, you must recreate the container. Stop and remove the existing container, then run a new one with the updated parameters:
sudo docker stop documentserver
sudo docker rm documentserver
sudo docker run -i -t -d -p 80:80 \
-e JWT_ENABLED=true \
-e JWT_SECRET=<your_secret_key> \
onlyoffice/documentserver
To disable JWT, use -e JWT_ENABLED=false instead.