[#84] Port targets for issuing credentials
All checks were successful
DCO action / DCO (pull_request) Successful in 46s

Signed-off-by: Nikita Zinkevich <n.zinkevich@yadro.com>
This commit is contained in:
Nikita Zinkevich 2024-09-30 17:04:11 +03:00
parent d0c32731f2
commit fc39619f6b
5 changed files with 61 additions and 0 deletions

View file

@ -60,6 +60,7 @@ get: $(foreach SVC, $(GET_SVCS), get.$(SVC))
.PHONY: up
up: up/basic
@$(foreach SVC, $(START_SVCS), $(shell docker-compose -f services/$(SVC)/docker-compose.yml up -d))
./vendor/frostfs-adm morph proxy-add-account --config frostfs-adm.yml --account NYpbUf3vVDfaL1UyiUxwEfR6dtrZSBztis || die "Couldn't set s3-gw wallet as proxy wallet"
@echo "Full FrostFS Developer Environment is ready"
# Build up FrostFS

View file

@ -13,10 +13,12 @@ services:
ipv4_address: ${IPV4_PREFIX}.82
volumes:
- ./wallet.json:/wallet.json
- ./user_wallet.json:/user_wallet.json
- ./tls.key:/tls.key
- ./tls.crt:/tls.crt
- ./../../vendor/hosts:/etc/hosts
- ./cfg:/etc/frostfs/s3
- ./issue-creds.sh:/usr/bin/issue-creds.sh
stop_signal: SIGTERM
stop_grace_period: 15s
env_file: [ ".env", ".s3.env", ".int_test.env" ]
@ -34,6 +36,7 @@ services:
- S3_GW_PEERS_2_WEIGHT=0.2
- S3_GW_PEERS_3_ADDRESS=s04.${LOCAL_DOMAIN}:8080
- S3_GW_PEERS_3_WEIGHT=0.2
- AUTHMATE_WALLET_CONTRACT_PASSPHRASE=s3
networks:
s3_gate_int:

39
services/s3_gate/issue-creds.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
initUser() {
/bin/frostfs-s3-authmate register-user \
--wallet $WALLET_PATH \
--rpc-endpoint http://morph-chain.frostfs.devenv:30333 \
--username $USERNAME \
--contract-wallet /wallet.json 1> /dev/null && touch $WALLET_CACHE/$USERNAME
}
issueAWS() {
/bin/frostfs-s3-authmate issue-secret \
--wallet $WALLET_PATH \
--peer s01.frostfs.devenv:8080 \
--gate-public-key $S3_GATE_PUBLIC_KEY \
--container-placement-policy "REP 1"
}
WALLET_PATH=/$2
if [[ -z "$2" ]]; then
WALLET_PATH=/user_wallet.json
fi
S3_GATE_PUBLIC_KEY=$3
if [[ -z "$3" ]]; then
S3_GATE_PUBLIC_KEY=0204507e99f918e343046c382dfdb4564c616bc9ad6b2fe26b08f4b2b666c58ce9
fi
WALLET_CACHE=/data/wallets
mkdir -p $WALLET_CACHE
USERNAME=$(echo $WALLET_PATH | md5sum | cut -d' ' -f1)
if [ ! -e $WALLET_CACHE/$USERNAME ]; then
initUser
fi
if [ $1 == "s3" ]; then
issueAWS
fi

View file

@ -0,0 +1,17 @@
.PHONY: s3cred s3cred-custom cred cred-custom
# Generate S3 credentials
s3cred:
@docker exec -it s3_gate /usr/bin/issue-creds.sh s3
# Generate S3 credentials based on imported wallets
s3cred-custom:
@docker exec -it s3_gate /usr/bin/issue-creds.sh s3 $(wallet)
# Register user-wallet.json in FrostFS ID contract
cred:
@docker exec -it s3_gate /usr/bin/issue-creds.sh native $(gate_public_key)
# Register custom wallet in FrostFS ID contract
cred-custom:
@docker exec -it s3_gate /usr/bin/issue-creds.sh native $(wallet) $(gate_public_key)

View file

@ -0,0 +1 @@
{"version":"1.0","accounts":[{"address":"NQjbiXuAoZHCifBJ9H1TQ7SPQA3EzdA1Mr","key":"6PYVwvn4kpcHD2VedzwcKcFgGYooeiBrWaJdXg1WEag3fzNWMwPKnKDKV4","label":"nikita","contract":{"script":"DCEDzN6yW9sasGL4sGpyAq9I47Ly2b2JjRz0WSqLoW1sIU9BVuezJw==","parameters":[{"name":"parameter0","type":"Signature"}],"deployed":false},"lock":false,"isDefault":false}],"scrypt":{"n":16384,"r":8,"p":8},"extra":{"Tokens":null}}