s3tables: align getPrincipalFromRequest with account ID for IAM compatibility
This commit is contained in:
@@ -154,17 +154,14 @@ func (h *S3TablesHandler) HandleRequest(w http.ResponseWriter, r *http.Request,
|
|||||||
// Principal/authorization helpers
|
// Principal/authorization helpers
|
||||||
|
|
||||||
func (h *S3TablesHandler) getPrincipalFromRequest(r *http.Request) string {
|
func (h *S3TablesHandler) getPrincipalFromRequest(r *http.Request) string {
|
||||||
// Prioritize identity from context (set by IAM middleware)
|
// Prefer the authenticated account ID from the request header. This is the same
|
||||||
if identityName := s3_constants.GetIdentityNameFromContext(r); identityName != "" {
|
// identifier used as the "owner" in permission checks, so keeping them aligned
|
||||||
return identityName
|
// avoids mismatches (e.g. username vs. account ID) when IAM is enabled.
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback to the authenticated account ID
|
|
||||||
if accountID := r.Header.Get(s3_constants.AmzAccountId); accountID != "" {
|
if accountID := r.Header.Get(s3_constants.AmzAccountId); accountID != "" {
|
||||||
return accountID
|
return accountID
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default to handler's default account ID
|
// Default to handler's configured account ID
|
||||||
return h.accountID
|
return h.accountID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user