By default, requests that modify existing files or account settings are authenticated, but requests to upload or deliver files are not. Requests are authenticated by checking a policy string that is signed by a shared secret. Applications can be configured on an individual basis so that every request is authenticated. All security settings are configurable in the Developer Portal.
|Modifies existing file
|Modifies account settings
|Uploads new file
Policies and Signatures
Authentication and authorization against our APIs relies on Base64URL-encoded JSON “policies” and HMAC-SHA256 “signatures”. The policy determines which actions are authorized and the signature authenticates the policy. Depending on the API, these values may be required as part of the path, query parameters, or body of a request.
The secret used for signing is automatically generated for each application. The secret should be carefully protected and never exposed client-side. A secure application stack requires backend code that generates and signs short-lived and limited-scope policies for clients. The secret can be regenerated as needed, but this will invalidate existing signatures.
A policy must contain an “expiry” but can exclude all other values. A minimal policy, containing only an expiry, permits nearly all requests. The “call” value limits the types of requests allowed, and additional values limit request parameters. Getting EXIF data from image files requires explicit permission.
This policy allows any request except one to get EXIF data:
This policy only allows uploading and saving to custom storage:
"call": ["pick", "store"]
A valid policy must contain an “expiry” value set in the future, but can exclude any other values.
|Sets policy expiration
|Array of call names
|Limits allowed requests, defaults to all
|Limits file modifications to a single file
|Limits storage containers allowed for uploads
|Limits storage paths allowed for uploads
|Limits source URL’s allowed for transformations
|Size in bytes
|Sets a min size for uploads
|Size in bytes
|Sets a max size for uploads
Please notice that while using the container, path, or URL policy keys, all special characters should be escaped with a backslash in order to use them in regular expressions.
The example of the url:
Regular expression with the properly escaped special characters:
Policies without a “call” array allow every call by default except “exif”. Requests to get EXIF data require the “exif” call explicitly.
|Saving to custom storage (also need “pick”)
|Overwriting (not new uploads)
|Converting (and using the document viewer)
|Getting exif metadata for image files
|Getting file metadata
|Running workflow jobs
The Developer Portal contains a widget to create and sign policies and each of the SDK’s contain helper functionality for the same. The below example shows how to create and use a policy for file delivery.
Create a JSON policy string:
"call": ["read", "convert"],
Base64URL encode the policy string:
Create a HMAC-SHA256 signature of the encoded policy (using ‘mysecret’ as key):
Using the policy and signature with a download URL:
Using a policy and a signature when transforming your files (resize transformation URL):