1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
10 "git.curoverse.com/arvados.git/sdk/go/arvados"
11 "git.curoverse.com/arvados.git/sdk/go/keepclient"
14 // SignLocator takes a blobLocator, an apiToken and an expiry time, and
15 // returns a signed locator string.
16 func SignLocator(cluster *arvados.Cluster, blobLocator, apiToken string, expiry time.Time) string {
17 return keepclient.SignLocator(blobLocator, apiToken, expiry, cluster.Collections.BlobSigningTTL.Duration(), []byte(cluster.Collections.BlobSigningKey))
20 // VerifySignature returns nil if the signature on the signedLocator
21 // can be verified using the given apiToken. Otherwise it returns
22 // either ExpiredError (if the timestamp has expired, which is
23 // something the client could have figured out independently) or
25 func VerifySignature(cluster *arvados.Cluster, signedLocator, apiToken string) error {
26 err := keepclient.VerifySignature(signedLocator, apiToken, cluster.Collections.BlobSigningTTL.Duration(), []byte(cluster.Collections.BlobSigningKey))
27 if err == keepclient.ErrSignatureExpired {
29 } else if err != nil {
30 return PermissionError