-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSHARP-4610: OIDC: Automatic token acquisition for GCP Identity Provi…
…der (#1315)
- Loading branch information
1 parent
757a238
commit 9392310
Showing
13 changed files
with
364 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Don't trace since the URI contains a password that shouldn't show up in the logs | ||
set -o errexit # Exit the script with error if any of the commands fail | ||
|
||
DOTNET_SDK_PATH="$(pwd)/.dotnet" | ||
|
||
echo "Downloading .NET SDK installer into $DOTNET_SDK_PATH folder..." | ||
curl -Lfo ./dotnet-install.sh https://dot.net/v1/dotnet-install.sh | ||
echo "Installing .NET LTS SDK..." | ||
bash ./dotnet-install.sh --channel 6.0 --install-dir "$DOTNET_SDK_PATH" --no-path | ||
export PATH=$DOTNET_SDK_PATH:$PATH | ||
|
||
if [ "$OIDC_ENV" == "azure" ]; then | ||
source ./env.sh | ||
TOKEN_RESOURCE="$AZUREOIDC_RESOURCE" | ||
elif [ "$OIDC_ENV" == "gcp" ]; then | ||
source ./secrets-export.sh | ||
TOKEN_RESOURCE="$GCPOIDC_AUDIENCE" | ||
else | ||
echo "Unrecognized OIDC_ENV $OIDC_ENV" | ||
exit 1 | ||
fi | ||
|
||
if [[ "$MONGODB_URI" =~ ^mongodb:.* ]]; then | ||
MONGODB_URI="mongodb://${OIDC_ADMIN_USER}:${OIDC_ADMIN_PWD}@${MONGODB_URI:10}?authSource=admin" | ||
elif [[ "$MONGODB_URI" =~ ^mongodb\+srv:.* ]]; then | ||
MONGODB_URI="mongodb+srv://${OIDC_ADMIN_USER}:${OIDC_ADMIN_PWD}@${MONGODB_URI:14}?authSource=admin" | ||
else | ||
echo "Unexpected MONGODB_URI format: $MONGODB_URI" | ||
exit 1 | ||
fi | ||
|
||
dotnet test --no-build --framework net6.0 --filter Category=MongoDbOidc -e OIDC_ENV="$OIDC_ENV" -e TOKEN_RESOURCE="$TOKEN_RESOURCE" -e MONGODB_URI="$MONGODB_URI" --results-directory ./build/test-results --logger "console;verbosity=detailed" ./tests/**/*.Tests.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.