Skip to content
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

[Identity] Migrated to samples v2 #19085

Merged
merged 11 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/identity/identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Key links:
- [Package (npm)](https://www.npmjs.com/package/@azure/identity)
- [API Reference Documentation](https://docs.microsoft.com/javascript/api/@azure/identity)
- [Product documentation](https://azure.microsoft.com/services/active-directory/)
- [Samples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples)
- [Samples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think other versions could be added in the future so do we want the customer to pick and choose the right version for them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh interesting! — Though I’d rather not think too much about it at the moment 🙏 I took a peek and it made me question other things. Makes me feel it’s a scope leak and could lead to a rabbit hole.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a peek and it made me question other things.

@sadasant interesting, anything you could share that could help with future migrations?


## Getting started

Expand Down
20 changes: 16 additions & 4 deletions sdk/identity/identity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,27 @@
"./dist-esm/src/plugins/consumer.js": "./dist-esm/src/plugins/consumer.browser.js",
"./dist-esm/test/httpRequests.js": "./dist-esm/test/httpRequests.browser.js"
},
"//sampleConfiguration": {
"productName": "Azure Identity",
"productSlugs": [
"azure",
"azure-active-directory"
],
"requiredResources": {
"Azure Active Directory App Registration": "https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app",
"Azure Key Vault": "https://docs.microsoft.com/azure/key-vault/quick-create-portal"
}
},
"scripts": {
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build:samples": "echo skipped",
"build:samples": "echo Obsolete.",
"build:test": "tsc -p . && rollup -c 2>&1",
"build": "npm run clean && npm run extract-api && tsc -p . && rollup -c 2>&1",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\" \"samples/**/*.{js,json}\"",
"clean": "rimraf dist dist-* types *.tgz *.log",
"execute:samples": "echo skipped",
"execute:samples": "dev-tool samples run samples-dev",
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\" \"samples/**/*.{js,json}\"",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "echo skipped",
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace \"dist-esm/test/public/node/*.spec.js\"",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
Expand Down Expand Up @@ -111,6 +122,7 @@
"uuid": "^8.3.0"
},
"devDependencies": {
"@azure/keyvault-keys": "4.2.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/test-utils": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/**
* @summary Authenticates with an app registration’s client Id and secret.
*/

import { ClientSecretCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";

Expand All @@ -9,9 +13,9 @@ require("dotenv").config();

export async function main(): Promise<void> {
const credential = new ClientSecretCredential(
process.env.AZURE_TENANT_ID!, // The tenant ID in Azure Active Directory
process.env.AZURE_CLIENT_ID!, // The application (client) ID registered in the AAD tenant
process.env.AZURE_CLIENT_SECRET! // The client secret for the registered application
process.env.AZURE_TENANT_ID!, // The tenant ID in Azure Active Directory
process.env.AZURE_CLIENT_ID!, // The app registration client Id in the AAD tenant
process.env.AZURE_CLIENT_SECRET! // The app registration secret for the registered application
);

const keyVaultUrl = `https://key-vault-name.vault.azure.net`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/**
* @summary Tries several authentication methods using a single credential. The simplest way to use `@azure/identity`.
*/

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/**
* @summary Authenticates as an app registration automatically using environment variables.
*/

import { EnvironmentCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";

Expand Down
6 changes: 3 additions & 3 deletions sdk/identity/identity/samples/AzureIdentityExamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

## Introduction

Authenticating your application, users, and principals is an integral part of working with the Azure client libraries. The Azure Identity library provides multiple ways to gain access to the Azure services, each with a flexible configuration that covers most scenarios. There is sample code in [JavaScript](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity/samples/javascript) and [TypeScript](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity/samples/typescript) to cover the basic authentication scenarios. This document covers several use cases of Identity with greater context and links to the underlying authentication flows and other available documentation.
Authenticating your application, users, and principals is an integral part of working with the Azure client libraries. The Azure Identity library provides multiple ways to gain access to the Azure services, each with a flexible configuration that covers most scenarios. There is sample code in [JavaScript](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity/samples/v2/javascript) and [TypeScript](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity/samples/v2/typescript) to cover the basic authentication scenarios. This document covers several use cases of Identity with greater context and links to the underlying authentication flows and other available documentation.

## Authenticating client-side browser applications

Expand Down Expand Up @@ -126,7 +126,7 @@ If your application is hosted in Azure, you can make use of [Managed Identity](h

#### Authenticating with `DefaultAzureCredential`

This example demonstrates authenticating the `SecretClient` from the [@azure/keyvault-secrets][secrets_client_library] client library using the `DefaultAzureCredential`. There's also [a runnable sample](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/typescript/src/defaultAzureCredential.ts) to create a Key Vault key client you can copy-paste. The `DefaultAzureCredential` makes for a terrific starting point as it provides sane defaults with minimal configuration and chains multiple credentials together. While you may outgrow it eventually, it is a sensible first choice for most scenarios where the application is intended to ultimately be run in the Azure Cloud.
This example demonstrates authenticating the `SecretClient` from the [@azure/keyvault-secrets][secrets_client_library] client library using the `DefaultAzureCredential`. There's also [a runnable sample](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2/typescript/src/defaultAzureCredential.ts) to create a Key Vault key client you can copy-paste. The `DefaultAzureCredential` makes for a terrific starting point as it provides sane defaults with minimal configuration and chains multiple credentials together. While you may outgrow it eventually, it is a sensible first choice for most scenarios where the application is intended to ultimately be run in the Azure Cloud.

```ts
/**
Expand Down Expand Up @@ -179,7 +179,7 @@ function withInteractiveBrowserCredential() {

#### Authenticating a service principal with a client secret

This example demonstrates authenticating the `SecretClient` from the [@azure/keyvault-secrets][secrets_client_library] client library using the `ClientSecretCredential`. There's also [a runnable sample](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/typescript/src/clientSecretCredential.ts) to create a Key Vault key client you can copy-paste.
This example demonstrates authenticating the `SecretClient` from the [@azure/keyvault-secrets][secrets_client_library] client library using the `ClientSecretCredential`. There's also [a runnable sample](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2/typescript/src/clientSecretCredential.ts) to create a Key Vault key client you can copy-paste.

You'll need to:

Expand Down
79 changes: 0 additions & 79 deletions sdk/identity/identity/samples/javascript/README.md

This file was deleted.

35 changes: 0 additions & 35 deletions sdk/identity/identity/samples/javascript/package.json

This file was deleted.

14 changes: 0 additions & 14 deletions sdk/identity/identity/samples/tsconfig.json

This file was deleted.

Loading