Object locking prevents object versions from being deleted or overwritten – for a fixed amount of time or indefinitely. Use an object lock to help meet regulatory requirements requiring WORM storage, or to add another layer of protection against object changes and deletion.

Objects are not actually locked. Object locking is used to lock individual object versions.

Object locking does not prevent the creation of new versions of an object while the object is locked – it makes it impossible to delete or otherwise change the version(s) of the object with locking enabled.

Important

Object locking does not prevent overwriting or deleting objects. Since the locked versions remain present and protected, it is still possible to overwrite or even delete objects with locking enabled.

A new version is created when overwriting or modifying an object. A delete request creates a delete marker. The object appears deleted, but Swarm preserves history including the locked version.

There are two types of object locking used simultaneously and independent of each other:

Retention

Retention Periods

A retention period is used to set the fixed amount of time the object needs to remain locked. The object version cannot be changed or deleted until the time expires.

There is more than one way to set a retention period on an object version:

A bucket default retention period specifies a duration (in days or years) for which every object version placed in the bucket is locked. Gateway calculates a retention period for the object version by adding the specified duration to the object version's creation timestamp when placing an object in the bucket.

How to Extend a Retention Period

A retention period can always be extended after it is set with the following steps:

  1. Submit a new lock request for the object version with a retention period longer than the current one.

  2. Gateway replaces the existing retention period with the new, longer period.

Any user with permissions to set an object retention period can also extend a retention period.

Retention Modes

A retention mode must always be specified when locking an object or setting a bucket default retention period. 

Info

Retention mode always applies to the individual objects carrying it, not to the bucket or cluster as a whole.

There are two retention modes impacting actions with objects under retention:

Info

Compliance mode is irreversible for the entire retention period once an object is locked.

In a deviation from S3, Gateway always uses the maximum of either the bucket default retention duration, or the duration specified in a per-object request.

Legal Hold

A legal hold prevents an object version from being overwritten or deleted until the legal hold is removed.

Legal holds do not have an associated retention period and are independent from retention periods and retention modes. As long as the bucket containing the object has object locking enabled adding and removing legal holds are available. It does not matter if the specified object version has a retention period set or not.

Info

Setting a legal hold on an object version does not affect the retention mode or retention period for the object version.

Prerequisites

Swarm Storage 12.0 or above must be running to use this feature because it relies on the Swarm lifepoints feature to prevent deletion of locked objects until a certain date has passed. Object locking is fully implemented starting with Gateway 7.6.

When an object is locked until a certain date, it obtains a deletable=no lifepoint protecting it from deletion until the date.

Important

Even though Gateway relies on lifepoints, it remains possible for applications to impose user defined lifepoints on objects together with object locks. Gateway verifies correct semantics in all cases without any additional behavior needed from the application side. In case of any conflicts between user defined lifepoints and object locks, the object lock always wins.

Versioning needs to be enabled for object locking to work.

Gateway refuses to enable object locking when versioning is not enabled. Gateway refuses to disable versioning once object locking is enabled. In both cases an error message is displayed.

Info

The ability to disable versioning at the cluster level via SNMP does not pass via Gateway so it cannot protect against disabling object locking in the cluster.
Administrators are advised against disabling versioning at the cluster level to avoid the risk of auto-deleting locked object versions after object locking is enabled in individual domains or buckets.

Metadata Headers Related to Object Locking

Object versions in Swarm are immutable and the metadata cannot be changed unlike Amazon S3.

Object locking uses the following headers:

The above headers are listed using the SCSP names. The corresponding S3 names start with x-amz-*. The SCSP headers are effectively stored with the objects. The S3 names are mapped onto the SCSP counterparts and back on-the-fly.

Assumptions and Limitations

Lifepoint Headers

Gateway now adds a single deletable=no lifepoint header (the lock lifepoint), to go along with the object lock. This lock lifepoint is what actually protects the object against deletion in Swarm, both through user requests and through built-in functionalities like HP or bucket policies.

The lock lifepoint is computed as follows;

  1. The lock lifepoint end date matches the end date of the retention period if the object is locked with a retention period. For legal hold, the lock lifepoint has no end date.

  2. Next review the list of original lifepoints, and append those whose end date is later than the one from the lock lifepoint. In case of legal hold, there is no end date so none of the original lifepoints get appended.

The purpose of storing the set of original lifepoints is to allow later modifications/removal of the object lock to recompute/reinstate the original lifepoints as they are before the object lock.

