Entitlement Service
Manage content entitlements and rights of end-users.
Overview
The purpose of an Entitlement Service is to decide based on the defined business rules if a given end-user should be able to play a given video and to provide respective entitlements.
Entitlement: the fact of having a right to something
A frontend application can then display or hide a video from the end-user. If DRM is used, it can further exchange the provided entitlements into a DRM license using a DRM License Service. This DRM License will be used by a video player (and the underlying Content Decryption Module) to decrypt and play the video.
Entitlement Service natively supports Axinom DRM (it generates an entitlement message directly understood by the Axinom DRM License Service), but it can easily be adjusted to communicate with other DRM providers, see DRM Support below.
Axinom Entitlement Service is a customizable service. It is provided in source code under an open-source license. You can use the service as-is, or you can freely customize it to tailor your environment.
Entitlement service is delivered as a part of the Mosaic Media Template.
Data Model
Entitlement Service owns the following data:
- GeoIP Database - for deriving end-user’s country based on the IP address.
GeoIP Database
A GeoIP Database is used for deriving end-user’s country based on the IP address. A free tier of a Maxmind country database is currently included.
The GeoIP Database is updated automatically on every Entitlement Service startup and then every 24 hours. This complies with the licensing conditions of Maxmind. The database can also be easily updated manually by updating geoip-country npm package that is used, since the vendor regularly deploys new versions with updated databases.
GUI
Entitlement Service does not have its own GUI.
Interfaces
GraphQL Frontend-facing
Entitlement Service exposes a GraphQL query endpoint entitlement() that takes an entityId as a parameter and returns (in positive case) an Entitlement Message and an array of claims that passed the evaluation.
entityId is the ID of an entity that the caller would like to play, e.g. movie-123 or episode-456.
To call this endpoint, the end-user must be authenticated using the User Service and must provide a valid JWT token.
Video Service Webhooks
Entitlement Service also implements the /manifest and /entitlement webhooks of the Video Service, which let editors play protected videos in the Management System.
The /entitlement webhook returns a signed Entitlement Message together with the License Service URLs and the FairPlay certificate of the environment.
See Previewing Videos in the Management System for how to configure the webhooks in the Video Service.
Business Rules
To make its decision the Entitlement Service performs the following steps:
Customizing Business Rules
If you would like to add/remove/modify the entitlement checks, you can easily do so by modifying the source code of the Entitlement Service.
Removing unused checks can make sense already from a performance point of view.
DRM Support
The service is compatible with Axinom DRM - it generates an Entitlement Message, that is understood natively by Axinom DRM License Service.
The currently implemented logic does the following:
- In a positive case, create an Axinom DRM Entitlement Message wrapped into an Axinom DRM License Service Message
- Include every Key ID (Key IDs are assumed to be maintained in the Video Service and published through the Catalog Service)
- Assign the same Policy to all Key IDs
- For this policy set for PlayReady - for development purpose - min_device_security_level: 150 and a PlayReady enabler "Support playback when the output type is unknown"
- Set license.allow_persistence to
trueorfalse, depending on the presence of the claim ENABLE_VIDEOS_DOWNLOAD - Sign the generated Entitlement Message with a Communication Key of the environment, read from the Mosaic DRM Service, see DRM Settings below
DRM Settings
Entitlement Service reads the DRM settings of its environment from the Mosaic DRM Service while it runs. The service reads:
- the communication key that signs the Entitlement Messages
- the DRM tenant ID, from which it builds the License Service URLs of the environment
- the FairPlay certificate: the first FairPlay certificate registered for the environment, or a test certificate while the environment may still use one (see
FAIRPLAY_TEST_CERT_URLunder Configuration)
The service checks for changed settings every few minutes, so changes in the Management System are picked up without a restart.
Prerequisites
- The DRM Service is enabled for the environment, see Enabling the service.
- The environment has at least one communication key, see Communication Keys.
- Entitlement Service has its own service account with the Admin permission of the DRM Service. When you run the service locally, the setup script of the Mosaic Media Template creates this service account for you. When you deploy the service with the Hosting Service, the Hosting Service creates it from the deployment manifest.
Without the DRM Service, Entitlement Service still starts.
Videos that are not DRM-protected don't need the DRM lookup, so their playback is not affected.
Requests for protected videos fail with the error DRM_SERVICE_REQUEST_FAILED until the DRM settings can be read.
Communication Key Rollover
A new communication key needs up to 10 minutes to become active in every License Service instance. Entitlement Service therefore ignores keys that are younger than 10 minutes and signs with the newest of the remaining keys. If all keys of the environment are younger than 10 minutes, it uses the oldest of them.
To replace a communication key without interrupting playback:
- Create the new key in the Management System.
- Wait about 15 minutes, until Entitlement Service has switched to the new key.
- Wait until the Entitlement Messages signed with the old key have expired.
Deleting the old key invalidates every message signed with it, so players that still hold such a message can no longer acquire a license.
How long a message stays valid depends on the
expiration_dateyou set in the License Service Message. - Delete the old key.
Configuration
The following environment variables control how the service reaches the DRM Service and the License Service:
| Variable | Required | Description |
|---|---|---|
DRM_SERVICE_BASE_URL | Yes | The URL of the DRM Service of your Mosaic region, for example https://drm.service.eu.axinom.net. |
SERVICE_ACCOUNT_CLIENT_ID, SERVICE_ACCOUNT_CLIENT_SECRET | Yes | The credentials of the service account that reads the DRM settings. |
LICENSE_SERVICE_WIDEVINE_URL, LICENSE_SERVICE_PLAYREADY_URL, LICENSE_SERVICE_FAIRPLAY_URL | No | The License Service URLs returned by the /entitlement webhook. Use the License Service URLs of your environment, listed under Service endpoints, but without the DRM tenant prefix in front of the host: the service adds it itself. The default is the production License Service. |
FAIRPLAY_TEST_CERT_URL | No | The URL of the FairPlay certificate to use when no FairPlay certificate is registered for the environment. The default is a test certificate provided by Axinom. |
Errors
| Error code | Meaning |
|---|---|
DRM_SERVICE_REQUEST_FAILED | The DRM settings could not be read, for example because the DRM Service is not enabled for the environment. |
NO_DRM_TENANT_FOUND | The DRM Service returned no DRM tenant for the environment. |
NO_COMMUNICATION_KEYS_AVAILABLE | The environment has no communication key. |
NO_FAIRPLAY_CERTIFICATE_AVAILABLE | The environment has no FairPlay certificate, and the environment can no longer use a test certificate. |
Customizing DRM Support
To customize the logic for Entitlement Message generation, adjust the file entitlement-message-generation.ts.
If you use Axinom DRM, you may want to customize the structure of the Entitlement Message. See Entitlement Message (data structure) and Entitlement Message (Tool) for more details.
If you use a different DRM provider, replace the code according to the instructions of the respective provider.
Pricing
Entitlement Service is provided under an open-source license free of charge.