-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: USGovSingleTenant OAuthEndpoint (#4588)
* fix usgov single tenant * fix js lint
- Loading branch information
1 parent
9e74976
commit aa83fbe
Showing
10 changed files
with
149 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
libraries/botframework-connector/src/auth/microsoftGovernmentAppCredentials.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @module botframework-connector | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
import { GovernmentConstants } from './governmentConstants'; | ||
import { MicrosoftAppCredentials } from './microsoftAppCredentials'; | ||
|
||
/** | ||
* MicrosoftGovermentAppCredentials auth implementation | ||
*/ | ||
export class MicrosoftGovernmentAppCredentials extends MicrosoftAppCredentials { | ||
/** | ||
* Initializes a new instance of the [MicrosoftGovernmentAppCredentials](xref:botframework-connector.MicrosoftGovernmentAppCredentials) class. | ||
* | ||
* @param {string} appId The Microsoft app ID. | ||
* @param {string} appPassword The Microsoft app password. | ||
* @param {string} channelAuthTenant Optional. The oauth token tenant. | ||
* @param {string} oAuthScope Optional. The scope for the token. | ||
*/ | ||
constructor(appId: string, public appPassword: string, channelAuthTenant?: string, oAuthScope?: string) { | ||
super(appId, appPassword, channelAuthTenant, oAuthScope); | ||
} | ||
|
||
protected GetToChannelFromBotOAuthScope(): string { | ||
return GovernmentConstants.ToChannelFromBotOAuthScope; | ||
} | ||
|
||
protected GetToChannelFromBotLoginUrlPrefix(): string { | ||
return GovernmentConstants.ToChannelFromBotLoginUrlPrefix; | ||
} | ||
|
||
protected GetDefaultChannelAuthTenant(): string { | ||
return GovernmentConstants.DefaultChannelAuthTenant; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
libraries/botframework-connector/tests/auth/microsoftAppCredentials.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { MicrosoftAppCredentials, AuthenticationConstants } = require('../..'); | ||
const assert = require('assert'); | ||
|
||
describe('MicrosoftAppCredentialsTestSuite', function () { | ||
describe('MicrosoftAppCredentialsTestCase', function () { | ||
it('AssertOAuthEndpointAndOAuthScope', function () { | ||
const credentials1 = new MicrosoftAppCredentials('appId', 'password', 'tenantId', 'audience'); | ||
assert.strictEqual( | ||
AuthenticationConstants.ToChannelFromBotLoginUrlPrefix + 'tenantId', | ||
credentials1.oAuthEndpoint | ||
); | ||
assert.strictEqual('audience', credentials1.oAuthScope); | ||
|
||
const credentials2 = new MicrosoftAppCredentials('appId', 'password'); | ||
assert.strictEqual( | ||
AuthenticationConstants.ToChannelFromBotLoginUrlPrefix + | ||
AuthenticationConstants.DefaultChannelAuthTenant, | ||
credentials2.oAuthEndpoint | ||
); | ||
assert.strictEqual(AuthenticationConstants.ToChannelFromBotOAuthScope, credentials2.oAuthScope); | ||
}); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
libraries/botframework-connector/tests/auth/microsoftGovernmentAppCredentials.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const { MicrosoftGovernmentAppCredentials, GovernmentConstants } = require('../..'); | ||
const assert = require('assert'); | ||
|
||
describe('MicrosoftGovernmentAppCredentialsTestSuite', function () { | ||
describe('MicrosoftGovernmentAppCredentialsTestCase', function () { | ||
it('AssertOAuthEndpointAndOAuthScope', function () { | ||
const credentials1 = new MicrosoftGovernmentAppCredentials('appId', 'password', 'tenantId', 'audience'); | ||
assert.strictEqual( | ||
GovernmentConstants.ToChannelFromBotLoginUrlPrefix + 'tenantId', | ||
credentials1.oAuthEndpoint | ||
); | ||
assert.strictEqual('audience', credentials1.oAuthScope); | ||
|
||
const credentials2 = new MicrosoftGovernmentAppCredentials('appId', 'password'); | ||
assert.strictEqual( | ||
GovernmentConstants.ToChannelFromBotLoginUrlPrefix + GovernmentConstants.DefaultChannelAuthTenant, | ||
credentials2.oAuthEndpoint | ||
); | ||
assert.strictEqual(GovernmentConstants.ToChannelFromBotOAuthScope, credentials2.oAuthScope); | ||
}); | ||
}); | ||
}); |