aboutsummaryrefslogtreecommitdiff
path: root/garage.go
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-06-24 10:22:17 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-06-24 10:22:17 +0200
commite940996f0f8cb8c6adb22c7d8780e364d65ecea2 (patch)
tree7cdc6db520293ea1623b07fd68eff6a595d0e0e3 /garage.go
parenta7edf6d1ba812f11b7711c4bdc6dc6d9af9c7906 (diff)
downloadguichet-e940996f0f8cb8c6adb22c7d8780e364d65ecea2.tar.gz
guichet-e940996f0f8cb8c6adb22c7d8780e364d65ecea2.zip
generate a per-website dedicated key
Diffstat (limited to 'garage.go')
-rw-r--r--garage.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/garage.go b/garage.go
index 52a26b0..fabd6bf 100644
--- a/garage.go
+++ b/garage.go
@@ -44,6 +44,17 @@ func grgGetKey(accessKey string) (*garage.KeyInfo, error) {
return resp, nil
}
+func grgSearchKey(name string) (*garage.KeyInfo, error) {
+ client, ctx := gadmin()
+
+ resp, _, err := client.KeyApi.GetKey(ctx).Search(name).ShowSecretKey("true").Execute()
+ if err != nil {
+ fmt.Printf("%+v\n", err)
+ return nil, err
+ }
+ return resp, nil
+}
+
func grgCreateBucket(bucket string) (*garage.BucketInfo, error) {
client, ctx := gadmin()
@@ -59,14 +70,14 @@ func grgCreateBucket(bucket string) (*garage.BucketInfo, error) {
return binfo, nil
}
-func grgAllowKeyOnBucket(bid, gkey string) (*garage.BucketInfo, error) {
+func grgAllowKeyOnBucket(bid, gkey string, read, write, owner bool) (*garage.BucketInfo, error) {
client, ctx := gadmin()
// Allow user's key
ar := garage.AllowBucketKeyRequest{
BucketId: bid,
AccessKeyId: gkey,
- Permissions: *garage.NewAllowBucketKeyRequestPermissions(true, true, true),
+ Permissions: *garage.NewAllowBucketKeyRequestPermissions(read, write, owner),
}
binfo, _, err := client.BucketApi.AllowBucketKey(ctx).AllowBucketKeyRequest(ar).Execute()
if err != nil {