diff --git a/sdk/identity/identity/CHANGELOG.md b/sdk/identity/identity/CHANGELOG.md index dbce12deb454..4006cdbbd966 100644 --- a/sdk/identity/identity/CHANGELOG.md +++ b/sdk/identity/identity/CHANGELOG.md @@ -40,7 +40,7 @@ async function main() { Identity v2 includes three new credential types: - `AzurePowerShellCredential`, which re-uses any account previously authenticated with the `Az.Account` PowerShell module. -- `ApplicationCredential`, which is a simplified `DefaultAzureCredential` that only includes `EnvironmentCredential` and `ManagedIdentityCredential`. +- `AzureApplicationCredential`, which is a simplified `DefaultAzureCredential` that only includes `EnvironmentCredential` and `ManagedIdentityCredential`. - `OnBehalfOfCredential`, which enables the [On-Behalf-Of authentication flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow). #### New features in all credentials diff --git a/sdk/identity/identity/recordings/node/applicationcredential/recording_authenticates_with_a_client_secret_on_the_environment_variables.js b/sdk/identity/identity/recordings/node/azureapplicationcredential/recording_authenticates_with_a_client_secret_on_the_environment_variables.js similarity index 100% rename from sdk/identity/identity/recordings/node/applicationcredential/recording_authenticates_with_a_client_secret_on_the_environment_variables.js rename to sdk/identity/identity/recordings/node/azureapplicationcredential/recording_authenticates_with_a_client_secret_on_the_environment_variables.js diff --git a/sdk/identity/identity/recordings/node/applicationcredential/recording_supports_tracing_with_environment_client_secret.js b/sdk/identity/identity/recordings/node/azureapplicationcredential/recording_supports_tracing_with_environment_client_secret.js similarity index 100% rename from sdk/identity/identity/recordings/node/applicationcredential/recording_supports_tracing_with_environment_client_secret.js rename to sdk/identity/identity/recordings/node/azureapplicationcredential/recording_supports_tracing_with_environment_client_secret.js diff --git a/sdk/identity/identity/recordings/node/applicationcredential/recording_throws_an_aggregateauthenticationerror_when_gettoken_is_called_and_no_credential_was_configured.js b/sdk/identity/identity/recordings/node/azureapplicationcredential/recording_throws_an_aggregateauthenticationerror_when_gettoken_is_called_and_no_credential_was_configured.js similarity index 100% rename from sdk/identity/identity/recordings/node/applicationcredential/recording_throws_an_aggregateauthenticationerror_when_gettoken_is_called_and_no_credential_was_configured.js rename to sdk/identity/identity/recordings/node/azureapplicationcredential/recording_throws_an_aggregateauthenticationerror_when_gettoken_is_called_and_no_credential_was_configured.js diff --git a/sdk/identity/identity/recordings/node/applicationcredential/recording_throws_an_authenticationerror_when_gettoken_is_called_and_applicationcredential_authentication_failed.js b/sdk/identity/identity/recordings/node/azureapplicationcredential/recording_throws_an_authenticationerror_when_gettoken_is_called_and_azureapplicationcredential_authentication_failed.js similarity index 100% rename from sdk/identity/identity/recordings/node/applicationcredential/recording_throws_an_authenticationerror_when_gettoken_is_called_and_applicationcredential_authentication_failed.js rename to sdk/identity/identity/recordings/node/azureapplicationcredential/recording_throws_an_authenticationerror_when_gettoken_is_called_and_azureapplicationcredential_authentication_failed.js diff --git a/sdk/identity/identity/review/identity.api.md b/sdk/identity/identity/review/identity.api.md index 23dc2f505f72..21e176820158 100644 --- a/sdk/identity/identity/review/identity.api.md +++ b/sdk/identity/identity/review/identity.api.md @@ -21,16 +21,6 @@ export class AggregateAuthenticationError extends Error { // @public export const AggregateAuthenticationErrorName = "AggregateAuthenticationError"; -// @public -export class ApplicationCredential extends ChainedTokenCredential { - constructor(options?: ApplicationCredentialOptions); -} - -// @public -export interface ApplicationCredentialOptions extends TokenCredentialOptions, CredentialPersistenceOptions { - managedIdentityClientId?: string; -} - // @public export class AuthenticationError extends Error { constructor(statusCode: number, errorBody: object | string | undefined | null); @@ -66,6 +56,16 @@ export class AuthorizationCodeCredential implements TokenCredential { getToken(scopes: string | string[], options?: GetTokenOptions): Promise; } +// @public +export class AzureApplicationCredential extends ChainedTokenCredential { + constructor(options?: AzureApplicationCredentialOptions); +} + +// @public +export interface AzureApplicationCredentialOptions extends TokenCredentialOptions, CredentialPersistenceOptions { + managedIdentityClientId?: string; +} + // @public export enum AzureAuthorityHosts { AzureChina = "https://login.chinacloudapi.cn", diff --git a/sdk/identity/identity/src/index.ts b/sdk/identity/identity/src/index.ts index 74fe2bd333fa..8348225dddf6 100644 --- a/sdk/identity/identity/src/index.ts +++ b/sdk/identity/identity/src/index.ts @@ -53,8 +53,8 @@ export { AuthorizationCodeCredential } from "./credentials/authorizationCodeCred export { AzurePowerShellCredential } from "./credentials/azurePowerShellCredential"; export { AzurePowerShellCredentialOptions } from "./credentials/azurePowerShellCredentialOptions"; export { - AzureApplicationCredential as ApplicationCredential, - AzureApplicationCredentialOptions as ApplicationCredentialOptions + AzureApplicationCredential, + AzureApplicationCredentialOptions } from "./credentials/azureApplicationCredential"; export { diff --git a/sdk/identity/identity/test/internal/node/applicationCredential.spec.ts b/sdk/identity/identity/test/internal/node/azureApplicationCredential.spec.ts similarity index 91% rename from sdk/identity/identity/test/internal/node/applicationCredential.spec.ts rename to sdk/identity/identity/test/internal/node/azureApplicationCredential.spec.ts index 9059c4d2f512..4ee0220d33e6 100644 --- a/sdk/identity/identity/test/internal/node/applicationCredential.spec.ts +++ b/sdk/identity/identity/test/internal/node/azureApplicationCredential.spec.ts @@ -3,7 +3,7 @@ import { assert } from "chai"; import { RestError } from "@azure/core-rest-pipeline"; -import { ApplicationCredential } from "../../../src"; +import { AzureApplicationCredential } from "../../../src"; import { prepareIdentityTests } from "../../httpRequests"; import { createResponse, @@ -11,7 +11,7 @@ import { SendCredentialRequests } from "../../httpRequestsCommon"; -describe("ApplicationCredential testing Managed Identity (internal)", function() { +describe("AzureApplicationCredential testing Managed Identity (internal)", function() { let envCopy: string = ""; let testContext: IdentityTestContext; let sendCredentialRequests: SendCredentialRequests; @@ -39,7 +39,7 @@ describe("ApplicationCredential testing Managed Identity (internal)", function() const { error } = await sendCredentialRequests({ scopes: ["scopes"], - credential: new ApplicationCredential(), + credential: new AzureApplicationCredential(), insecureResponses: [ { error: new RestError("Request Timeout", { code: "REQUEST_SEND_ERROR", statusCode: 408 }) @@ -59,7 +59,7 @@ describe("ApplicationCredential testing Managed Identity (internal)", function() const { error } = await sendCredentialRequests({ scopes: ["scopes"], - credential: new ApplicationCredential(), + credential: new AzureApplicationCredential(), insecureResponses: [ createResponse(200), // IMDS Endpoint ping { error: new RestError(errorMessage, { statusCode: 500 }) } @@ -78,7 +78,7 @@ describe("ApplicationCredential testing Managed Identity (internal)", function() const { error } = await sendCredentialRequests({ scopes: ["scopes"], - credential: new ApplicationCredential(), + credential: new AzureApplicationCredential(), insecureResponses: [ createResponse(200), // IMDS Endpoint ping { error: netError } @@ -95,7 +95,7 @@ describe("ApplicationCredential testing Managed Identity (internal)", function() const authDetails = await sendCredentialRequests({ scopes: ["https://service/.default"], - credential: new ApplicationCredential(), + credential: new AzureApplicationCredential(), secureResponses: [ createResponse(200, { access_token: "token", diff --git a/sdk/identity/identity/test/public/node/applicationCredential.spec.ts b/sdk/identity/identity/test/public/node/azureApplicationCredential.spec.ts similarity index 89% rename from sdk/identity/identity/test/public/node/applicationCredential.spec.ts rename to sdk/identity/identity/test/public/node/azureApplicationCredential.spec.ts index bbe1e222b404..304ce8d8e785 100644 --- a/sdk/identity/identity/test/public/node/applicationCredential.spec.ts +++ b/sdk/identity/identity/test/public/node/azureApplicationCredential.spec.ts @@ -2,12 +2,12 @@ // Licensed under the MIT license. import { assert } from "chai"; -import { ApplicationCredential } from "../../../src"; +import { AzureApplicationCredential } from "../../../src"; import { MsalTestCleanup, msalNodeTestSetup, testTracing } from "../../msalTestUtils"; import { getError } from "../../authTestUtils"; import { Context } from "mocha"; -describe("ApplicationCredential", function() { +describe("AzureApplicationCredential", function() { let cleanup: MsalTestCleanup; const environmentVariableNames = ["AZURE_TENANT_ID", "AZURE_CLIENT_ID", "AZURE_CLIENT_SECRET"]; const cachedValues: Record = {}; @@ -36,7 +36,7 @@ describe("ApplicationCredential", function() { process.env.AZURE_CLIENT_ID = cachedValues.AZURE_CLIENT_ID; process.env.AZURE_CLIENT_SECRET = cachedValues.AZURE_CLIENT_SECRET; - const credential = new ApplicationCredential(); + const credential = new AzureApplicationCredential(); const token = await credential.getToken(scope); assert.ok(token?.token); @@ -53,7 +53,7 @@ describe("ApplicationCredential", function() { process.env.AZURE_CLIENT_ID = cachedValues.AZURE_CLIENT_ID; process.env.AZURE_CLIENT_SECRET = cachedValues.AZURE_CLIENT_SECRET; - const credential = new ApplicationCredential(); + const credential = new AzureApplicationCredential(); await credential.getToken(scope, { tracingOptions @@ -79,19 +79,19 @@ describe("ApplicationCredential", function() { ); it("throws an AggregateAuthenticationError when getToken is called and no credential was configured", async () => { - const credential = new ApplicationCredential(); + const credential = new AzureApplicationCredential(); const error = await getError(credential.getToken(scope)); assert.equal(error.name, "AggregateAuthenticationError"); assert.ok(error.message.indexOf(`CredentialUnavailableError: EnvironmentCredential`) > -1); assert.ok(error.message.indexOf(`CredentialUnavailableError: ManagedIdentityCredential`) > -1); }); - it("throws an AuthenticationError when getToken is called and ApplicationCredential authentication failed", async () => { + it("throws an AuthenticationError when getToken is called and AzureApplicationCredential authentication failed", async () => { process.env.AZURE_TENANT_ID = "tenant"; process.env.AZURE_CLIENT_ID = "client"; process.env.AZURE_CLIENT_SECRET = "secret"; - const credential = new ApplicationCredential(); + const credential = new AzureApplicationCredential(); const error = await getError(credential.getToken(scope)); assert.equal(error.name, "AuthenticationError");