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

port:[#3906] Port Managed Identity (MSI) + Single Tenant from DotNet #3923

Merged
merged 33 commits into from
Sep 27, 2021

Conversation

sw-joelmut
Copy link
Collaborator

@sw-joelmut sw-joelmut commented Sep 7, 2021

Fixes #3906

Description

This PR ports the Managed Identity (MSI) and Single Tenant functionalities from DotNet.

Note: While testing the different combinations of the following table, we found that the case where a SingleTenant host connects a MultiTenant skill through expectReplies delivery mode works, the skill answered to the host properly, whereas using normal it didn't, due to not finding the resource in botframework.com (which is not supported, more information can be found in the related issue).

MultiTenant SkillSingleTenant SkillMSI Skill
MultiTenant HostY--
SingleTenant Hostnormal (-), expectReplies (Y)YY
MSI Host-YY

NOTE: When one of the bots is MultiTenant, the other cannot be SingleTenant/MSI since the token acquisition by the MultiTenant bot will fail due to not being able to find the SingleTenant/MSI bot resource registered in the botframework.com tenant. So, those scenarios are not supported.

Specific Changes

  • Updated ConfigurationServiceClientCredentialFactory to support the three MultiTenant, SingleTenant and MSI functionalities.
  • Added valid token issuers into the botbuilder-dialogs-adaptive-runtime and botframework-connector libraries.
  • Added new JwtTokenProviderFactory class that will be used to instantiate the DefaultAzureCredential class from @azure/identity.
  • Added ManagedIdentityAppCredentials class by extending from AppCredentials and be able to get the jwt token.
  • Added ManagedIdentityAuthenticator that will be in charge of creating the token provider and gather the token from it.
  • Added ManagedIdentityServiceClientCredentialsFactory class Factory in charge of creating the ManagedIdentityAppCredentials.
  • Added new unit tests for previous specified classes.
  • Added new/updated dependencies (package.json)
    • botframework-connector
      • @azure/identity@2.0.0-beta.6
    • root
      • @azure/logger@1.0.2
      • @azure/ms-rest-js@1.9.1

Testing

The following image shows some new added unit tests passing successfully.
image

Troubleshooting

  • @azure/identity

    • When using the latest available version in NPM (1.5.2) we started getting Unexpected character... error on the keytar dependency when running yarn build.
    • We found an issue related to keytar which will not be included in the base package in the 2.0.0 release.
      • Issue: https://github.com/Azure/azure-sdk-for-js/issues/14852#issuecomment-818915410
    • Solution: Instead of installing the version 1.5.2 we use 2.0.0-beta.6 and no issues were shown, and the build was successful.
      image
  • @azure/logger

    • Package dependency of the @azure/identity library.
    • Browserify fails to build the project due to not finding the @azure/logger library in the @azure/identity. This is caused by the browser configuration property set in the @azure/logger library.
    • This issues was already solved in the newest versions, from which @azure/identity wasn't installing.
    • Solution: By including the @azure/logger into the root package.json and setting the minimum version of ^1.0.2 solved the issue when building with browserify.
      image

@coveralls
Copy link

coveralls commented Sep 7, 2021

Pull Request Test Coverage Report for Build 1279572164

  • 79 of 85 (92.94%) changed or added relevant lines in 11 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.03%) to 84.569%

Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/botframework-connector/src/auth/skillValidation.ts 1 2 50.0%
libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts 0 2 0.0%
libraries/botbuilder-core/src/configurationServiceClientCredentialFactory.ts 21 24 87.5%
Files with Coverage Reduction New Missed Lines %
libraries/botframework-connector/src/auth/skillValidation.ts 1 87.61%
libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts 2 16.95%
Totals Coverage Status
Change from base Build 1258824352: 0.03%
Covered Lines: 19703
Relevant Lines: 22071

💛 - Coveralls

