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] Samples aligned with other languages (v1 compatible) #15031

Merged
25 commits merged into from
Jun 24, 2021

Conversation

sadasant
Copy link
Contributor

@sadasant sadasant commented Apr 27, 2021

In this PR we're aligning the samples of Identity with other languages. The samples I'm adding in this PR are:

  • Rolling certificates with ClientCertificateCredential (.Net).
  • ClientCertificateCredential with a Key Vault Certificate (Python) (decided not to use @azure/keyvault-certificates because of the possible issues converting certificates from one format to another in Node).
  • Custom credentials (.Net).
  • Using MSAL directly (.Net).
  • On Behalf Of Flow (.Net).

New samples related to the v2-specific features will be added after the Identity package is separated.

Related to #14435


I’ve decided to use this opportunity to:

Fix #15324

This PR also implicitly:

Fixes #15573

@sadasant sadasant requested a review from witemple-msft April 27, 2021 23:31
@sadasant sadasant changed the title [Identity] Samples aligned with other languages (for v1.4) [Identity] Samples aligned with other languages (v1 compatible) Apr 27, 2021
@ramya-rao-a
Copy link
Contributor

@maorleger Can you please help in reviewing this?

Copy link
Member

@maorleger maorleger left a comment

Choose a reason for hiding this comment

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

A few questions / comments

sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
@check-enforcer

This comment has been minimized.

In this example, `StaticTokenCredential` implements the `TokenCredential` abstraction. It takes a pre-fetched access token in its constructor as an `AccessToken` (defined on `@azure/core-http`), and simply returns that from its implementation of `getToken()`.

```ts
import { TokenCredential, AccessToken } from "@azure/core-http";
Copy link
Contributor

Choose a reason for hiding this comment

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

We have been very intentional when showing samples to use JavaScript rather than TypeScript. We have the TS samples only in our samples folder where we can afford to keep both TS & JS samples. Can we do the same here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this PR I’d like to keep this in typescript, as it will mean double the files, and if we want to cater specifically to either audience, it may make sense to give more context on what typescript dependencies to install, for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, let’s do this: I can add the two documents as part of this PR, but let’s get one of them approved first (the typescript one, which will be more complex), then I’ll do the JS one.

Copy link
Contributor Author

@sadasant sadasant Jun 11, 2021

Choose a reason for hiding this comment

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

On second thought, two documents won’t work well with the samples v2 approach, since these won’t be auto-generated. There must be a clean way to do this, but we also have an issue to migrate to samples v2. I believe we can have one file for now and improve over time.

@sadasant
Copy link
Contributor Author

@ramya-rao-a I reviewed it and updated it! I read it carefully. Some things are missing, like the accommodations for a proper TypeScript project. Still, it seems that this file is generally about providing an idea of how to move forward rather than giving prescriptive solutions for our users.

My intention with this PR is to make these specific samples easy to follow. We still have to add many other cases based on the rest of the features that we’ll be releasing. In parallel, we’ll be figuring out how to make the Identity samples play well with the Samples V2 architecture. I think there’s a lot of work pending that will touch the sample files, so we’ll have many opportunities to revisit this.

sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com>
@sadasant
Copy link
Contributor Author

@scottaddie hello, Scott! There’s one answer to one of your feedback entries here: #15031 (comment) It’s hidden from plain view because of all of the collapsed messages. Let me know how it goes! Your time is appreciated.

@sadasant sadasant requested a review from scottaddie June 18, 2021 01:00
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved

If the application gets notified of certificate rotations and can directly respond, it might choose to wrap the `ClientCertificateCredential` in a custom credential which provides a means for rotating the certificate.

> You'll need to install the [@azure/core-auth][core_auth] package for this sample.
Copy link
Member

Choose a reason for hiding this comment

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

What is needed from the perspective of somebody new to TypeScript? We do have some of that information in our main Identity readme, should we have something similar here?

You could list TypeScript as a prerequisite and link to https://www.typescriptlang.org/download. That information is probably better off in the main README. No need to duplicate the content then.

What I meant by adding a Prerequisites section was to add a heading before something like the following:

> You'll need to install the [@azure/core-auth][core_auth] package for this sample.

This example would become:

**Prerequisites**

Install the [@azure/core-auth][core_auth] package.

sadasant and others added 2 commits June 18, 2021 12:59
Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com>
@sadasant sadasant requested a review from scottaddie June 18, 2021 19:18
@sadasant
Copy link
Contributor Author

@scottaddie regarding the pre-requisites section, I did this: 69c56ab let me know how it looks?

sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com>
@sadasant sadasant requested a review from scottaddie June 21, 2021 19:36
Copy link
Member

@scottaddie scottaddie left a comment

Choose a reason for hiding this comment

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

One more suggestion to consider, and then this looks good to me.

sdk/identity/identity/samples/AzureIdentityExamples.md Outdated Show resolved Hide resolved
@ghost
Copy link

ghost commented Jun 24, 2021

Hello @sadasant!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 9b9a9d1 into Azure:main Jun 24, 2021
@sadasant sadasant deleted the identity/fix14435-samples branch June 25, 2021 09:53
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this pull request Jul 26, 2021
Fix swagger correctness for appplatform 2021-06-01-preview (Azure#15031)
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants