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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2253145
Port MSI and SingleTenant support
ceciliaavila Sep 2, 2021
189f9d2
Add unit tests for botframework-connector
ceciliaavila Sep 2, 2021
d88c616
Restore yarn.lock
ceciliaavila Sep 3, 2021
7c45a2b
Test nohoist for azure/identity
ceciliaavila Sep 3, 2021
542a7ab
Fix dependencies issues
sw-joelmut Sep 7, 2021
f3dd2c3
Connect ManagedIdentityAuthenticator.getToken
sw-joelmut Sep 7, 2021
86f0f2d
Add remaining tests and fix the already added
sw-joelmut Sep 7, 2021
e0a233a
Update yarn.lock
sw-joelmut Sep 7, 2021
171733b
Fixing depcheck errors in PR
MartinLuccanera Sep 9, 2021
875b0d3
Fixing depcheck, adjusting versions and ignores
MartinLuccanera Sep 9, 2021
288765f
Fix parity port with DotNet causing SingleTenant to fail at authentic…
sw-joelmut Sep 9, 2021
0c4a9a6
Merge branch 'southworks/add/port-msi-single-tenant-support' of https…
sw-joelmut Sep 9, 2021
135522d
Apppliying feedback
MartinLuccanera Sep 10, 2021
14386eb
Merge branch 'southworks/add/port-msi-single-tenant-support' of githu…
MartinLuccanera Sep 10, 2021
afebb4d
Applying fixes for tests, lint and zod related feedback
MartinLuccanera Sep 13, 2021
bc25476
Fixing asserts import and extra parameter
MartinLuccanera Sep 14, 2021
799842f
Merge branch 'southworks/add/port-msi-single-tenant-support' of githu…
MartinLuccanera Sep 14, 2021
a6132b6
Fix tests failing due to wrong link and fixing case-wise comparison f…
MartinLuccanera Sep 15, 2021
5c95709
Fixing lint
MartinLuccanera Sep 15, 2021
4d54c25
Merge branch 'main' into southworks/add/port-msi-single-tenant-support
ceciliaavila Sep 15, 2021
12fe13f
Add ignore-casing to MicrosoftAppType based on DotNet code and add un…
sw-joelmut Sep 16, 2021
c78713a
Improve issuer array assignation
sw-joelmut Sep 16, 2021
7bbf539
Merge remote-tracking branch 'upstream/southworks/add/port-msi-single…
sw-joelmut Sep 16, 2021
0e207e5
fix: export ms-rest-js type and remove added dep
Sep 17, 2021
9f75226
Improve issuers, assertions, unit tests and many other small changes
sw-joelmut Sep 20, 2021
27fbdf0
fix: skillValidation validTokenIssuers
sw-joelmut Sep 20, 2021
1fa5179
Merge branch 'main' into southworks/add/port-msi-single-tenant-support
sw-joelmut Sep 21, 2021
a8a8277
Update @azure/identity to 2.0.0-beta.6
sw-joelmut Sep 21, 2021
9c9f8d9
Change logical operator for nullable operator
sw-joelmut Sep 21, 2021
2f88d99
Merge branch 'main' into southworks/add/port-msi-single-tenant-support
sw-joelmut Sep 24, 2021
3245f18
Improve SingleTenant and MSI implementation from feedback
sw-joelmut Sep 24, 2021
47d891f
fix: IJwtTokenProviderFactory
Sep 27, 2021
5f66d89
fix: reintroduced typo
Sep 27, 2021
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
1 change: 0 additions & 1 deletion libraries/botframework-connector/src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export * from './enterpriseChannelValidation';
export * from './governmentChannelValidation';
export * from './governmentConstants';
export * from './jwtTokenProviderFactory';
export * from './jwtTokenProviderFactoryInterface';
export * from './jwtTokenValidation';
export * from './managedIdentityAppCredentials';
export * from './managedIdentityAuthenticator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,23 @@

import { DefaultAzureCredential } from '@azure/identity';
import { ok } from 'assert';
import type { JwtTokenProviderFactoryInterface } from './jwtTokenProviderFactoryInterface';

/*
* A factory that can create OAuth token providers for generating JWT auth tokens.
*/
export interface IJwtTokenProviderFactory {
joshgummersall marked this conversation as resolved.
Show resolved Hide resolved
/*
* Creates a new instance of the <see cref="DefaultAzureCredential"/> class.
* @param appId Client id for the managed identity to be used for acquiring tokens.
* @returns A new instance of the <see cref="DefaultAzureCredential"/> class.
*/
createAzureServiceTokenProvider(appId: string): DefaultAzureCredential;
}