The purpose of appending the "later lifepoints" to the lock lifepoint is to allow Swarm to act on them as it normally does once the lock lifepoint has expired naturally, without any intervention from Gateway. For legal hold there must always be a Gateway intervention to remove the lock, so the original lifepoints get reinstated at the time.

How to Enable Object Locking

Object locking is set using API calls. It is not available in the user interface.

Enabling Object Locking on a Bucket

Object locking must be enabled on the bucket before locking any objects.

S3 normally allows enabling object locking on new buckets without any objects. Gateway does not impose this restriction.

The user must have the PutBucketObjectLocking permission to enable/disable object locking on a bucket. A user must have the GetBucketObjectLocking permission to query current object locking status.

Object Locking and Versioning Inheritance Rules

Versioning can be disabled for another bucket or domain in the cluster unrelated if a bucket in one domain has object locking (and therefore versioning) enabled.

Cannot be disabled at the bucket, domain or cluster level if object locking (and versioning) is enabled at a bucket level.

Can be disabled for individual buckets if enabled at a domain level.

Can be disabled for individual domains and/or buckets if enabled at the cluster level.

It does not matter if versioning was enabled on the bucket itself, or whether it was inherited from cluster or domain level. Gateway refuses to disable versioning at the domain or bucket level if object locking is in effect anywhere within it.

Errors When Attempting to Enable Object Locking

The request to enable object locking can fail with the following errors:

Enabling object locking on a bucket comes down to storing the x-object-lock-meta-status and optionally x-object-lock-meta-default headers on the bucket context object. This immediately caches the bucket’s object locking configuration in memory so it is readily available during object requests.

Enabling Object Locking using S3

Enable or inspect the object locking configuration on a bucket using the following calls;

Enabling Object Locking using SCSP

Enable object locking on a bucket:

PUT /<bucket>?objectlock=<defaultmode> [ :<defaultperiod> ]

In this call omit either defaultmode, defaultperiod, or both.

The bucket allows object locking (it is enabled), but no locking happens by default if both are omitted. Objects written to the bucket without any locking directives remain unlocked.

The defaults can be modified or removed at any time via additional PUT commands. This does not affect the object locking status of the bucket – once it is enabled, it stays enabled.

Caution

Object locking cannot be disabled once enabled on a bucket.

It does not matter if versioning was enabled on the bucket itself, or whether it was inherited from cluster or domain level. Gateway refuses to disable versioning at the domain or bucket level if object locking is in effect anywhere within it.

Remove the lock defaults and write new objects without any object locking headers to allow writing unlocked objects into a bucket with object locking enabled.

Remove the lock defaults:

PUT /<bucket>?objectlock=
(use an empty query argument)
The "=" is optional.

How to Check Object Locking Status

REST API Changes

Object locking introduces the following new REST calls:

Object locking also introduces changes to existing REST calls:

For S3, see https://docs.aws.amazon.com/AmazonS3/latest/API/Welcome.html.

How to Lock an Object at Creation Time

Creating a New Object with a Retention Period

The client adds the following headers in the S3 PutObject / SCSP POST request to create a new object or object version with an immediate retention period in effect:

x-object-lock-meta-mode: <GOVERNANCE|COMPLIANCE>
x-object-lock-meta-retain-until-date: <date>
This takes precedence over the default bucket retention mode and duration, if present.

In a deviation from S3, Gateway always uses the maximum of either the bucket default retention duration, or the duration specified in a per-object request.

Gateway looks for corresponding defaults at the bucket level if any one of these two headers is omitted from the request and if found, takes the corresponding values from there.

The request fails with a 400 Bad Request error because both are needed for a successful retention lock if either mode or retain-until-date is then still missing.

Creating a New Object with a Legal Hold

The client adds the following header in the S3 PutObject / SCSP POST request to create a new object or object version with an immediate legal hold in effect:

x-object-lock-legal-hold: ON

The user needs to have the PutObjectRetention and, respectively, PutObjectLegalHold permission to use these headers, or the request fails with a 403 Forbidden error.

The request fails with a 412 Precondition Failed error if the bucket does not have object locking enabled.

Gateway forwards these headers when creating the new object on Swarm, and also creates a lock lifepoint instructing Swarm to not delete the object before the retention period expires. For retention periods, the lock lifepoint also includes the subset of the original lifepoints with a later end date than the retention period.

lifepoint: [<date>] deletable=no, <later lifepoints>

Or in case of legal hold;

lifepoint: [] deletable=no

The original lifepoint headers are preserved in:

x-object-lock-meta-original-lifepoints: <original lifepoints>

Writing an Object as a Normal Unlocked Object in a Bucket with Object Locking Enabled

