From 9debaa1fc00762665181895b5632c2a4f2b48487 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 30 Dec 2024 10:00:12 +0100 Subject: [PATCH] assuming-long-roleidnames + object-uuid-based-rolenames (#139) Co-authored-by: Michael Hoennig Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/139 Reviewed-by: Timotheus Pokorra --- bin/cas-curl | 120 ++++++++++++++--- .../hsadminng/context/Context.java | 2 +- .../HsOfficeRelationRbacRepository.java | 18 +-- .../HsOfficeRelationRealRepository.java | 63 +++++++-- .../db/changelog/0-base/010-context.sql | 6 +- .../db/changelog/1-rbac/1050-rbac-base.sql | 12 +- .../db/changelog/1-rbac/1054-rbac-context.sql | 15 ++- .../5028-hs-office-person-test-data.sql | 3 +- .../5038-hs-office-relation-test-data.sql | 6 +- .../5048-hs-office-partner-test-data.sql | 2 +- .../5058-hs-office-bankaccount-test-data.sql | 4 +- .../5068-hs-office-debitor-test-data.sql | 2 +- ...ceBankAccountControllerAcceptanceTest.java | 2 +- ...eBankAccountRepositoryIntegrationTest.java | 2 +- ...OfficeDebitorControllerAcceptanceTest.java | 6 +- ...fficeDebitorRepositoryIntegrationTest.java | 2 +- ...OfficePartnerControllerAcceptanceTest.java | 2 +- ...fficePartnerRepositoryIntegrationTest.java | 2 +- ...cePersonRbacRepositoryIntegrationTest.java | 8 +- ...cePersonRealRepositoryIntegrationTest.java | 8 +- ...RealRelationRepositoryIntegrationTest.java | 8 +- ...fficeRelationControllerAcceptanceTest.java | 2 +- ...ficeRelationRepositoryIntegrationTest.java | 127 ++++++++++++------ ...ceSepaMandateControllerAcceptanceTest.java | 2 +- .../rbac/context/ContextUnitTest.java | 2 +- .../RbacRoleRepositoryIntegrationTest.java | 2 +- 26 files changed, 301 insertions(+), 127 deletions(-) diff --git a/bin/cas-curl b/bin/cas-curl index 41427a41..45fa22dd 100755 --- a/bin/cas-curl +++ b/bin/cas-curl @@ -1,14 +1,10 @@ #!/bin/bash -if [ "$#" -eq 0 ] || [ "$1" == "help" ] || [ "$1" == "--help" ] || [ "$1" == "-h" ]; then - cat <> [parameters] - - commands: -EOF - grep '") ''# ' $0 - exit +if [ "$2" == "--show-password" ]; then + HSADMINNG_CAS_SHOW_PASSWORD=yes + shift +else + HSADMINNG_CAS_SHOW_PASSWORD= fi if [ "$1" == "--trace" ]; then @@ -17,7 +13,10 @@ if [ "$1" == "--trace" ]; then } function doCurl() { set -x - curl --fail-with-body --header "Authorization: $HSADMINNG_CAS_TICKET" "$@" + curl --fail-with-body \ + --header "Authorization: $HSADMINNG_CAS_TICKET" \ + --header "assumed-roles: $HSADMINNG_CAS_ASSUME" \ + "$@" set +x } shift @@ -30,6 +29,13 @@ else } fi +export HSADMINNG_CAS_ASSUME_HEADER +if [ -f ~/.cas-curl-assume ]; then + HSADMINNG_CAS_ASSUME="$(cat ~/.cas-curl-assume)" +else + HSADMINNG_CAS_ASSUME= +fi + if [ -z "$HSADMINNG_CAS_LOGIN" ] || [ -z "$HSADMINNG_CAS_VALIDATE" ] || \ [ -z "$HSADMINNG_CAS_SERVICE_ID" ]; then cat >&2 <> [parameters] + + commands: +EOF + # filters out help texts (containing double-# and following lines with leading single-#) from the commands itself + # (the '' makes sure that this line is not found, just the lines with actual help texts) + sed -n '/#''#/ {x; p; x; s/#''#//; p; :a; n; /^[[:space:]]*#/!b; s/^[[:space:]]*#//; p; ba}' <$0 } function casLogin() { @@ -63,10 +77,16 @@ function casLogin() { read -s -e -p "Password: " HSADMINNG_CAS_PASSWORD fi + if [ "$HSADMINNG_CAS_SHOW_PASSWORD" == "--show-password" ]; then + HSADMINNG_CAS_PASSWORD_DISPLAY=$HSADMINNG_CAS_PASSWORD + else + HSADMINNG_CAS_PASSWORD_DISPLAY="<