-
Notifications
You must be signed in to change notification settings - Fork 402
/
alias.go
82 lines (65 loc) · 2.68 KB
/
alias.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package macaroon
import "storj.io/common/macaroon"
// ActionType specifies the operation type being performed that the Macaroon will validate
type ActionType = macaroon.ActionType
const (
// ActionRead specifies a read operation
ActionRead = macaroon.ActionRead
// ActionWrite specifies a read operation
ActionWrite = macaroon.ActionWrite
// ActionList specifies a read operation
ActionList = macaroon.ActionList
// ActionDelete specifies a read operation
ActionDelete = macaroon.ActionDelete
// ActionProjectInfo requests project-level information
ActionProjectInfo = macaroon.ActionProjectInfo
)
// Action specifies the specific operation being performed that the Macaroon will validate
type Action = macaroon.Action
// APIKey implements a Macaroon-backed Storj-v3 API key.
type APIKey = macaroon.APIKey
// ParseAPIKey parses a given api key string and returns an APIKey if the
// APIKey was correctly formatted. It does not validate the key.
func ParseAPIKey(key string) (*APIKey, error) {
return macaroon.ParseAPIKey(key)
}
// ParseRawAPIKey parses raw api key data and returns an APIKey if the APIKey
// was correctly formatted. It does not validate the key.
func ParseRawAPIKey(data []byte) (*APIKey, error) {
return macaroon.ParseRawAPIKey(data)
}
// NewAPIKey generates a brand new unrestricted API key given the provided
// server project secret
func NewAPIKey(secret []byte) (*APIKey, error) {
return macaroon.NewAPIKey(secret)
}
// AllowedBuckets stores information about which buckets are
// allowed to be accessed, where `Buckets` stores names of buckets that are
// allowed and `All` is a bool that indicates if all buckets are allowed or not
type AllowedBuckets = macaroon.AllowedBuckets
// NewCaveat returns a Caveat with a random generated nonce.
func NewCaveat() (Caveat, error) {
return macaroon.NewCaveat()
}
// Macaroon is a struct that determine contextual caveats and authorization
type Macaroon = macaroon.Macaroon
// NewUnrestricted creates Macaroon with random Head and generated Tail
func NewUnrestricted(secret []byte) (*Macaroon, error) {
return macaroon.NewUnrestricted(secret)
}
// NewSecret generates cryptographically random 32 bytes
func NewSecret() (secret []byte, err error) {
return macaroon.NewSecret()
}
// ParseMacaroon converts binary to macaroon
func ParseMacaroon(data []byte) (_ *Macaroon, err error) {
return macaroon.ParseMacaroon(data)
}
// Caveat is a caveat.
type Caveat = macaroon.Caveat
// Caveat_Path is a path for caveat.
// If any entries exist, require all access to happen in at least
// one of them.
type Caveat_Path = macaroon.Caveat_Path //nolint alias to generated code