mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-04-29 17:42:44 +00:00
Merge pull request #6283 from tklk-forks/azure-managed-identities-endpoint
Azure: Use endpoint environment variable for managed identities if set
This commit is contained in:
commit
bed1c311e3
@ -340,8 +340,17 @@ _azure_getaccess_token() {
|
|||||||
|
|
||||||
if [ "$managedIdentity" = true ]; then
|
if [ "$managedIdentity" = true ]; then
|
||||||
# https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-http
|
# https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-http
|
||||||
export _H1="Metadata: true"
|
if [ -n "$IDENTITY_ENDPOINT" ]; then
|
||||||
response="$(_get http://169.254.169.254/metadata/identity/oauth2/token\?api-version=2018-02-01\&resource=https://management.azure.com/)"
|
# Some Azure environments may set IDENTITY_ENDPOINT (formerly MSI_ENDPOINT) to have an alternative metadata endpoint
|
||||||
|
url="$IDENTITY_ENDPOINT?api-version=2019-08-01&resource=https://management.azure.com/"
|
||||||
|
headers="X-IDENTITY-HEADER: $IDENTITY_HEADER"
|
||||||
|
else
|
||||||
|
url="http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/"
|
||||||
|
headers="Metadata: true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export _H1="$headers"
|
||||||
|
response="$(_get "$url")"
|
||||||
response="$(echo "$response" | _normalizeJson)"
|
response="$(echo "$response" | _normalizeJson)"
|
||||||
accesstoken=$(echo "$response" | _egrep_o "\"access_token\":\"[^\"]*\"" | _head_n 1 | cut -d : -f 2 | tr -d \")
|
accesstoken=$(echo "$response" | _egrep_o "\"access_token\":\"[^\"]*\"" | _head_n 1 | cut -d : -f 2 | tr -d \")
|
||||||
expires_on=$(echo "$response" | _egrep_o "\"expires_on\":\"[^\"]*\"" | _head_n 1 | cut -d : -f 2 | tr -d \")
|
expires_on=$(echo "$response" | _egrep_o "\"expires_on\":\"[^\"]*\"" | _head_n 1 | cut -d : -f 2 | tr -d \")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user