-
Notifications
You must be signed in to change notification settings - Fork 862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct IMDS resource ID query parameter #22650
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,14 +34,14 @@ const ( | |
identityServerThumbprint = "IDENTITY_SERVER_THUMBPRINT" | ||
headerMetadata = "Metadata" | ||
imdsEndpoint = "http://169.254.169.254/metadata/identity/oauth2/token" | ||
miResID = "mi_res_id" | ||
msiEndpoint = "MSI_ENDPOINT" | ||
msiResID = "msi_res_id" | ||
msiSecret = "MSI_SECRET" | ||
imdsAPIVersion = "2018-02-01" | ||
azureArcAPIVersion = "2019-08-15" | ||
qpClientID = "client_id" | ||
serviceFabricAPIVersion = "2019-07-01-preview" | ||
|
||
qpClientID = "client_id" | ||
qpResID = "mi_res_id" | ||
) | ||
|
||
type msiType int | ||
|
@@ -286,7 +286,7 @@ func (c *managedIdentityClient) createIMDSAuthRequest(ctx context.Context, id Ma | |
q.Add("resource", strings.Join(scopes, " ")) | ||
if id != nil { | ||
if id.idKind() == miResourceID { | ||
q.Add(qpResID, id.String()) | ||
q.Add(msiResID, id.String()) | ||
} else { | ||
q.Add(qpClientID, id.String()) | ||
} | ||
|
@@ -306,7 +306,7 @@ func (c *managedIdentityClient) createAppServiceAuthRequest(ctx context.Context, | |
q.Add("resource", scopes[0]) | ||
if id != nil { | ||
if id.idKind() == miResourceID { | ||
q.Add(qpResID, id.String()) | ||
q.Add(miResID, id.String()) | ||
} else { | ||
q.Add(qpClientID, id.String()) | ||
} | ||
|
@@ -329,7 +329,7 @@ func (c *managedIdentityClient) createAzureMLAuthRequest(ctx context.Context, id | |
if id.idKind() == miResourceID { | ||
log.Write(EventAuthentication, "WARNING: Azure ML doesn't support specifying a managed identity by resource ID") | ||
q.Set("clientid", "") | ||
q.Set(qpResID, id.String()) | ||
q.Set(miResID, id.String()) | ||
} else { | ||
q.Set("clientid", id.String()) | ||
} | ||
|
@@ -351,7 +351,7 @@ func (c *managedIdentityClient) createServiceFabricAuthRequest(ctx context.Conte | |
if id != nil { | ||
log.Write(EventAuthentication, "WARNING: Service Fabric doesn't support selecting a user-assigned identity at runtime") | ||
if id.idKind() == miResourceID { | ||
q.Add(qpResID, id.String()) | ||
q.Add(miResID, id.String()) | ||
} else { | ||
q.Add(qpClientID, id.String()) | ||
} | ||
|
@@ -411,7 +411,7 @@ func (c *managedIdentityClient) createAzureArcAuthRequest(ctx context.Context, i | |
if id != nil { | ||
log.Write(EventAuthentication, "WARNING: Azure Arc doesn't support user-assigned managed identities") | ||
if id.idKind() == miResourceID { | ||
q.Add(qpResID, id.String()) | ||
q.Add(miResID, id.String()) | ||
} else { | ||
q.Add(qpClientID, id.String()) | ||
} | ||
|
@@ -437,7 +437,7 @@ func (c *managedIdentityClient) createCloudShellAuthRequest(ctx context.Context, | |
log.Write(EventAuthentication, "WARNING: Cloud Shell doesn't support user-assigned managed identities") | ||
q := request.Raw().URL.Query() | ||
if id.idKind() == miResourceID { | ||
q.Add(qpResID, id.String()) | ||
q.Add(miResID, id.String()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most places seem to keep using the mi string, instead of msi, but the PR description is implying we should convege and only use msi. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need both. We should use "msi_res_id" for IMDS (and implicitly, anything resembling IMDS). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, this was interesting. The App Service doc was changed after we implemented this feature because a reader saw that other APIs use |
||
} else { | ||
q.Add(qpClientID, id.String()) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come this is still needed (in what scenarios)?
I can't easily tell from the logic below where we'd use this one vs the MSI one.
Both seem to be wrapped around
if id.idKind() == miResourceID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need this for App Service. Each platform we support has a different API, so the query parameter we need to set depends on the platform.
id
in the line you pasted is the value of the parameter i.e. the resource ID.