Skip to main content

Signature

ONLYOFFICE Docs uses tokens generated using the JSON Web Tokens standard. The tokens are sent when performing the client-side browser requests to ONLYOFFICE Docs or the HTTP requests to or from ONLYOFFICE Docs.

info

This feature is used in ONLYOFFICE Docs starting with version 4.2.

For the validation setup, it is necessary to edit the secret key and token parameters in the configuration file, which can be found (or created) at the following path:

/etc/onlyoffice/documentserver/local.json
caution

The default values are available in the default.json configuration file, which is available in the folders above (for Linux and Windows). Please do not edit the contents of the default.json file directly. The default values will be restored each time you restart Docker container or upgrade ONLYOFFICE Docs to a new version and all your changes will be lost.

Restart the services for the config changes to take effect:

supervisorctl restart all

Parameters

ParameterTypeExampleDescription
services.CoAuthoring.secret.browser.stringstringsecretDefines the secret key to generate a token in the client-side browser requests to ONLYOFFICE Docs.
services.CoAuthoring.secret.inbox.stringstringsecretDefines the secret key to generate a token in the incoming HTTP requests with the commands from the document storage service to the document command service, document conversion service and document builder service.
services.CoAuthoring.secret.outbox.stringstringsecretDefines the secret key to generate a token in the outgoing HTTP requests to the callbackUrl address by document editing service.
services.CoAuthoring.token.enable.browserbooleanfalseDefines if a token in the client-side browser requests is enabled or not.
services.CoAuthoring.token.enable.request.inboxbooleanfalseDefines if a token in the incoming HTTP requests is enabled or not.
services.CoAuthoring.token.enable.request.outboxbooleanfalseDefines if a token in the outgoing HTTP requests is enabled or not.

Sample local.json configuration

{
"services": {
"CoAuthoring": {
"secret": {
"browser": {
"string": "secret"
},
"inbox": {
"string": "secret"
},
"outbox": {
"string": "secret"
}
},
"token": {
"enable": {
"browser": true,
"request": {
"inbox": true,
"outbox": true
}
}
}
}
}
}

Code samples for signature generation

Below you can find examples of signature generation for initialization config and requests. They are taken from test samples in different programming languages. We advise you to use this code in your projects to generate signatures.

import config from "config"

const configServer = config.get("server")
const cfgSignatureSecretExpiresIn = configServer.get("token.expiresIn")
const cfgSignatureSecret = configServer.get("token.secret")
const cfgSignatureSecretAlgorithmRequest = configServer.get("token.algorithmRequest")
documentService.getToken = function getToken(data) {
const options = {algorithm: cfgSignatureSecretAlgorithmRequest,
expiresIn: cfgSignatureSecretExpiresIn}
return jwt.sign(data, cfgSignatureSecret, options)
}