Skip to content

Commit

Permalink
Merge pull request #61 from RobertCroteau/bug_certsample
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
petrsnd authored Mar 15, 2023
2 parents 817cbcd + 6a20548 commit aa51c2a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
8 changes: 4 additions & 4 deletions samples/certificate-login/certificate-login.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ echo -e "${YELLOW}\nInstalling intermediate ca...${NC}"
$SafeguardDir/install-trusted-certificate.sh -C $IssuingCertFile

echo -e "${YELLOW}\nAdding certificate user named $UserName...${NC}"
$SafeguardDir/invoke-safeguard-method.sh -s core -m POST -U Users -b "{
\"PrimaryAuthenticationProviderId\": -2,
\"UserName\": \"$UserName\",
\"PrimaryAuthenticationIdentity\": \"$Thumbprint\"
$SafeguardDir/invoke-safeguard-method.sh -v 4 -s core -m POST -U Users -b "{
\"PrimaryAuthenticationProvider\": {\"Id\":-2, \"Identity\":\"$Thumbprint\"},
\"IdentityProvider\": {\"Id\": -1},
\"Name\": \"$UserName\"
}"

echo -e "${YELLOW}\nLogging out as user admin ($Provider/$AdminUser)...${NC}"
Expand Down
20 changes: 9 additions & 11 deletions samples/event-handling/a2a-event-handling/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,8 @@ echo -e "${YELLOW}\nInstalling intermediate ca...${NC}"
$SafeguardDir/install-trusted-certificate.sh -C $IssuingCertFile

echo -e "${YELLOW}\nAdding certificate user named $CertUserName...${NC}"
Result=$($SafeguardDir/invoke-safeguard-method.sh -s core -m POST -U Users -N -b "{
\"PrimaryAuthenticationProviderId\": -2,
\"UserName\": \"$CertUserName\",
\"PrimaryAuthenticationIdentity\": \"$Thumbprint\"
}")
Result=$($SafeguardDir/invoke-safeguard-method.sh -v 4 -s core -m POST -U Users -N -b "
{ \"Name\":\"$CertUserName\", \"IdentityProvider\": {\"Id\": -1}, \"PrimaryAuthenticationProvider\": {\"Id\":-2, \"Identity\":\"$Thumbprint\"} }")
Error=$(echo $Result | jq .Code 2> /dev/null)
echo $Result | jq .
if [ -z "$Error" -o "$Error" = "null" ]; then
Expand All @@ -109,10 +106,11 @@ else
fi

echo -e "${YELLOW}\nAdding setup user named $SetupUserName...${NC}"
Result=$($SafeguardDir/invoke-safeguard-method.sh -s core -m POST -U Users -N -b "{
\"PrimaryAuthenticationProviderId\": -1,
\"UserName\": \"$SetupUserName\",
\"AdminRoles\": [\"PolicyAdmin\",\"AssetAdmin\"]
Result=$($SafeguardDir/invoke-safeguard-method.sh -v 4 -s core -m POST -U Users -N -b "{
\"Name\":\"$SetupUserName\",
\"IdentityProvider\": {\"Id\": -1},
\"PrimaryAuthenticationProvider\": {\"Id\":-1},
\"AdminRoles\": [\"PolicyAdmin\",\"AssetAdmin\"]
}")
Error=$(echo $Result | jq .Code 2> /dev/null)
echo $Result | jq .
Expand Down Expand Up @@ -147,8 +145,8 @@ echo $Result | jq .
if [ -z "$Error" -o "$Error" = "null" ]; then
AssetId=$(echo $Result | jq .Id)
echo -e "${YELLOW}\nCreating a test account ($AccountName)...${NC}"
Result=$($SafeguardDir/invoke-safeguard-method.sh -s core -m POST -U AssetAccounts -N -b "{
\"AssetId\": $AssetId,
Result=$($SafeguardDir/invoke-safeguard-method.sh -v 4 -s core -m POST -U AssetAccounts -N -b "{
\"Asset\": { \"Id\": $AssetId },
\"Name\": \"$AccountName\",
\"Description\": \"This should be deleted\"
}")
Expand Down
4 changes: 2 additions & 2 deletions src/listen-for-a2a-event.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Content-Length: 0
EOF
)
echo $TokenResponse | $SED -n -e 's/\+/%2B/g;s/\//%2F/g;s/.*"connectionId":"\([^"]*\)".*/\1/p'
echo $TokenResponse | $SED -n -e 's/\+/%2B/g;s/\//%2F/g;s/.*"connectionToken":"\([^"]*\)".*/\1/p'
else
curl -K <(cat <<EOF
-s
Expand All @@ -101,7 +101,7 @@ $CABundleArg
--pass $Pass
EOF
) "https://$Appliance/service/a2a/signalr/negotiate?negotiateVersion=1" -d '' \
| $SED -n -e 's/\+/%2B/g;s/\//%2F/g;s/.*"connectionId":"\([^"]*\)".*/\1/p'
| $SED -n -e 's/\+/%2B/g;s/\//%2F/g;s/.*"connectionToken":"\([^"]*\)".*/\1/p'
fi
}

Expand Down
2 changes: 1 addition & 1 deletion src/listen-for-event.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ get_connection_token()
{
# this call does not require an authorization header
curl -s $CABundleArg "https://$Appliance/service/event/signalr/negotiate?negotiateVersion=1" -d '' \
| $SED -n -e 's/\+/%2B/g;s/\//%2F/g;s/.*"connectionId":"\([^"]*\)".*/\1/p'
| $SED -n -e 's/\+/%2B/g;s/\//%2F/g;s/.*"connectionToken":"\([^"]*\)".*/\1/p'
}


Expand Down
9 changes: 7 additions & 2 deletions src/new-certificate-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ done

require_args

$ScriptDir/invoke-safeguard-method.sh -a "$Appliance" -T -v $Version -s core -m POST -U "Users" -N -b "
{ \"UserName\":\"$NewUserName\", \"PrimaryAuthenticationProviderId\":-2, \"PrimaryAuthenticationIdentity\":\"$NewUserThumbprint\" }" <<<$AccessToken
if [ $Version -eq 4 ]; then
$ScriptDir/invoke-safeguard-method.sh -a "$Appliance" -T -v $Version -s core -m POST -U "Users" -N -b "
{ \"Name\":\"$NewUserName\", \"IdentityProvider\": {\"Id\": -1}, \"PrimaryAuthenticationProvider\": {\"Id\":-2, \"Identity\":\"$NewUserThumbprint\"} }" <<<$AccessToken
else
$ScriptDir/invoke-safeguard-method.sh -a "$Appliance" -T -v $Version -s core -m POST -U "Users" -N -b "
{ \"UserName\":\"$NewUserName\", \"IdentityProviderId\":-1, \"PrimaryAuthenticationProviderId\":-2, \"PrimaryAuthenticationIdentity\":\"$NewUserThumbprint\" }" <<<$AccessToken
fi

0 comments on commit aa51c2a

Please sign in to comment.