|
XRootD
|
This plugin adds support for macaroons over HTTP in XRootD.
Macaroons are a type of cryptographic authorization token designed to provide flexible, decentralized access control. They were introduced by Google researchers as an alternative to traditional bearer tokens and OAuth-style access tokens, with a focus on delegation and attenuation of privileges.
Unlike opaque tokens, macaroons embed structured caveats that restrict what the token can do. These restrictions can be added by different parties without needing to contact a central authority, making them especially useful in distributed systems. Caveats are always monotonic: they can only reduce permissions, never increase them.
Caveats take the form KEY:VALUE. In XRootD, the following caveats are supported:
name: this is the identity of the user that obtained the initial macaroonpath: a path restriction such that the macaroon only allows access within itactivity: pre-defined set of allowed activities for the given macaroonbefore: defines the date/time when the macaroon expires and becomes invalidXRootD supports the following activity types: READ_METADATA, UPDATE_METADATA, LIST, DOWNLOAD, UPLOAD, MANAGE, and DELETE. Below are the operations that each of the activities allow:
READ_METADATA: statUPDATE_METADATA: chmod, chownLIST: readdirDOWNLOAD: readUPLOAD: rename, create, insertMANAGE: insert, lock, mkdir, update, create, overwriteDELETE: rm, rmdirIn order to request a macaroon with restricted ability relative to what the user requesting it can obtain, a list of activities can be passed in in the POST request, like in the example below:
Unsupported caveats are rejected by the server. A macaroon can be used to request another macaroon which is further limited in its privileges.
To obtain a macaroon, the user can use curl or other tool to issue a POST request, like so:
The above will result in a JSON response object containing the macaroon and in how many seconds it expires (60 seconds, as requested in the validity above):
Then, to use the macaroon, use the value of the macaroon element in the JSON object as your bearer token, like so:
In order to enable support for macaroons in your XRootD server/cluster, the following lines are required:
where <sitename> is the name of your site (it must be set to use macaroons). The site name is used to set the macaroon's standard location field.
The macaroons.secretkey is what is used by the server as symmetric key to sign the macaroons it emits, so make sure it's not too short. The macaroons library defines a suggested secret length of 32 bytes, but we recommend using at least 64 bytes for your secret keys used with XRootD. You can use any string for this. However, the recommended best practice is to generate a random key with openssl, as shown below: