diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-06-24 10:22:17 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-06-24 10:22:17 +0200 |
commit | e940996f0f8cb8c6adb22c7d8780e364d65ecea2 (patch) | |
tree | 7cdc6db520293ea1623b07fd68eff6a595d0e0e3 /garage.go | |
parent | a7edf6d1ba812f11b7711c4bdc6dc6d9af9c7906 (diff) | |
download | guichet-e940996f0f8cb8c6adb22c7d8780e364d65ecea2.tar.gz guichet-e940996f0f8cb8c6adb22c7d8780e364d65ecea2.zip |
generate a per-website dedicated key
Diffstat (limited to 'garage.go')
-rw-r--r-- | garage.go | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -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 { |