Objects are written as a normal unlocked object, despite being written to a bucket with object locking enabled if both headers are omitted from the request, and there are no defaults at the bucket level.

Managing Retention on an Existing Object

Enabling and disabling retention on an object requires the user have the PutObjectRetention permission.

The user must have the GetObjectRetention permission to query current retention status.

The client must explicitly specify the versionId of the object version to lock.

Gateway then applies the extra object locking headers to the version, thus applying object locking protection for the length of the retention period.

The following headers are added or changed;

x-object-lock-meta-mode: <GOVERNANCE|COMPLIANCE>
x-object-lock-meta-retain-until-date: <date>
x-object-lock-meta-original-lifepoints: <original lifepoints>
lifepoint: [<date>] deletable=no, <later lifepoints>

Gateway must recompute the lock lifepoint when changing the retention period, starting from the preserved set of original lifepoints and appending those with later end dates to the lock lifepoint. This is the main purpose of preserving the original lifepoints.

In a deviation from S3, Gateway always uses the maximum of either the bucket default retention duration, or the duration specified in a per-object request.

Introducing or extending a retention period is always possible, but there are restrictions to shortening or removing a retention period on an object already under retention:

Using S3, enable or inspect the retention period on an object using the following calls;

Using SCSP, enable or inspect the retention period on an object using the following calls:

Both S3 and SCSP also allow retrieving object lock information using regular object HEAD and GET requests.
Assuming the user has the GetObjectRetention permission, the information is returned in the form of the above response headers. The response body is not affected.

Managing Legal Hold on an Existing Object

Enabling/disabling legal hold requires the user have the PutObjectLegalHold permission. The GetObjectLegalHold permission is required to check the current legal hold status.

As with retention periods, Gateway stores this as a metadata header.

x-object-lock-meta-legal-hold: ON
(empty means OFF)
x-object-lock-meta-original-lifepoints: <original lifepoints>
lifepoint: [] deletable=no

Using S3, enable or inspect the legal hold using the following calls:

Using SCSP, enable or inspect the legal hold on an object using the following calls:

Both S3 and SCSP also allow retrieving legal hold information using regular object HEAD and GET requests. Assuming the user has the GetObjectLegalHold permission, the information is returned in the form of the above response headers. The response body is not affected.

Combined Retention and Legal Hold

An object can be both under one of the retention modes AND legal hold at the same time.

In the SCSP protocol, querying and deleting such combined locks is handled via a uniform GET and DELETE API (as opposed to S3 which has separate APIs for querying/deleting retention and legal hold).

Differences Between S3 and Swarm's Implementation of Object Locking

In S3, a DELETE request results in a delete marker, shadowing the locked object version. Swarm's implementation deviates from this logic – it rejects any DELETE requests for indelible objects with an HTTP 403 Forbidden error.

Gateway checks if the object is locked when it receives an HTTP 403 Forbidden error from Swarm. Gateway simulates the S3 behavior creating a new (unlocked) object version, immediately followed by a DELETE, thus creating a delete marker.

For SCSP, use a configuration flag to pick the desired behavior:

[object_locking]
scspDeleteUsesS3Logic=true

New Policy Actions Related to Object Locking

The following new policy actions related to object locking are introduced:

Interactions with Existing Swarm Functionality

Recursive Deletes

Clients can request Recursive Deletes of entire domains/buckets using DELETE <uri>?recursive=yes requests. Swarm implements this by synchronously deleting the domain/bucket object, and asynchronously deleting the objects in it. This has potential for conflicting with object retention/legal hold. Gateway first checks if there are any objects under retention/legal hold and refuse the recursive delete if so.

The recursive delete request fails with a 412 Precondition Failed error if any buckets with object locks are found.

APPEND

SCSP APPEND does create a new version when versioning is enabled; it does not allow an object's metadata to be modified. The "retain-until" header value can not be changed on an APPEND. Gateway does not impose any restrictions on the use of APPEND in combination with object locking.

Max Retention Configuration

S3 allows defining a max-retention-duration limit in the policy. Gateway currently approximates this functionality using a new configuration flag:

[object_locking]
retentionMaxYears=100
The default limit value is 100 years (input type int) if unspecified.

Audit Logging

Object Locking operations are audit logged (Gateway Audit Logging). Since object locks can also be requested as part of the object PUT/POST/COPY requests, Gateway tag the request's audit log line with additional object lock information, rather than inserting new log lines.

The tags are appended to the audit log line, enclosed in [] brackets. Multiple tags (for example, both legal hold and retention are requested) are comma separated.

Object locking tags are always prefixed with OBJLCK.