// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.

syntax = "proto3";

package macaroon;
option go_package = "storj.io/common/macaroon";

import "pico.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

message Caveat {
  // if any of these three are set, disallow that type of access
  bool disallow_reads = 1;
  bool disallow_writes = 2;
  bool disallow_lists = 3;
  bool disallow_deletes = 4;
  bool disallow_locks = 5;
  bool disallow_put_retention = 6;
  bool disallow_get_retention = 7;
  bool disallow_put_legal_hold = 8;
  bool disallow_get_legal_hold = 9;
  bool disallow_bypass_governance_retention = 11;
  bool disallow_put_bucket_object_lock_configuration = 12;
  bool disallow_get_bucket_object_lock_configuration = 13;
  bool disallow_put_bucket_notification_configuration = 14;
  bool disallow_get_bucket_notification_configuration = 15;

  // If any entries exist, require all access to happen in at least
  // one of them.
  message Path {
    bytes bucket = 1;
    bytes encrypted_path_prefix = 2;
  }
  repeated Path allowed_paths = 10;

  // if set, the validity time window
  google.protobuf.Timestamp not_after = 20  [(pico.field).custom_type = "time.Time", (pico.field).custom_cast = "storj.io/picobuf/picoconv.Timestamp"];
  google.protobuf.Timestamp not_before = 21 [(pico.field).custom_type = "time.Time", (pico.field).custom_cast = "storj.io/picobuf/picoconv.Timestamp"];

  // if set, sets expiration time for new objects
  google.protobuf.Duration max_object_ttl = 22 [(pico.field).custom_type = "time.Duration", (pico.field).custom_cast = "storj.io/picobuf/picoconv.Duration"];

  // nonce is set to some random bytes so that you can make arbitrarily
  // many restricted macaroons with the same (or no) restrictions.
  bytes nonce = 30;
}
