From 88c77b4caa61e26889ea8c865a9b2a9edca40778 Mon Sep 17 00:00:00 2001 From: TJ Durnford Date: Sun, 16 Feb 2020 11:25:55 -0800 Subject: [PATCH 01/12] Added OBO sample --- lerna.json | 3 +- .../component/src/hooks/useSetNotification.js | 1 + .../.dockerignore | 6 + .../Dockerfile | 47 + .../Dockerfile-run | 28 + .../README.md | 274 + .../app/.env | 1 + .../app/.gitignore | 23 + .../app/package-lock.json | 15167 ++++++++++++++++ .../app/package.json | 36 + .../app/public/favicon.ico | Bin 0 -> 3870 bytes .../public/images/BotServices-Translucent.svg | 1 + .../app/public/images/BotServices.png | Bin 0 -> 3953 bytes .../app/public/images/BotServices.svg | 1 + .../app/public/images/Microsoft-32px.png | Bin 0 -> 1208 bytes .../app/public/images/Microsoft-64px.png | Bin 0 -> 1300 bytes .../images/Microsoft-Graph-64px-DDD-White.png | Bin 0 -> 2322 bytes .../images/Microsoft-Graph-64px-EEE-White.png | Bin 0 -> 2269 bytes .../public/images/Microsoft-Graph-64px.png | Bin 0 -> 1543 bytes .../app/public/index.html | 56 + .../app/public/manifest.json | 15 + .../app/serve.json | 10 + .../app/src/App.css | 7 + .../app/src/App.js | 17 + .../app/src/index.css | 4 + .../app/src/index.js | 13 + .../app/src/oauth/Composer.js | 148 + .../app/src/oauth/Context.js | 4 + .../app/src/oauth/fetchProfileDisplayName.js | 15 + .../src/oauth/fetchProfilePhotoAsBase64.js | 24 + .../app/src/serviceWorker.js | 128 + .../app/src/setupProxy.js | 6 + .../MicrosoftGraphProfileMenu/ProfileMenu.css | 114 + .../src/ui/MicrosoftGraphProfileMenu/index.js | 81 + .../OnBehalfOfAttachment/index.css | 71 + .../Attachments/OnBehalfOfAttachment/index.js | 112 + .../WebChat/Notifications/AppSignInToast.js | 43 + .../WebChat/Notifications/BotSignInToast.js | 125 + .../TraditionalBotAuthenticationToast.js | 35 + .../src/ui/WebChat/Notifications/index.css | 53 + .../app/src/ui/WebChat/Notifications/index.js | 3 + .../app/src/ui/WebChat/index.css | 10 + .../app/src/ui/WebChat/index.js | 86 + .../app/src/utils/fetchJSON.js | 15 + .../app/src/utils/requiresInteraction.js | 11 + .../azure-pipelines.yml | 50 + .../bot/.eslintrc.js | 17 + .../bot/.gitignore | 2 + .../bot/README.md | 109 + .../bot/bots/authBot.js | 36 + .../bot/bots/dialogBot.js | 45 + .../new-rg-parameters.json | 42 + .../preexisting-rg-parameters.json | 39 + .../template-with-new-rg.json | 183 + .../template-with-preexisting-rg.json | 154 + .../bot/dialogs/logoutDialog.js | 42 + .../bot/dialogs/mainDialog.js | 129 + .../bot/index.js | 74 + .../bot/oAuthHelpers.js | 100 + .../bot/package-lock.json | 5459 ++++++ .../bot/package.json | 34 + .../bot/simple-graph-client.js | 110 + .../docker-compose.yml | 16 + .../e.soo-on-behalf-of-authentication/init.sh | 9 + .../rest-api/.gitignore | 2 + .../rest-api/package-lock.json | 1287 ++ .../rest-api/package.json | 22 + .../rest-api/src/encodeBase64URL.js | 7 + .../rest-api/src/exchangeAccessToken.js | 42 + .../rest-api/src/generateDirectLineToken.js | 17 + .../rest-api/src/index.js | 55 + .../src/routes/aad/oauth/authorize.js | 30 + .../rest-api/src/routes/aad/oauth/callback.js | 45 + .../aad/oauth/createPKCECodeChallenge.js | 14 + .../aad/oauth/createPKCECodeVerifier.js | 15 + .../rest-api/src/routes/aad/settings.js | 12 + .../rest-api/src/routes/botMessages.js | 28 + .../rest-api/src/routes/directLine/token.js | 9 + .../src/utils/createHTMLWithPostMessage.js | 4 + .../rest-api/src/utils/fetchJSON.js | 18 + .../rest-api/src/utils/generateOAuthState.js | 12 + .../sshd_config | 16 + 82 files changed, 25078 insertions(+), 1 deletion(-) create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/.dockerignore create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile-run create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/README.md create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/.env create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/.gitignore create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/package-lock.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/package.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/favicon.ico create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/BotServices-Translucent.svg create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/BotServices.png create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/BotServices.svg create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-32px.png create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-64px.png create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px-DDD-White.png create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px-EEE-White.png create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px.png create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/index.html create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/manifest.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/serve.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/App.css create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/App.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/index.css create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/index.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/Composer.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/Context.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/fetchProfileDisplayName.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/fetchProfilePhotoAsBase64.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/serviceWorker.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/setupProxy.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/MicrosoftGraphProfileMenu/ProfileMenu.css create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/MicrosoftGraphProfileMenu/index.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.css create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/AppSignInToast.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/BotSignInToast.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/TraditionalBotAuthenticationToast.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/index.css create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/index.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/index.css create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/index.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/utils/fetchJSON.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/utils/requiresInteraction.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/azure-pipelines.yml create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/.eslintrc.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/.gitignore create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/README.md create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/bots/authBot.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/bots/dialogBot.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/new-rg-parameters.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/preexisting-rg-parameters.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/template-with-new-rg.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/template-with-preexisting-rg.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/dialogs/logoutDialog.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/dialogs/mainDialog.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/index.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/oAuthHelpers.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/package-lock.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/package.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/simple-graph-client.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/docker-compose.yml create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/init.sh create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/.gitignore create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/package-lock.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/package.json create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/encodeBase64URL.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/exchangeAccessToken.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/generateDirectLineToken.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/index.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/authorize.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/callback.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/createPKCECodeChallenge.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/createPKCECodeVerifier.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/settings.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/botMessages.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/directLine/token.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/createHTMLWithPostMessage.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/fetchJSON.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/generateOAuthState.js create mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/sshd_config diff --git a/lerna.json b/lerna.json index 74ed1239e6..bccf06bfd7 100644 --- a/lerna.json +++ b/lerna.json @@ -1,7 +1,8 @@ { "lerna": "3.19.0", "packages": [ - "packages/*" + "packages/*", + "samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app" ], "version": "0.0.0" } diff --git a/packages/component/src/hooks/useSetNotification.js b/packages/component/src/hooks/useSetNotification.js index 5c98e252db..f5062c4a40 100644 --- a/packages/component/src/hooks/useSetNotification.js +++ b/packages/component/src/hooks/useSetNotification.js @@ -1,5 +1,6 @@ import useWebChatUIContext from './internal/useWebChatUIContext'; export default function useSetNotification() { + console.log(useWebChatUIContext()); return useWebChatUIContext().setNotification; } diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/.dockerignore b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/.dockerignore new file mode 100644 index 0000000000..5fc54870bb --- /dev/null +++ b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/.dockerignore @@ -0,0 +1,6 @@ +/app/build +/app/node_modules +/bot/.env +/bot/node_modules +/rest-api/.env +/rest-api/node_modules diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile new file mode 100644 index 0000000000..cdb9f32104 --- /dev/null +++ b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile @@ -0,0 +1,47 @@ +# This container is for simplifying CI when using Azure Pipelines + +# The first builder image will build HTML and JavaScript code out of the create-react-app project +FROM node:12 AS builder-react +WORKDIR /var/build/react/ + +# Copy the web app code to /var/build/react/ +# We excluded /.env and /node_modules/ via .dockerignore +ADD app/ /var/build/react/ + +# Doing a fresh "npm install" on build to make sure the image is reproducible +RUN npm ci + +# Build the web app code via create-react-app and react-scripts +RUN npm run build + +# The second builder image will aggregate all code into a single Docker image for export +FROM node:12 + +# Copy the bot code to /var/bot/ +ADD bot/ /var/build/bot/ + +# Copy the web server code to /var/web/ +ADD rest-api/ /var/build/web/ + +# Copy SSH configuration and startup script to /var/ +# Adopted from https://github.com/Azure-App-Service/node/blob/master/10.14/sshd_config +ADD init.sh /var/build/ +ADD sshd_config /var/build/ + +# Copy static React app to /var/web/public/, to be consumed by web server +COPY --from=builder-react /var/build/react/build/ /var/build/web/public/ + +# Doing a fresh "npm install" on build to make sure the image is reproducible +WORKDIR /var/build/bot/ +RUN npm ci + +# Doing a fresh "npm install" on build to make sure the image is reproducible +WORKDIR /var/build/web/ +RUN npm ci + +# Pack "concurrently" to make sure the image is reproducible +WORKDIR /var/build/ +RUN npm install concurrently@5.0.0 + +# Pack the build content as a "build.tgz" and export it out +RUN tar -cf build.tgz * diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile-run b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile-run new file mode 100644 index 0000000000..62e630c836 --- /dev/null +++ b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile-run @@ -0,0 +1,28 @@ +# This is the container for running the demo under Azure Web App +FROM node:12 AS builder-web + +# Expose both port 80 and 2222 (SSH for Azure Web App) +EXPOSE 80 2222 + +WORKDIR /var/ + +# Extract build image to /var/ +ADD build.tgz /var/ + +# Setup OpenSSH for debugging thru Azure Web App +# https://docs.microsoft.com/en-us/azure/app-service/containers/app-service-linux-ssh-support#ssh-support-with-custom-docker-images +# https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image +ENV SSH_PASSWD "root:Docker!" +ENV SSH_PORT 2222 +RUN \ + apt-get update \ + && apt-get install -y --no-install-recommends dialog \ + && apt-get update \ + && apt-get install -y --no-install-recommends openssh-server \ + && echo "$SSH_PASSWD" | chpasswd \ + && mv /var/sshd_config /etc/ssh/ \ + && mv /var/init.sh /usr/local/bin/ \ + && chmod u+x /usr/local/bin/init.sh + +# Set up entrypoint +ENTRYPOINT init.sh diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/README.md b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/README.md new file mode 100644 index 0000000000..62b0e76564 --- /dev/null +++ b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/README.md @@ -0,0 +1,274 @@ +# Single sign-on demo for On Behalf Of Authentication using OAuth + + +# Description + +In this demo, we will show you how to authorize a user to access resources on an enterprise app with a bot using [Microsoft Graph](https://developer.microsoft.com/en-us/graph/). + +> When dealing with personal data, please respect user privacy. Follow platform guidelines and post your privacy statement online. + +## Background + +Different companies may use different access delegation technologies to protect their resources. In our demo, we are targeting authorization through [OAuth 2.0](https://tools.ietf.org/html/rfc6749)). + +Although OAuth and [OpenID](https://openid.net/) are often related to each other, they solve different problems. OAuth is for authorization and access delegation, while OpenID is for authentication and user identity. + +Instead of OpenID, most enterprise apps use OAuth plus a user profile API to identify an individual user. In this demo, we will demonstrate how to use OAuth to obtain access to user profile API and use the API to identifying the accessor. + +This demo does not include any threat models and is designed for educational purposes only. When you design a production system, threat-modelling is an important task to make sure your system is secure and provide a way to quickly identify potential source of data breaches. IETF [RFC 6819](https://tools.ietf.org/html/rfc6819) and [OAuth 2.0 for Browser-Based Apps](https://tools.ietf.org/html/draft-ietf-oauth-browser-based-apps-01#section-9) is a good starting point for threat-modelling when using OAuth 2.0. + +# Test out the hosted sample + +- [Try out MockBot](https://webchat-sample-obo.azurewebsites.net/) + +# How to run locally + +This demo integrates with multiple services. There are multiple services you need to setup in order to host the demo. + +1. [Clone the code](#clone-the-code) +2. [Setup OAuth via Azure Active Directory for the Web App](#setup-oauth-via-azure-active-directory-for-the-web-app) +3. [Setup OAuth via Azure Active Directory for the Bot](#setup-oauth-via-azure-active-directory-for-the-bot) +4. [Setup Azure Bot Services](#setup-azure-bot-services) +5. [Prepare and run the code](#prepare-and-run-the-code) + +## Clone the code + +To host this demo, you will need to clone the code and run locally. + +1. Clone this repository +1. Create two files for environment variables, `/bot/.env` and `/rest-api/.env` + - In `/rest-api/.env`: + - Write `AAD_OAUTH_REDIRECT_URI=http://localhost:3000/api/aad/oauth/callback` + - When Azure Active Directory completes the authorization flow, it will send the browser to this URL. This URL must be accessible by the browser from the end-user machine + +## Setup OAuth via Azure Active Directory for the Web App + +- Go to your [Azure Active Directory](https://ms.portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview) +- Create a new application + 1. Select "App registrations" + 2. Click "New registration" + 3. Fill out "Name", for example, "Web Chat On-Behalf-Of Sample" + 4. In "Redirect URI (optional)" section, add a new entry + 1. Select "Web" as type + 2. Enter `http://localhost:3000/api/aad/oauth/callback` as the redirect URI + - This must match `AAD_OAUTH_REDIRECT_URI` in `/rest-api/.env` we saved earlier + - Click "Register" +- Save the client and tenant ID + 1. Select the "Overview" blade + 1. On the main pane, copy the content of "Application (client) ID" and "Directory (tenant) ID" to `/rest-api/.env`, it should looks be a GUID + - `AAD_OAUTH_CLIENT_ID=12345678abcd-1234-5678-abcd-12345678abcd` + - `AAD_OAUTH_TENANT_ID=abcd1234-abcd-1234-efgh-5678abcdefgh` +- Update App Registration Manifest + 1. Select the "Manifest" blade + 1. Set `accessTokenAcceptedVersion` to `2` + 2. Set `oauth2AllowImplicitFlow` to `true` +- Enable ID Tokens + 1. Select the "Authentication" Blade + 1. Towards the bottom of the "Web" section, check the box next to "ID tokens" under "Implicit grant" + +## Setup OAuth via Azure Active Directory for the Bot +- Go to your [Azure Active Directory](https://ms.portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview) +- Create a new application + 1. Select "App registrations" + 2. Click "New registration" + 3. Fill out "Name", for example, "Web Chat On-Behalf-Of Sample" + 4. In "Redirect URI (optional)" section, add a new entry + 1. Select "Web" as type + 2. Enter `https://token.botframework.com/.auth/web/redirect` as the redirect URI + - Click "Register" +- Update App Registration Manifest + 1. Select the "Manifest" blade + 1. Set `accessTokenAcceptedVersion` to `2` +- Create a new client secret + 1. Select the "Certificates & secretes" blade + 2. Click the "New client secret" +- Add a scope and client application + 1. Select the "Expose an API" blade + 1. Add a new scope for the bot + 1. Click the "Add a scope" button under "Scopes defined by this API" + 1. Add a scope name + 2. Set "Who can consent?" to "Admins and users" + 3. Add an admin consent display name + 4. Add an admin consent description + 5. Click "Add scope" + 2. Add a client application + 1. Click the "Add a client application" under "Authorized client applications" + 1. Set the client id to the Web Applications client id + 2. Check the box next to the scope we added in the previous step under "Authorized scopes" + 3. Click "Add application" + + + +## Setup Azure Bot Services + +> We prefer using [Bot Channel Registration](https://ms.portal.azure.com/#create/Microsoft.BotServiceConnectivityGalleryPackage) during development. This will help you diagnose problems locally without deploying to the server and speed up development. + +You can follow our instructions on how to [setup a new Bot Channel Registration](https://docs.microsoft.com/en-us/azure/bot-service/bot-service-quickstart-registration?view=azure-bot-service-3.0). + +1. Save the Microsoft App ID and password to `/bot/.env` + - `MICROSOFT_APP_ID=12345678-1234-5678-abcd-12345678abcd` + - `MICROSOFT_APP_PASSWORD=a1b2c3d4e5f6` +1. Save the Web Chat secret to `/rest-api/.env` + - `DIRECT_LINE_SECRET=a1b2c3.d4e5f6g7h8i9j0` + +> When you are building your production bot, never expose your Web Chat or Direct Line secret to the client. Instead, you should use the secret to generate a limited token and send it to the client. For information, please refer [to this page on how to generate a Direct Line token](https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0#generate-token) and [Enhanced Direct Line Authentication feature](https://blog.botframework.com/2018/09/25/enhanced-direct-line-authentication-features/). + +During development, you will run your bot locally. Azure Bot Services will send activities to your bot through a public URL. You can use [ngrok](https://ngrok.com/) to expose your bot server on a public URL. + +1. Run `ngrok http -host-header=localhost:3978 3978` +1. Update your Bot Channel Registration. You can use [Azure CLI](https://aka.ms/az-cli) or [Azure Portal](https://portal.azure.com) + - Via Azure CLI + - Run `az bot update --resource-group --name --subscription --endpoint "https://a1b2c3d4.ngrok.io/api/messages"` + - Via Azure Portal + - Browse to your Bot Channel Registration + - Select "Settings" + - In "Configuration" section, set "Messaging Endpoint" to `https://a1b2c3d4.ngrok.io/api/messages` + +## Prepare and run the code + +1. Under `app`, `bot`, and `rest-api` folder, run the following: + 1. `npm install` + 1. `npm start` +1. Browse to http://localhost:3000/ to start the demo + +# Things to try out + +- Notice there are two sign-in buttons on top-right hand corner + - After signed in, both the website and the bot get your sign in information +- Type, "where are my packages" in Web Chat + - If not signed in, the bot will present a sign-in button + - If signed in, the bot will answer the question +- Type, "bye" in Web Chat + - If signed in, the bot will sign you out + +# Code + +- `/app/` is the React app built using `create-react-app` scaffold +- `/bot/` is the bot server +- `/rest-api/` is the REST API for handling OAuth requests + - `GET /api/aad/oauth/authorize` will redirect to Azure AD OAuth authorize page at https://login.microsoftonline.com/12345678-1234-5678-abcd-12345678abcd/oauth2/v2.0/authorize + - `GET /api/aad/oauth/callback` will handle callback from Azure AD OAuth + - `GET /api/aad/settings` will send Azure AD OAuth settings to the React app + - `GET /api/directline/token` will generate a new Direct Line token for the React app + - It will serve React app as a static content + - During development-time, it will also serve the bot server via `/api/messages` + - To enable this feature, add `PROXY_BOT_URL=http://localhost:3978` to `/web/.env` + - This will forward all traffic from `https://a1b2c3d4.ngrok.io/api/messages` to `https://localhost:3978/api/messages` + +# Overview + +This sample includes multiple parts: + +- A basic web page with sign in and sign out button, coded with React +- Web Chat integrated, coded with pure JavaScript +- Wiring between the web page and Web Chat through DOM events + - When web page sign in, it should emit DOM event `accesstokenchange` with `{ data: { accessToken, provider } }` + - When the bot ask for sign out, Web Chat will emit DOM event `signout` +- For bot, OAuth access token is piggybacked on every user-initiated activity through `channelData.oauthAccessToken` and `channelData.oauthProvider` + +## Assumptions + +- Developer has an existing enterprise web app that uses OAuth to access protected resources + - We assume the OAuth access token lives in the browser's memory and is accessible through JavaScript + - Access token can live in browser memory but must be secured during transmit through the use of TLS + - More about security considerations can be found at [IETF RFC 6749 Section 10.3](https://tools.ietf.org/html/rfc6749#section-10.3) +- Developer know how to alter existing JavaScript code around their existing UI for OAuth + +## Goals + +- Website and bot conversation supports both anonymous and authenticated access + - Forced page refresh and/or new conversation is not mandated +- End-user is able to sign in through the web page, and is recognized by the bot immediately + - Vice versa, end-user is able to sign in through the bot, and is recognized by the web page immediately +- End-user is able to sign in through the web page and sign out though the bot + - Vice versa, end-user is able to sign in through the bot and sign out through the web page + +## Organization of JavaScript code + +In our demo, we built an enteprise single-page app using React. Then, we use a ``; diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/fetchJSON.js b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/fetchJSON.js new file mode 100644 index 0000000000..9814c30216 --- /dev/null +++ b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/fetchJSON.js @@ -0,0 +1,18 @@ +const fetch = require('node-fetch'); + +// Helper function for fetching network resource as JSON +module.exports = async function fetchJSON(url, options) { + const res = await fetch(url, { + ...options, + headers: { + ...options.headers, + accept: 'application/json' + } + }); + + if (!res.ok) { + throw new Error(`Failed to fetch JSON from server due to ${res.status}`); + } + + return await res.json(); +}; diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/generateOAuthState.js b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/generateOAuthState.js new file mode 100644 index 0000000000..2b5b681e66 --- /dev/null +++ b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/generateOAuthState.js @@ -0,0 +1,12 @@ +const crypto = require('crypto'); + +// For additional security, GitHub recommends using a "state" parameter that is only known to the servers and never passed to the client. +// We are using a well-known salt to create the "state" parameter for distributed knowledge. +module.exports = function generateOAuthState(seed, salt) { + const hash = crypto.createHash('sha384'); + + hash.update(seed); + hash.update(salt); + + return hash.digest('hex').substr(0, 10); +}; diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/sshd_config b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/sshd_config new file mode 100644 index 0000000000..04b53f9524 --- /dev/null +++ b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/sshd_config @@ -0,0 +1,16 @@ +# This is ssh server systemwide configuration file. +# +# /etc/sshd_config + +Port SSH_PORT +ListenAddress 0.0.0.0 +LoginGraceTime 180 +X11Forwarding yes +Ciphers aes128-cbc,3des-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr +MACs hmac-sha1,hmac-sha1-96 +StrictModes yes +SyslogFacility DAEMON +PasswordAuthentication yes +PermitEmptyPasswords no +PermitRootLogin yes +Subsystem sftp internal-sftp From e2c3ea8a2c25178994a529f588393bc78d2c3173 Mon Sep 17 00:00:00 2001 From: TJ Durnford Date: Thu, 20 Feb 2020 11:50:09 -0800 Subject: [PATCH 02/12] renamed directory --- .../src/routes/aad/oauth/authorize.js | 30 ------------------ .../.dockerignore | 0 .../Dockerfile | 0 .../Dockerfile-run | 0 .../README.md | 0 .../app/.env | 0 .../app/.gitignore | 0 .../app/package-lock.json | 0 .../app/package.json | 0 .../app/public/favicon.ico | Bin .../public/images/BotServices-Translucent.svg | 0 .../app/public/images/BotServices.png | Bin .../app/public/images/BotServices.svg | 0 .../app/public/images/Microsoft-32px.png | Bin .../app/public/images/Microsoft-64px.png | Bin .../images/Microsoft-Graph-64px-DDD-White.png | Bin .../images/Microsoft-Graph-64px-EEE-White.png | Bin .../public/images/Microsoft-Graph-64px.png | Bin .../app/public/index.html | 0 .../app/public/manifest.json | 0 .../app/serve.json | 0 .../app/src/App.css | 0 .../app/src/App.js | 0 .../app/src/index.css | 0 .../app/src/index.js | 0 .../app/src/oauth/Composer.js | 0 .../app/src/oauth/Context.js | 0 .../app/src/oauth/fetchProfileDisplayName.js | 0 .../src/oauth/fetchProfilePhotoAsBase64.js | 0 .../app/src/serviceWorker.js | 0 .../app/src/setupProxy.js | 0 .../MicrosoftGraphProfileMenu/ProfileMenu.css | 0 .../src/ui/MicrosoftGraphProfileMenu/index.js | 0 .../OnBehalfOfAttachment/index.css | 0 .../Attachments/OnBehalfOfAttachment/index.js | 0 .../WebChat/Notifications/AppSignInToast.js | 0 .../WebChat/Notifications/BotSignInToast.js | 0 .../TraditionalBotAuthenticationToast.js | 0 .../src/ui/WebChat/Notifications/index.css | 0 .../app/src/ui/WebChat/Notifications/index.js | 0 .../app/src/ui/WebChat/index.css | 0 .../app/src/ui/WebChat/index.js | 2 +- .../app/src/utils/fetchJSON.js | 0 .../app/src/utils/requiresInteraction.js | 0 .../azure-pipelines.yml | 6 ++-- .../bot/.eslintrc.js | 0 .../bot/.gitignore | 0 .../bot/README.md | 0 .../bot/bots/authBot.js | 0 .../bot/bots/dialogBot.js | 0 .../new-rg-parameters.json | 0 .../preexisting-rg-parameters.json | 0 .../template-with-new-rg.json | 0 .../template-with-preexisting-rg.json | 0 .../bot/dialogs/logoutDialog.js | 0 .../bot/dialogs/mainDialog.js | 0 .../bot/index.js | 0 .../bot/oAuthHelpers.js | 0 .../bot/package-lock.json | 0 .../bot/package.json | 0 .../bot/simple-graph-client.js | 0 .../docker-compose.yml | 0 .../init.sh | 0 .../rest-api/.gitignore | 0 .../rest-api/package-lock.json | 0 .../rest-api/package.json | 0 .../rest-api/src/encodeBase64URL.js | 0 .../rest-api/src/exchangeAccessToken.js | 0 .../rest-api/src/generateDirectLineToken.js | 4 ++- .../rest-api/src/index.js | 1 - .../rest-api/src/routes/aad/oauth/callback.js | 0 .../aad/oauth/createPKCECodeChallenge.js | 0 .../aad/oauth/createPKCECodeVerifier.js | 0 .../rest-api/src/routes/aad/settings.js | 0 .../rest-api/src/routes/botMessages.js | 0 .../rest-api/src/routes/directLine/token.js | 0 .../src/utils/createHTMLWithPostMessage.js | 0 .../rest-api/src/utils/fetchJSON.js | 0 .../rest-api/src/utils/generateOAuthState.js | 0 .../rest-api/src/utils/uniqueID.js | 12 +++++++ .../sshd_config | 0 81 files changed, 19 insertions(+), 36 deletions(-) delete mode 100644 samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/authorize.js rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/.dockerignore (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/Dockerfile (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/Dockerfile-run (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/README.md (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/.env (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/.gitignore (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/package-lock.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/package.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/public/favicon.ico (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/public/images/BotServices-Translucent.svg (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/public/images/BotServices.png (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/public/images/BotServices.svg (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/public/images/Microsoft-32px.png (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/public/images/Microsoft-64px.png (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/public/images/Microsoft-Graph-64px-DDD-White.png (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/public/images/Microsoft-Graph-64px-EEE-White.png (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/public/images/Microsoft-Graph-64px.png (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/public/index.html (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/public/manifest.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/serve.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/App.css (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/App.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/index.css (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/index.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/oauth/Composer.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/oauth/Context.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/oauth/fetchProfileDisplayName.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/oauth/fetchProfilePhotoAsBase64.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/serviceWorker.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/setupProxy.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/ui/MicrosoftGraphProfileMenu/ProfileMenu.css (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/ui/MicrosoftGraphProfileMenu/index.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.css (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/ui/WebChat/Notifications/AppSignInToast.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/ui/WebChat/Notifications/BotSignInToast.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/ui/WebChat/Notifications/TraditionalBotAuthenticationToast.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/ui/WebChat/Notifications/index.css (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/ui/WebChat/Notifications/index.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/ui/WebChat/index.css (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/ui/WebChat/index.js (96%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/utils/fetchJSON.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/app/src/utils/requiresInteraction.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/azure-pipelines.yml (75%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/.eslintrc.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/.gitignore (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/README.md (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/bots/authBot.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/bots/dialogBot.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/deploymentTemplates/new-rg-parameters.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/deploymentTemplates/preexisting-rg-parameters.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/deploymentTemplates/template-with-new-rg.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/deploymentTemplates/template-with-preexisting-rg.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/dialogs/logoutDialog.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/dialogs/mainDialog.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/index.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/oAuthHelpers.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/package-lock.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/package.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/bot/simple-graph-client.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/docker-compose.yml (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/init.sh (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/.gitignore (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/package-lock.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/package.json (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/encodeBase64URL.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/exchangeAccessToken.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/generateDirectLineToken.js (80%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/index.js (95%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/routes/aad/oauth/callback.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/routes/aad/oauth/createPKCECodeChallenge.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/routes/aad/oauth/createPKCECodeVerifier.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/routes/aad/settings.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/routes/botMessages.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/routes/directLine/token.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/utils/createHTMLWithPostMessage.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/utils/fetchJSON.js (100%) rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/rest-api/src/utils/generateOAuthState.js (100%) create mode 100644 samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/utils/uniqueID.js rename samples/07.advanced-web-chat-apps/{e.soo-on-behalf-of-authentication => e.sso-on-behalf-of-authentication}/sshd_config (100%) diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/authorize.js b/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/authorize.js deleted file mode 100644 index da0c4d1762..0000000000 --- a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/authorize.js +++ /dev/null @@ -1,30 +0,0 @@ -const { randomBytes } = require('crypto'); -const createPKCECodeChallenge = require('./createPKCECodeChallenge'); - -const { AAD_OAUTH_AUTHORIZE_URL, AAD_OAUTH_CLIENT_ID, AAD_OAUTH_REDIRECT_URI, AAD_OAUTH_SCOPE } = process.env; - -// GET /api/aad/oauth/authorize -// Redirects to https://login.microsoftonline.com/12345678-1234-5678-abcd-12345678abcd/oauth2/v2.0/authorize -module.exports = (_, res) => { - const seed = randomBytes(32); - const challenge = createPKCECodeChallenge(seed); - const params = new URLSearchParams({ - client_id: AAD_OAUTH_CLIENT_ID, - code_challenge: challenge, - code_challenge_method: 'S256', - - // Azure Active Directory does not support having additional URL query parameters in the URL. - // This is to prevent Covert Redirect attack. - // https://blogs.msdn.microsoft.com/aaddevsup/2018/04/18/query-string-is-not-allowed-in-redirect_uri-for-azure-ad/ - redirect_uri: AAD_OAUTH_REDIRECT_URI, - response_type: 'code', - scope: AAD_OAUTH_SCOPE, - - // https://tools.ietf.org/html/draft-ietf-oauth-browser-based-apps-00#section-9.4 - // Excerpt: ...using the "state" parameter to link client requests and responses to prevent CSRF (Cross-Site Request Forgery) attacks. - state: seed.toString('base64') - }); - - res.setHeader('location', `${AAD_OAUTH_AUTHORIZE_URL}?${params}`); - res.send(302); -}; diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/.dockerignore b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/.dockerignore similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/.dockerignore rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/.dockerignore diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/Dockerfile similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/Dockerfile diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile-run b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/Dockerfile-run similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/Dockerfile-run rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/Dockerfile-run diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/README.md b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/README.md similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/README.md rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/README.md diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/.env b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/.env similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/.env rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/.env diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/.gitignore b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/.gitignore similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/.gitignore rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/.gitignore diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/package-lock.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/package-lock.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/package-lock.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/package-lock.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/package.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/package.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/package.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/package.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/favicon.ico b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/favicon.ico similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/favicon.ico rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/favicon.ico diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/BotServices-Translucent.svg b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/BotServices-Translucent.svg similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/BotServices-Translucent.svg rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/BotServices-Translucent.svg diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/BotServices.png b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/BotServices.png similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/BotServices.png rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/BotServices.png diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/BotServices.svg b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/BotServices.svg similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/BotServices.svg rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/BotServices.svg diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-32px.png b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/Microsoft-32px.png similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-32px.png rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/Microsoft-32px.png diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-64px.png b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/Microsoft-64px.png similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-64px.png rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/Microsoft-64px.png diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px-DDD-White.png b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px-DDD-White.png similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px-DDD-White.png rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px-DDD-White.png diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px-EEE-White.png b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px-EEE-White.png similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px-EEE-White.png rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px-EEE-White.png diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px.png b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px.png similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px.png rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/images/Microsoft-Graph-64px.png diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/index.html b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/index.html similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/index.html rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/index.html diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/manifest.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/manifest.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/public/manifest.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/public/manifest.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/serve.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/serve.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/serve.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/serve.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/App.css b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/App.css similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/App.css rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/App.css diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/App.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/App.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/App.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/App.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/index.css b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/index.css similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/index.css rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/index.css diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/index.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/index.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/index.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/index.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/Composer.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/oauth/Composer.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/Composer.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/oauth/Composer.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/Context.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/oauth/Context.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/Context.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/oauth/Context.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/fetchProfileDisplayName.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/oauth/fetchProfileDisplayName.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/fetchProfileDisplayName.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/oauth/fetchProfileDisplayName.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/fetchProfilePhotoAsBase64.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/oauth/fetchProfilePhotoAsBase64.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/oauth/fetchProfilePhotoAsBase64.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/oauth/fetchProfilePhotoAsBase64.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/serviceWorker.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/serviceWorker.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/serviceWorker.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/serviceWorker.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/setupProxy.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/setupProxy.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/setupProxy.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/setupProxy.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/MicrosoftGraphProfileMenu/ProfileMenu.css b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/MicrosoftGraphProfileMenu/ProfileMenu.css similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/MicrosoftGraphProfileMenu/ProfileMenu.css rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/MicrosoftGraphProfileMenu/ProfileMenu.css diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/MicrosoftGraphProfileMenu/index.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/MicrosoftGraphProfileMenu/index.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/MicrosoftGraphProfileMenu/index.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/MicrosoftGraphProfileMenu/index.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.css b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.css similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.css rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.css diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/AppSignInToast.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/AppSignInToast.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/AppSignInToast.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/AppSignInToast.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/BotSignInToast.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/BotSignInToast.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/BotSignInToast.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/BotSignInToast.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/TraditionalBotAuthenticationToast.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/TraditionalBotAuthenticationToast.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/TraditionalBotAuthenticationToast.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/TraditionalBotAuthenticationToast.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/index.css b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/index.css similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/index.css rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/index.css diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/index.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/index.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/index.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Notifications/index.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/index.css b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/index.css similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/index.css rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/index.css diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/index.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/index.js similarity index 96% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/index.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/index.js index 19f1e3c9e7..fc23c4e965 100644 --- a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/ui/WebChat/index.js +++ b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/index.js @@ -1,5 +1,5 @@ import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react'; -import ReactWebChat, { createDirectLine, createStore, hooks } from 'botframework-webchat'; +import ReactWebChat, { createDirectLine, createStore } from 'botframework-webchat'; import OAuthContext from '../../oauth/Context'; import fetchJSON from '../../utils/fetchJSON'; diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/utils/fetchJSON.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/utils/fetchJSON.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/utils/fetchJSON.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/utils/fetchJSON.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/utils/requiresInteraction.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/utils/requiresInteraction.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/app/src/utils/requiresInteraction.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/utils/requiresInteraction.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/azure-pipelines.yml b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/azure-pipelines.yml similarity index 75% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/azure-pipelines.yml rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/azure-pipelines.yml index 45c225b419..a987c86583 100644 --- a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/azure-pipelines.yml +++ b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/azure-pipelines.yml @@ -8,7 +8,7 @@ trigger: - sample-sso paths: include: - - samples/07.advanced-web-chat-apps/b.sso-for-enterprise + - samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication steps: - task: DockerInstaller@0 @@ -20,7 +20,7 @@ steps: displayName: "Build builder container" inputs: command: build - Dockerfile: "samples/07.advanced-web-chat-apps/b.sso-for-enterprise/Dockerfile" + Dockerfile: "samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/Dockerfile" arguments: "-t builder" - task: Docker@2 @@ -41,7 +41,7 @@ steps: command: rm arguments: "builder-image" - - bash: "cp samples/07.advanced-web-chat-apps/b.sso-for-enterprise/Dockerfile-run $BUILD_ARTIFACTSTAGINGDIRECTORY/Dockerfile" + - bash: "cp samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/Dockerfile-run $BUILD_ARTIFACTSTAGINGDIRECTORY/Dockerfile" displayName: "Copy Dockerfile" - task: PublishBuildArtifacts@1 diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/.eslintrc.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/.eslintrc.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/.eslintrc.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/.eslintrc.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/.gitignore b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/.gitignore similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/.gitignore rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/.gitignore diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/README.md b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/README.md similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/README.md rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/README.md diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/bots/authBot.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/bots/authBot.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/bots/authBot.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/bots/authBot.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/bots/dialogBot.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/bots/dialogBot.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/bots/dialogBot.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/bots/dialogBot.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/new-rg-parameters.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/deploymentTemplates/new-rg-parameters.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/new-rg-parameters.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/deploymentTemplates/new-rg-parameters.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/preexisting-rg-parameters.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/deploymentTemplates/preexisting-rg-parameters.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/preexisting-rg-parameters.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/deploymentTemplates/preexisting-rg-parameters.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/template-with-new-rg.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/deploymentTemplates/template-with-new-rg.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/template-with-new-rg.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/deploymentTemplates/template-with-new-rg.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/template-with-preexisting-rg.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/deploymentTemplates/template-with-preexisting-rg.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/deploymentTemplates/template-with-preexisting-rg.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/deploymentTemplates/template-with-preexisting-rg.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/dialogs/logoutDialog.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/dialogs/logoutDialog.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/dialogs/logoutDialog.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/dialogs/logoutDialog.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/dialogs/mainDialog.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/dialogs/mainDialog.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/dialogs/mainDialog.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/dialogs/mainDialog.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/index.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/index.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/index.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/index.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/oAuthHelpers.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/oAuthHelpers.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/oAuthHelpers.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/oAuthHelpers.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/package-lock.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/package-lock.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/package-lock.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/package-lock.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/package.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/package.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/package.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/package.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/simple-graph-client.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/simple-graph-client.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/bot/simple-graph-client.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/bot/simple-graph-client.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/docker-compose.yml b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/docker-compose.yml similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/docker-compose.yml rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/docker-compose.yml diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/init.sh b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/init.sh similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/init.sh rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/init.sh diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/.gitignore b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/.gitignore similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/.gitignore rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/.gitignore diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/package-lock.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/package-lock.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/package-lock.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/package-lock.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/package.json b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/package.json similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/package.json rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/package.json diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/encodeBase64URL.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/encodeBase64URL.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/encodeBase64URL.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/encodeBase64URL.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/exchangeAccessToken.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/exchangeAccessToken.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/exchangeAccessToken.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/exchangeAccessToken.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/generateDirectLineToken.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/generateDirectLineToken.js similarity index 80% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/generateDirectLineToken.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/generateDirectLineToken.js index 02ec89a1b9..aeaccd9348 100644 --- a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/generateDirectLineToken.js +++ b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/generateDirectLineToken.js @@ -1,11 +1,13 @@ const fetchJSON = require('./utils/fetchJSON'); +const uniqueID = require('./utils/uniqueID'); // Generates a new Direct Line token given the secret. module.exports = async function generateDirectLineToken(secret) { // You should consider using Enhanced Direct Line Authentication to protect the user ID. // https://blog.botframework.com/2018/09/25/enhanced-direct-line-authentication-features/ + const userID = uniqueID().substr(0, 10); const { token } = await fetchJSON('https://directline.botframework.com/v3/directline/tokens/generate', { - body: JSON.stringify({ user: { id: 'dl_user_id_1', name: 'username' } }), + body: JSON.stringify({ user: { id: `dl_${userID}`, name: 'username' } }), headers: { authorization: `Bearer ${secret}`, 'Content-type': 'application/json' diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/index.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/index.js similarity index 95% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/index.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/index.js index cac0c65cff..0ba9fc8eb9 100644 --- a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/index.js +++ b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/index.js @@ -32,7 +32,6 @@ server.use(restify.plugins.queryParser()); const proxy = httpProxy.createProxyServer(); // Registering routes. -server.get('/api/aad/oauth/authorize', require('./routes/aad/oauth/authorize')); server.get('/api/aad/oauth/callback', require('./routes/aad/oauth/callback')); server.get('/api/aad/settings', require('./routes/aad/settings')); server.get('/api/directline/token', require('./routes/directLine/token')); diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/callback.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/callback.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/callback.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/callback.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/createPKCECodeChallenge.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/createPKCECodeChallenge.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/createPKCECodeChallenge.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/createPKCECodeChallenge.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/createPKCECodeVerifier.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/createPKCECodeVerifier.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/createPKCECodeVerifier.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/aad/oauth/createPKCECodeVerifier.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/settings.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/aad/settings.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/aad/settings.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/aad/settings.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/botMessages.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/botMessages.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/botMessages.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/botMessages.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/directLine/token.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/directLine/token.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/routes/directLine/token.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/routes/directLine/token.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/createHTMLWithPostMessage.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/utils/createHTMLWithPostMessage.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/createHTMLWithPostMessage.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/utils/createHTMLWithPostMessage.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/fetchJSON.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/utils/fetchJSON.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/fetchJSON.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/utils/fetchJSON.js diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/generateOAuthState.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/utils/generateOAuthState.js similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/rest-api/src/utils/generateOAuthState.js rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/utils/generateOAuthState.js diff --git a/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/utils/uniqueID.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/utils/uniqueID.js new file mode 100644 index 0000000000..a11e3ff181 --- /dev/null +++ b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/rest-api/src/utils/uniqueID.js @@ -0,0 +1,12 @@ +/* eslint no-magic-numbers: ["error", { "ignore": [2, 36] }] */ + +const random = require('math-random'); + +module.exports = function uniqueID() { + return ( + Date.now() + + random() + .toString(36) + .substr(2) + ); +}; diff --git a/samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/sshd_config b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/sshd_config similarity index 100% rename from samples/07.advanced-web-chat-apps/e.soo-on-behalf-of-authentication/sshd_config rename to samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/sshd_config From cdfb4f13ca129f9704bf185b8b815957acfb4f58 Mon Sep 17 00:00:00 2001 From: TJ Durnford Date: Thu, 20 Feb 2020 12:16:52 -0800 Subject: [PATCH 03/12] Clean up --- .../component/src/hooks/useSetNotification.js | 1 - .../OnBehalfOfAttachment/index.css | 71 ----------- .../Attachments/OnBehalfOfAttachment/index.js | 112 ------------------ .../WebChat/Notifications/AppSignInToast.js | 2 +- .../WebChat/Notifications/BotSignInToast.js | 24 ++-- .../app/src/ui/WebChat/index.js | 2 +- 6 files changed, 12 insertions(+), 200 deletions(-) delete mode 100644 samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.css delete mode 100644 samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.js diff --git a/packages/component/src/hooks/useSetNotification.js b/packages/component/src/hooks/useSetNotification.js index f5062c4a40..5c98e252db 100644 --- a/packages/component/src/hooks/useSetNotification.js +++ b/packages/component/src/hooks/useSetNotification.js @@ -1,6 +1,5 @@ import useWebChatUIContext from './internal/useWebChatUIContext'; export default function useSetNotification() { - console.log(useWebChatUIContext()); return useWebChatUIContext().setNotification; } diff --git a/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.css b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.css deleted file mode 100644 index 40424246d1..0000000000 --- a/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.css +++ /dev/null @@ -1,71 +0,0 @@ -.button-container { - display: flex; - flex: 1; - position: relative; -} - -.card { - font-family: inherit; - padding: 10px; -} - -.card > .buttons { - align-items: stretch; - display: flex; - flex-direction: column; -} - -.card > .buttons > .button-container > button { - flex: 1; - color: #0063B1; - background-color: white; - border-style: solid; - border-width: 1px; - font-weight: 600; - padding: 10px -} - -.card > .buttons > .button-container:last-of-type { - margin-top: 8px; -} - -.container { - width: 10px; - text-align: center; -} - -.status { - position: absolute; - top: 9px; - right: 9px; -} - -.separator { - height: 8px; -} - -/* - Your use of the content in the files referenced here is subject to the terms of the license at https://aka.ms/fabric-assets-license -*/ -@font-face { - font-family: 'FabricMDL2Icons'; - src: url('data:application/octet-stream;base64,d09GRgABAAAAAAi4AA4AAAAAEIgAA6PXAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABRAAAAEgAAABgOcN1TGNtYXAAAAGMAAAAMgAAAUIADfEjY3Z0IAAAAcAAAAAgAAAAKgnZCa9mcGdtAAAB4AAAAPAAAAFZ/J7mjmdhc3AAAALQAAAADAAAAAwACAAbZ2x5ZgAAAtwAAADKAAAA6E/ELIVoZWFkAAADqAAAADIAAAA2AVv+72hoZWEAAAPcAAAAFQAAACQQAQgDaG10eAAAA/QAAAAIAAAACA0qAKZsb2NhAAAD/AAAAAYAAAAGAHQAFm1heHAAAAQEAAAAHAAAACAAGQGVbmFtZQAABCAAAAP4AAAJ+pKT8VRwb3N0AAAIGAAAABQAAAAg/1EAeXByZXAAAAgsAAAAiQAAANN4vfIOeJxjYGGbyjiBgZWBgXUWqzEDA6M0hGa+yJDGJMTBysrFyMQIBgxAIMCAAL7BCgoMDu9r39dygPkQkgGsjgXCU2BgAADpWQi4eJxjYGBgZoBgGQZGBhCwAfIYwXwWBgUgzQKEQP772v//IaRAC1QlAyMbw4gHAMeDCB0AAHicY9BiCGUoYGhgWMXIwNjA7MB4gMEBiwgQAACqHAeVeJxdj79Ow0AMxnMktIQnQDohnXUqQ5WInemGSyTUJSUM56WA1Eqk74CUhcUDz+JuGfNiCMwR/i62v8/6fL9zp/nJfHacpUcqKVacN+Gg1AsO6u2Z/fkhT+82ZWFM1XlW92XBagmia04X9U2waMjQ9ZZMbR4ftpwtYpfFjvDScNKGTuptAHaov8cd4lU8ksUjhBLfT/F9jEv6tSxWhtOLJqwD916z86gBTMVjE3j0GhB/yKQ/dWcT42w5ZdvATnOCRJ/KAvdEmoT7S49/9aCS/4b7bci/q0H1Tdz0FvSHYcGCsKGXZ9tQCRpg+Q6E/GTGAAEAAgAIAAr//wAPeJxjYGJYxsDA0sJaxsDMwM7AYC6oKKiqKKi4jPnen21M2/56MbCW/eqawuLHAARMIIIDCBmkGawYGBiNWOSYhERFmPiYWJSVVPSYmExNhOyYVISNzMwZ7RhNTfSYlJXY2BnV1ZSV+JhERcTkGeUYWRh6Gdke727z9Gzb/fjfr97ef79gPEY2CTENfsa1/AKCshpiopr8/xaUKeiKacgJCvIf5tfkYMCmpRdq3K+9giCtGqJiGrKCAmCtgnLqIFMO8wsyMAAARXY8lwAAeJxjYGRgYGBefH2Cw4478fw2Xxm4ORhAYP/fgw0g+patzywQzcEAFudkYAJRAHQMCqoAAHicY2BkYOBgAAE4yciACpgAAsoAHQAAAAUqAKYIAAAAAAAAFgB0AAB4nGNgZGBgYGKwBmIQYASTXCDMGAliAgAI7gCweJy1VM2KHDcQrtkZezc4XkIg4KMOJqyXocdeG5vYp8U/J+9lbRZ8CWi6Nd3CPS0hqd10yCFHH/IYuRjyFCGBHHP2E/icU46pKqlndj0TswlkmlF/KtXvV6UGgBujr2EE8XcX/xGP4EvcRbwDu/A04THKnyc8Qfxtwlfgc7AJX4Uv4PuEd+Eb+DHhPfgKfkv4GhzC+4Svj34dTRLeh8Od3zHKaPIZ7oqdPxMewc3xWcI7sD/+LuExyt8mPEH8c8JX4Mb4j4Svghh/SHgX3GQv4T04nAx+rsHLyU8JXx+/nfyV8D683Pvhl3fi6PadB+JE5854swjisXHWOBm0aTJxXNfiVJdV8OJUeeXeqCJ7JudO5+LkyfMjcey9Cv5UlW0t3ebBpuRMOY+exd3s/r14Sofx7IUqjRLaCymCk4VaSvdamIUIlTqXX+lMa0mcm6WVjVY+25p8FYJ9OJt1XZcth/MMbWaht6Z00lb9bGGa4Gdrc99aW2tVCDrIxCvTiqXsResVJoGJkVgEI3KnZFBTUWhva9lPhWwKYZ3G0xxVFL6lF1a5pQ4B3c17LqLWuWrIFx54YdwAFhRhulmqdaZo8zAVxDzaTslmCKAb0VU6r85l1mFQ3eR1W2CbVtmbpu7Fgb4l1HKOuazV0cOnsmX1QjelcMoH7BSxug5A5itfj5iBA41RglpSC5zGqIXpmtrI4iJ7MlKlHJVjMBSubbBtEIWiMkmnUrW9yCgOY9MndWoIOkR+Kj3XmHN2+W7DOxBwBLfhDjxAdAIacnBgwON/AQFljxE5vPO0SpRoRA1keHIMNT4CTlFWQoVnnncK3wq13+BaoOYztJvjnnxTjCf4ZTlie8+aZEdWJbToT6LmZSwuo3PGefiUs8AvXQb34d4F28HyvN0LzsbgKlCHqpL4D8xAgdIlZ/kaZcQSnVSsu42/kvctMjho5/he4l5iTprZyv4F88RzQOlDmOHT8ZOhv4/tsxRnhrhnLyX7seihR+mCvVG1s63RPedssSOa+yhWFtT7V1yTYCZ6fLfMXWQiMjZok8xw1Q41qA4FU9wXrGe54z1LiA+KY7kz0TZPXlTaS/Ztua9Uc+AzsppzHkMnaq6IrIa8ooXnLrgNyWJVw/RSXbW8L9Amx/2U+YozH+NOV3E+rkDzJHbMU47rds66VClp51hNy3NXbOWebGpGB6h/C980ofPEyzbvMYf/yu3ae8GeSpQ5nuOQ7tQwq9sqGKJv5vXo3AxQJbGWwPGGW0D+Y60FSjqu3PCt/NTsyQtTpbgvJq2xqohbvlktW1K2QzcHP6RZ803+5xmNX8YmdWbtfbghOrFM80P5zpnp2Nv/4W7/DV7sOJR4nGNgZgCD/34M5QyYgAkAKSwBynic28CgzbCJkZNJm3ETF4jcztWaG2qrysChvZ07NdhBTwbE4onwsNCQBLF4nc215YVBLD4dFRkRHhCLX05CmI8DxBLg4+FkZwGxBMEAxBLaMKEgwADIYtjOCDeaCW40M9xoFrjRrHCj2eQkoUazw43mgBvNCTd6kzAju/YGBgXX2kwJFwDEASgaAAAA') format('truetype'); -} - -.ms-Icon { - -moz-osx-font-smoothing: grayscale; - -webkit-font-smoothing: antialiased; - display: inline-block; - font-family: 'FabricMDL2Icons'; - font-style: normal; - font-weight: normal; - speak: none; -} - -.ms-Icon--SkypeCircleCheck:before { - color: green; - content: "\EF7D"; - font-size: 16px; - padding-top: 4; - } - diff --git a/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.js b/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.js deleted file mode 100644 index 86fbfb76dc..0000000000 --- a/samples/07.advanced-web-chat-apps/e.sso-on-behalf-of-authentication/app/src/ui/WebChat/Attachments/OnBehalfOfAttachment/index.js +++ /dev/null @@ -1,112 +0,0 @@ -import React, { useCallback, useContext, useEffect, useMemo, useState, useRef } from 'react'; -import { hooks } from 'botframework-webchat'; -import { Spinner } from 'office-ui-fabric-react/lib/Spinner'; - -import './index.css'; -import OAuthContext from '../../../../oauth/Context'; - -const { useActivities, usePostActivity } = hooks; - -const AUTHENTICATING = 'AUTHENTICATING'; -const AUTHENTICATION_FAILED = 'AUTHENTICATION_FAILED'; -const AUTHENTICATION_PENDING = 'AUTHENTICATION_PENDING'; -const AUTHENTICATION_SUCCESSFUL = 'AUTHENTICATION_SUCCESSFUL'; - -const OnBehalfOfAttachment = ({ card, next }) => { - const { - attachment: { - content: { connectionName, tokenExchangeResource: { id, uri } = {} } - } - } = card; - const { acquireToken, getAccount } = useContext(OAuthContext); - const [authenticationStatus, setAuthenticationStatus] = useState(AUTHENTICATION_PENDING); - const { current: invokeId } = useRef( - Math.random() - .toString(36) - .substr(2, 10) - ); - const oauthCard = useMemo(() => next(card), [next, card]); - - const [activities] = useActivities(); - const postActivity = usePostActivity(); - - const exchangeToken = useCallback( - async resourceUri => { - const user = getAccount(); - if (user) { - const { accessToken } = await acquireToken({ scopes: [resourceUri] }); - return accessToken; - } - setAuthenticationStatus(AUTHENTICATION_FAILED); - }, - [acquireToken, getAccount] - ); - - useEffect(() => { - const invokeActivity = activities.find( - ({ channelData: { invokeId: activityInvokeId } = {} }) => invokeId === activityInvokeId - ); - if (invokeActivity) { - const { channelData: { state } = {} } = invokeActivity; - if (state === 'send failed') { - setAuthenticationStatus(AUTHENTICATION_FAILED); - } else if (state === 'sent') { - setAuthenticationStatus(AUTHENTICATION_SUCCESSFUL); - } - } - }, [activities, invokeId]); - - useEffect(() => { - if (authenticationStatus === AUTHENTICATING) { - (async function() { - try { - const token = await exchangeToken('api://61598522-abf1-49ba-bbb4-3fb89f4ad9a6/ReadUser'); - token && - postActivity({ - channelData: { invokeId }, - type: 'invoke', - name: 'signin/tokenExchange', - value: { - id, - connectionName, - token - } - }); - } catch (error) { - setAuthenticationStatus(AUTHENTICATION_FAILED); - } - })(); - } - }, [authenticationStatus]); - - const handleClickAllow = useCallback(() => { - authenticationStatus !== AUTHENTICATING && setAuthenticationStatus(AUTHENTICATING); - }, [authenticationStatus, setAuthenticationStatus]); - - if (authenticationStatus === AUTHENTICATION_FAILED) { - return oauthCard; - } - - return ( -
-
The Bot has requested to access your account
-
-
-
- -
- {authenticationStatus === AUTHENTICATING ? ( - - ) : authenticationStatus === AUTHENTICATION_SUCCESSFUL ? ( -