/**
* @inheritdoc
*/
export class JwtTokenProviderFactory implements JwtTokenProviderFactoryInterface {
export class JwtTokenProviderFactory implements IJwtTokenProviderFactory {
/**
* @inheritdoc
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
* Licensed under the MIT License.
*/

import type { TokenResponse } from 'adal-node';
import { ok } from 'assert';
import { AppCredentials } from './appCredentials';
import type { JwtTokenProviderFactoryInterface } from './jwtTokenProviderFactoryInterface';
import type { IJwtTokenProviderFactory } from './jwtTokenProviderFactory';
import { ManagedIdentityAuthenticator } from './managedIdentityAuthenticator';
import { TokenResponse } from 'adal-node';
import { ok } from 'assert';

/**
* Managed Service Identity auth implementation.
*/
export class ManagedIdentityAppCredentials extends AppCredentials {
sw-joelmut marked this conversation as resolved.
Show resolved Hide resolved
private readonly tokenProviderFactory: JwtTokenProviderFactoryInterface;
private readonly authenticator: ManagedIdentityAuthenticator;
private readonly tokenProviderFactory: IJwtTokenProviderFactory;
private authenticator: ManagedIdentityAuthenticator;
ceciliaavila marked this conversation as resolved.
Show resolved Hide resolved

/**
* Managed Identity for AAD credentials auth and caching.
Expand All @@ -26,7 +26,7 @@ export class ManagedIdentityAppCredentials extends AppCredentials {
* @param oAuthScope The scope for the token.
* @param tokenProviderFactory The JWT token provider factory to use.
*/
constructor(appId: string, oAuthScope: string, tokenProviderFactory: JwtTokenProviderFactoryInterface) {
constructor(appId: string, oAuthScope: string, tokenProviderFactory: IJwtTokenProviderFactory) {
super(appId, null, oAuthScope);

ok(appId?.trim(), 'ManagedIdentityAppCredentials.constructor(): missing appId.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/

import type { AccessToken, DefaultAzureCredential } from '@azure/identity';
import type { IJwtTokenProviderFactory } from './jwtTokenProviderFactory';
import { ok } from 'assert';
import { retry } from 'botbuilder-stdlib';
import type { JwtTokenProviderFactoryInterface } from './jwtTokenProviderFactoryInterface';

/**
* Abstraction to acquire tokens from a Managed Service Identity.
Expand All @@ -25,8 +25,8 @@ export class ManagedIdentityAuthenticator {
* @param resource Resource for which to acquire the token.
joshgummersall marked this conversation as resolved.
Show resolved Hide resolved
* @param tokenProviderFactory The JWT token provider factory to use.
*/
constructor(appId: string, resource: string, tokenProviderFactory: JwtTokenProviderFactoryInterface) {
ok(appId?.trim(), 'ManagedIdentityAuthenticator.constructor(): missing appId.');
constructor(appId: string, resource: string, tokenProviderFactory: IJwtTokenProviderFactory) {
ok(appId?.trim(), 'ManagedIdentityAuthenticator.constructor(): missing appid.');
sw-joelmut marked this conversation as resolved.
Show resolved Hide resolved
ok(resource?.trim(), 'ManagedIdentityAuthenticator.constructor(): missing resource.');
ok(tokenProviderFactory, 'ManagedIdentityAuthenticator.constructor(): missing tokenProviderFactory.');

Expand All @@ -37,7 +37,7 @@ export class ManagedIdentityAuthenticator {
/**
* Acquires the security token.
*
* @returns {Promise<AccessToken>} A promise with the `AccessToken` provided by the [JwtTokenProviderFactoryInterface](xref:botframework-connector.JwtTokenProviderFactoryInterface) class.
* @returns {Promise<AccessToken>} A promise with the `AccessToken` provided by the [IJwtTokenProviderFactory](xref:botframework-connector.IJwtTokenProviderFactory) class.
*/
async getToken(): Promise<AccessToken> {
// Retry gradually, starting from 10 ms up to 5 times.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
* Licensed under the MIT License.
*/

import type { IJwtTokenProviderFactory } from './jwtTokenProviderFactory';
import type { ServiceClientCredentials } from '@azure/ms-rest-js';
import { ok } from 'assert';
import type { JwtTokenProviderFactoryInterface } from './jwtTokenProviderFactoryInterface';
import { ManagedIdentityAppCredentials } from './managedIdentityAppCredentials';
import { ServiceClientCredentialsFactory } from './serviceClientCredentialsFactory';
import { ok } from 'assert';

/*
* A Managed Identity implementation of the [ServiceClientCredentialsFactory](xref:botframework-connector.ServiceClientCredentialsFactory) abstract class.
*/
export class ManagedIdentityServiceClientCredentialsFactory extends ServiceClientCredentialsFactory {
private readonly appId: string;
private readonly tokenProviderFactory: JwtTokenProviderFactoryInterface;
private readonly tokenProviderFactory: IJwtTokenProviderFactory;

/**
* Initializes a new instance of the ManagedIdentityServiceClientCredentialsFactory class.
*
* @param appId Client ID for the managed identity assigned to the bot.
* @param tokenProviderFactory The JWT token provider factory to use.
*/
constructor(appId: string, tokenProviderFactory: JwtTokenProviderFactoryInterface) {
constructor(appId: string, tokenProviderFactory: IJwtTokenProviderFactory) {
super();
ok(appId?.trim(), 'ManagedIdentityServiceClientCredentialsFactory.constructor(): missing appId.');
ok(
Expand Down