package.json Show resolved Hide resolved
@@ -40,7 +40,8 @@
"update-versions": "yarn workspace botbuilder-repo-utils update-versions"
},
"devDependencies": {
"@azure/ms-rest-js": "1.9.0",
"@azure/logger": "^1.0.2",
"@azure/ms-rest-js": "1.9.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

This also should likely be reconciled with whatever package(s) it's used in. Why was this updated?

Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency with other uses of the same dependency. We can revert it if you deem it so

@ceciliaavila ceciliaavila changed the title [DRAFT][#3906] Port Managed Identity (MSI) + Single Tenant from DotNet port: [DRAFT][#3906] Port Managed Identity (MSI) + Single Tenant from DotNet Sep 15, 2021
@sw-joelmut sw-joelmut marked this pull request as ready for review September 16, 2021 20:05
@MartinLuccanera MartinLuccanera changed the title port: [DRAFT][#3906] Port Managed Identity (MSI) + Single Tenant from DotNet port: [#3906] Port Managed Identity (MSI) + Single Tenant from DotNet Sep 16, 2021
@mrivera-ms mrivera-ms changed the title port: [#3906] Port Managed Identity (MSI) + Single Tenant from DotNet port:[#3906] Port Managed Identity (MSI) + Single Tenant from DotNet Sep 16, 2021
Copy link
Contributor

@joshgummersall joshgummersall left a comment

Choose a reason for hiding this comment

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

Little more feedback here, it's looking solid though. I pulled the branch and understand the root package.json changes better now, thanks for your patience while I convinced myself those changes were necessary.

@sw-joelmut
Copy link
Collaborator Author

@joshgummersall Thank you for your feedback, we just pushed some changes, let us know if we can improve anything else 🤗(hug).

Copy link
Member

@stevengum stevengum left a comment

Choose a reason for hiding this comment

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

The Identity team released @azure/identity@2.0.0-beta.6 which contains a few breaking changes that I don't believe affects the changes in this PR nor the rest of the botframework-connector package. That said, would you bump @azure/identity to this current next version and vet the contents of this PR again?

https://github.com/Azure/azure-sdk-for-js/blob/4868986e7f311d64478492c1571e59903ccbd3a1/sdk/identity/identity/CHANGELOG.md

@sw-joelmut
Copy link
Collaborator Author

sw-joelmut commented Sep 21, 2021

The Identity team released @azure/identity@2.0.0-beta.6 which contains a few breaking changes that I don't believe affects the changes in this PR nor the rest of the botframework-connector package. That said, would you bump @azure/identity to this current next version and vet the contents of this PR again?

https://github.com/Azure/azure-sdk-for-js/blob/4868986e7f311d64478492c1571e59903ccbd3a1/sdk/identity/identity/CHANGELOG.md

Updated the @azure/identity to the latest 2.0.0-beta.6 and the functionality continues to work. Thanks, @stevengum.
image

Copy link
Contributor

@joshgummersall joshgummersall left a comment

Choose a reason for hiding this comment

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

One final set of feedback

Comment on lines +96 to +104
/**
* The Government V1 Azure AD token issuer URL template that will contain the tenant id where the token was issued from.
*/
export const ValidGovernmentTokenIssuerUrlTemplateV1 = 'https://login.microsoftonline.us/';

/**
* The Government V2 Azure AD token issuer URL template that will contain the tenant id where the token was issued from.
*/
export const ValidGovernmentTokenIssuerUrlTemplateV2 = 'https://login.microsoftonline.us/';
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be in the GovernmentConstants instead? @msomanathan

It's not a big deal, but historically all of the US Gov Cloud related constants are stored in a separate file. My main concern is the v4-to-v5 work and making sure our ducks are in a row.

I did note that this is a verbatim port from .NET.

Copy link
Contributor

Choose a reason for hiding this comment

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

Filed microsoft/botframework-sdk#6384 for tracking.

@sw-joelmut
Copy link
Collaborator Author

@stevengum Thank you for the feedback, we just pushed the changes.
There are some additional changes applied based on the provided feedback, let us know if there is anything else we could improve on the implementation. Thanks.

Copy link
Contributor

@joshgummersall joshgummersall left a comment

Choose a reason for hiding this comment

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

Approved, pending test pass!

@stevengum stevengum merged commit edb0f90 into main Sep 27, 2021
@stevengum stevengum deleted the southworks/add/port-msi-single-tenant-support branch September 27, 2021 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

port: Managed Identity (MSI) + Single Tenant support for Bot apps (#5829)
6 participants