-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SSO] [Port] support for SSO to parent and child bot projects for man…
…ual testing (#1870) * [SSO] [Port] support for SSO to parent and child bot projects ofr manual testing * add a readme that links to the c# readme Co-authored-by: Swagat Mishra <swagatm@microsoft.com> Co-authored-by: Carlos Castro <carlosscastro@users.noreply.github.com>
- Loading branch information
1 parent
49a49af
commit c6baa19
Showing
11 changed files
with
314 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
For steps on how to test SSO using the skillParent and skillChild samples, please refer to the [ReadMe for C#](https://github.com/microsoft/botbuilder-dotnet/blob/master/tests/Skills/ReadMeForSSOTesting.md) | ||
You will need to add your bot specific secrets like appId and password to the .env files instead of the appsettings.json as mentioned the C# ReadMe. |
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,3 @@ | ||
MicrosoftAppId= | ||
MicrosoftAppPassword= | ||
ConnectionName= |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const { ComponentDialog, DialogSet, DialogTurnStatus, OAuthPrompt, WaterfallDialog } = require('botbuilder-dialogs'); | ||
|
||
const OAUTH_PROMPT = 'oAuthPrompt'; | ||
const MAIN_WATERFALL_DIALOG = 'mainWaterfallDialog'; | ||
|
||
class MainDialog extends ComponentDialog { | ||
constructor() { | ||
super('MainDialog'); | ||
this.addDialog(new OAuthPrompt(OAUTH_PROMPT, { | ||
connectionName: process.env.ConnectionName, | ||
text: 'Sign In to AAD', | ||
title: 'Sign In' | ||
})) | ||
.addDialog(new WaterfallDialog(MAIN_WATERFALL_DIALOG, [ | ||
this.signInStep.bind(this), | ||
this.showTokenResponse.bind(this) | ||
])); | ||
this.initialDialogId = MAIN_WATERFALL_DIALOG; | ||
} | ||
|
||
async run(turnContext, accessor) { | ||
const dialogSet = new DialogSet(accessor); | ||
dialogSet.add(this); | ||
|
||
const dialogContext = await dialogSet.createContext(turnContext); | ||
const results = await dialogContext.continueDialog(); | ||
if (results.status === DialogTurnStatus.empty) { | ||
await dialogContext.beginDialog(this.id); | ||
} | ||
} | ||
|
||
async signInStep(step) { | ||
return step.beginDialog(OAUTH_PROMPT); | ||
} | ||
|
||
async showTokenResponse(step) { | ||
const tokenResponse = step.result; | ||
if(tokenResponse) { | ||
console.log(`Skill: your token is ${ tokenResponse.token }`) | ||
} | ||
else { | ||
console.log('Skill: No token response from OAuthPrompt'); | ||
} | ||
|
||
return await step.endDialog(); | ||
} | ||
} | ||
|
||
module.exports.MainDialog = MainDialog; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
MicrosoftAppId= | ||
MicrosoftAppPassword= | ||
ConnectionName= | ||
SkillMicrosoftAppId= |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const { ComponentDialog, DialogSet, DialogTurnStatus, OAuthPrompt, WaterfallDialog } = require('botbuilder-dialogs'); | ||
|
||
const OAUTH_PROMPT = 'oAuthPrompt'; | ||
const MAIN_WATERFALL_DIALOG = 'mainWaterfallDialog'; | ||
|
||
class MainDialog extends ComponentDialog { | ||
constructor() { | ||
super('MainDialog'); | ||
this.addDialog(new OAuthPrompt(OAUTH_PROMPT, { | ||
connectionName: process.env.ConnectionName, | ||
text: 'Sign In to AAD', | ||
title: 'Sign In' | ||
})) | ||
.addDialog(new WaterfallDialog(MAIN_WATERFALL_DIALOG, [ | ||
this.signInStep.bind(this), | ||
this.showTokenResponse.bind(this) | ||
])); | ||
this.initialDialogId = MAIN_WATERFALL_DIALOG; | ||
} | ||
|
||
async run(turnContext, accessor) { | ||
const dialogSet = new DialogSet(accessor); | ||
dialogSet.add(this); | ||
|
||
const dialogContext = await dialogSet.createContext(turnContext); | ||
const results = await dialogContext.continueDialog(); | ||
if (results.status === DialogTurnStatus.empty) { | ||
await dialogContext.beginDialog(this.id); | ||
} | ||
} | ||
|
||
async signInStep(step) { | ||
return step.beginDialog(OAUTH_PROMPT); | ||
} | ||
|
||
async showTokenResponse(step) { | ||
const tokenResponse = step.result; | ||
if(tokenResponse) { | ||
await step.context.sendActivity(`your token is ${ tokenResponse.token }`); | ||
} | ||
else { | ||
await step.context.sendActivity('No token response from OAuthPrompt'); | ||
} | ||
|
||
return await step.endDialog(); | ||
} | ||
} | ||
|
||
module.exports.MainDialog = MainDialog; |
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
Oops, something went wrong.