Skip to content

Commit 6f4662d

Browse files
CopilotmawasileCopilotmattdot
authored
Configuration and Constants Issues (#838)
* Initial plan for issue * Fix configuration and constants issues: CAE challenge strings, RX domain constants, and AuxiliaryTenantIDs type safety Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com> * Add changelog entry for configuration and constants fixes Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com> * Update internal/provider/provider.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Revert RX PowerApps Advisor API domain constants to eaglex.ic.gov Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Matt Dotson <mattdot@users.noreply.github.com>
1 parent 62a2def commit 6f4662d

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: fixed
2+
body: 'Fix configuration and constants issues: CAE challenge detection strings, RX PowerApps Advisor API domain constants, and AuxiliaryTenantIDs type safety conversion'
3+
time: 2025-06-05T12:17:43.646455328Z
4+
custom:
5+
Issue: "824"

internal/api/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ func IsCaeChallengeResponse(resp *http.Response) bool {
8383
if resp.StatusCode == http.StatusUnauthorized {
8484
wwwAuthenticate := resp.Header.Get("WWW-Authenticate")
8585
if wwwAuthenticate != "" {
86-
return strings.Contains(wwwAuthenticate, "claims=") &&
87-
strings.Contains(wwwAuthenticate, "insufficient_claims")
86+
return strings.Contains(wwwAuthenticate, constants.CAE_CHALLENGE_CLAIMS_INDICATOR) &&
87+
strings.Contains(wwwAuthenticate, constants.CAE_CHALLENGE_INSUFFICIENT_CLAIMS_INDICATOR)
8888
}
8989
}
9090

internal/constants/constants.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ const (
188188
NO_MANAGEMENT_APPLICATION_ERROR_MSG = "authorization has been denied for this request. Make sure that your service principal is registered as an admin management application: https://learn.microsoft.com/en-us/power-platform/admin/powerplatform-api-create-service-principal#registering-an-admin-management-application"
189189
)
190190

191+
const (
192+
CAE_CHALLENGE_CLAIMS_INDICATOR = "claims="
193+
CAE_CHALLENGE_INSUFFICIENT_CLAIMS_INDICATOR = "insufficient_claims"
194+
)
191195
// Error codes for provider errors.
192196
const (
193197
ERROR_OBJECT_NOT_FOUND = "OBJECT_NOT_FOUND"

internal/provider/provider.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,11 @@ func configureUseMsi(ctx context.Context, p *PowerPlatformProvider, clientId str
355355
// Convert the slice to an array
356356
auxiliaryTenantIDsList := make([]string, len(auxiliaryTenantIDs.Elements()))
357357
for i, v := range auxiliaryTenantIDs.Elements() {
358-
auxiliaryTenantIDsList[i] = v.String()
358+
if str, ok := v.(types.String); ok {
359+
auxiliaryTenantIDsList[i] = str.ValueString()
360+
} else {
361+
tflog.Warn(ctx, fmt.Sprintf("Element at index %d in auxiliaryTenantIDs is not of type types.String. Skipping.", i))
362+
}
359363
}
360364
p.Config.AuxiliaryTenantIDs = auxiliaryTenantIDsList
361365
p.Config.UseMsi = true

0 commit comments

Comments
 (0)