From 0438608a3efd3fce502088b969c4d3dbf53e4b0a Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 17 Sep 2024 14:19:44 +0300 Subject: [PATCH] [#45] Add Makefile targets to register wallet files in FrostFS ID This is required in frostfs-node since AIO 1.6.0 Signed-off-by: Alex Vanin --- Makefile | 12 ++++++++++-- README.md | 18 ++++++++++++++---- bin/issue-creds.sh | 9 ++++++--- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index dc29730..983f549 100644 --- a/Makefile +++ b/Makefile @@ -63,11 +63,19 @@ clean: down # Generate S3 credentials s3cred: - @docker exec aio /usr/bin/issue-creds.sh + @docker exec aio /usr/bin/issue-creds.sh s3 # Generate S3 credentials based on imported wallets s3cred-custom: - @docker exec aio /usr/bin/issue-creds.sh $(wallet) + @docker exec aio /usr/bin/issue-creds.sh s3 $(wallet) + +# Register user-wallet.json in FrostFS ID contract +cred: + @docker exec aio /usr/bin/issue-creds.sh native + +# Register custom wallet in FrostFS ID contract +cred-custom: + @docker exec aio /usr/bin/issue-creds.sh native $(wallet) enable-oracle: @docker exec aio neo-go contract invokefunction -r http://localhost:30333 \ diff --git a/README.md b/README.md index f71ee17..9ca12ab 100644 --- a/README.md +++ b/README.md @@ -291,13 +291,23 @@ wallet successfully created, file location is /wallets/new-wallet.json ## frostfs-cli interface +### Native credentials + +To use wallet file, it should be register in FrostFS ID contract and have +policies to perform FrostFS operations. + +Use `make cred` to register `s3-gw/user-wallet.json`. For custom wallets from +`wallet` dir, use `make cred-custom wallet=wallet1.json`. + +These commands are similar to `make s3cred` and `make s3cred-custom`. + ### Create container with frostfs-cli ``` sh -$ frostfs-cli -r localhost:8080 -w /config/user-wallet.json \ +$ frostfs-cli -r localhost:8080 -w s3-gw/user-wallet.json \ --address NWeByJPgNC97F83hTUnSbnZSBKaFvk5HNw \ container create \ - --policy "REP 1" --basic-acl public-read-write --await + --policy "REP 1" --await container ID: GfWw35kHds7gKWmSvW7Zi4U39K7NMLK8EfXBQ5FPJA46 awaiting... container has been persisted on sidechain @@ -306,7 +316,7 @@ container has been persisted on sidechain ### Put an object with frostfs-cli ``` sh -$ frostfs-cli -r localhost:8080 -w /config/user-wallet.json \ +$ frostfs-cli -r localhost:8080 -w s3-gw/user-wallet.json \ --address NWeByJPgNC97F83hTUnSbnZSBKaFvk5HNw \ object put \ --cid GfWw35kHds7gKWmSvW7Zi4U39K7NMLK8EfXBQ5FPJA46 \ @@ -319,7 +329,7 @@ $ frostfs-cli -r localhost:8080 -w /config/user-wallet.json \ ### Get and object with frostfs-cli ``` sh -$ frostfs-cli -r localhost:8080 -w /config/user-wallet.json \ +$ frostfs-cli -r localhost:8080 -w s3-gw/user-wallet.json \ --address NWeByJPgNC97F83hTUnSbnZSBKaFvk5HNw \ object get \ --cid GfWw35kHds7gKWmSvW7Zi4U39K7NMLK8EfXBQ5FPJA46 \ diff --git a/bin/issue-creds.sh b/bin/issue-creds.sh index 7c08dc5..74195b7 100755 --- a/bin/issue-creds.sh +++ b/bin/issue-creds.sh @@ -17,8 +17,8 @@ issueAWS() { } S3_GATE_PUBLIC_KEY=$(neo-go wallet dump-keys -w /config/s3-gw-wallet.json | tail -1) -WALLET_PATH=/wallets/$1 -if [[ -z "$1" ]]; then +WALLET_PATH=/wallets/$2 +if [[ -z "$2" ]]; then WALLET_PATH=/config/user-wallet.json fi @@ -29,4 +29,7 @@ USERNAME=$(echo $WALLET_PATH | md5sum | cut -d' ' -f1) if [ ! -e $WALLET_CACHE/$USERNAME ]; then initUser fi -issueAWS + +if [ $1 == "s3" ]; then + issueAWS +fi