diff options
author | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
commit | 404aeae4545d2426c089a5f8d5e82dae56f5212b (patch) | |
tree | 2d84e00af272b39fc04f3795ae06bc48970e57b5 /vendor/github.com/minio/minio-go/v7/pkg/credentials/static.go | |
parent | 209d8b0187ed025dec9ac149ebcced3462877bff (diff) | |
download | gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip |
Make Nix builds work
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/pkg/credentials/static.go')
-rw-r--r-- | vendor/github.com/minio/minio-go/v7/pkg/credentials/static.go | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/pkg/credentials/static.go b/vendor/github.com/minio/minio-go/v7/pkg/credentials/static.go new file mode 100644 index 0000000..7dde00b --- /dev/null +++ b/vendor/github.com/minio/minio-go/v7/pkg/credentials/static.go | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * MinIO Go Library for Amazon S3 Compatible Cloud Storage | ||
3 | * Copyright 2017 MinIO, Inc. | ||
4 | * | ||
5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | * you may not use this file except in compliance with the License. | ||
7 | * You may obtain a copy of the License at | ||
8 | * | ||
9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | * | ||
11 | * Unless required by applicable law or agreed to in writing, software | ||
12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | * See the License for the specific language governing permissions and | ||
15 | * limitations under the License. | ||
16 | */ | ||
17 | |||
18 | package credentials | ||
19 | |||
20 | // A Static is a set of credentials which are set programmatically, | ||
21 | // and will never expire. | ||
22 | type Static struct { | ||
23 | Value | ||
24 | } | ||
25 | |||
26 | // NewStaticV2 returns a pointer to a new Credentials object | ||
27 | // wrapping a static credentials value provider, signature is | ||
28 | // set to v2. If access and secret are not specified then | ||
29 | // regardless of signature type set it Value will return | ||
30 | // as anonymous. | ||
31 | func NewStaticV2(id, secret, token string) *Credentials { | ||
32 | return NewStatic(id, secret, token, SignatureV2) | ||
33 | } | ||
34 | |||
35 | // NewStaticV4 is similar to NewStaticV2 with similar considerations. | ||
36 | func NewStaticV4(id, secret, token string) *Credentials { | ||
37 | return NewStatic(id, secret, token, SignatureV4) | ||
38 | } | ||
39 | |||
40 | // NewStatic returns a pointer to a new Credentials object | ||
41 | // wrapping a static credentials value provider. | ||
42 | func NewStatic(id, secret, token string, signerType SignatureType) *Credentials { | ||
43 | return New(&Static{ | ||
44 | Value: Value{ | ||
45 | AccessKeyID: id, | ||
46 | SecretAccessKey: secret, | ||
47 | SessionToken: token, | ||
48 | SignerType: signerType, | ||
49 | }, | ||
50 | }) | ||
51 | } | ||
52 | |||
53 | // Retrieve returns the static credentials. | ||
54 | func (s *Static) Retrieve() (Value, error) { | ||
55 | if s.AccessKeyID == "" || s.SecretAccessKey == "" { | ||
56 | // Anonymous is not an error | ||
57 | return Value{SignerType: SignatureAnonymous}, nil | ||
58 | } | ||
59 | return s.Value, nil | ||
60 | } | ||
61 | |||
62 | // IsExpired returns if the credentials are expired. | ||
63 | // | ||
64 | // For Static, the credentials never expired. | ||
65 | func (s *Static) IsExpired() bool { | ||
66 | return false | ||
67 | } | ||