Skip to content

Commit

Permalink
Fix auzre arc managed identity (Azure#37736)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbordier authored Nov 23, 2023
1 parent fe469af commit 1c3fad0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions sdk/identity/azure-identity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Breaking Changes

### Bugs Fixed
- fixed Azure Arc Managed Identiy not being retrived because of a code logic bug (misplaced finally block)

### Other Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ private Mono<AccessToken> authenticateToArcManagedIdentityEndpoint(String identi
+ " Unauthorized response from Azure Arc Managed Identity Endpoint, received: %d", status),
null, e));
}

} finally {
String realm = connection.getHeaderField("WWW-Authenticate");

if (realm == null) {
Expand All @@ -946,17 +946,17 @@ private Mono<AccessToken> authenticateToArcManagedIdentityEndpoint(String identi
String secretKeyPath = realm.substring(separatorIndex + 1);
secretKey = new String(Files.readAllBytes(Paths.get(secretKeyPath)), StandardCharsets.UTF_8);

} finally {

if (connection != null) {
connection.disconnect();
}
}

if (secretKey == null) {
throw LOGGER.logExceptionAsError(new ClientAuthenticationException("Did not receive a secret value"
+ " in the response from Azure Arc Managed Identity Endpoint",
null));
}

if (secretKey == null) {
throw LOGGER.logExceptionAsError(new ClientAuthenticationException("Did not receive a secret value"
+ " in the response from Azure Arc Managed Identity Endpoint",
null));
}


Expand Down

0 comments on commit 1c3fad0

Please sign in to comment.