Skip to content

Commit a4fce1f

Browse files
authored
Merge pull request #346 from DingmaomaoBJTU/qiowu/fixdoc
2 parents 896996b + 9a8de9c commit a4fce1f

File tree

4 files changed

+74
-62
lines changed

4 files changed

+74
-62
lines changed

samples/react-bot-framework-secure/README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This demo does not include any threat models and is designed for educational pur
2020

2121
## Used SharePoint Framework Version
2222

23-
![1.0](https://img.shields.io/badge/version-1.0-green.svg)
23+
![SPFx 1.10.0](https://img.shields.io/badge/drop-1.10.0-green.svg)
2424

2525
## Applies to
2626

@@ -41,8 +41,8 @@ This demo does not include any threat models and is designed for educational pur
4141

4242
Solution|Author(s)
4343
--------|---------
44-
webpart | STCA BF Channel and ABS (stcabfchannel@microsoft.com) <br/> Stephan Bisser (@stephanbisser, bisser.io)
45-
bot | STCA BF Channel and ABS (stcabfchannel@microsoft.com)
44+
extension | Bot Framework Discussions (msbots@service.microsoft.com) <br/> Stephan Bisser (@stephanbisser, bisser.io)
45+
bot | Bot Framework Discussions (msbots@service.microsoft.com)
4646

4747
## Version history
4848

@@ -63,24 +63,33 @@ Version|Date|Comments
6363
- Clone the repository
6464

6565
```bash
66-
git clone [Placeholder]
66+
git clone https://github.com/pnp/sp-dev-fx-extensions
6767
```
6868

69-
- In a terminal, navigate to `[Placeholder]`
69+
- In a terminal, navigate to `sp-dev-fx-extensions`
7070

7171
```bash
72-
cd [Placeholder]
72+
cd sp-dev-fx-extensions
73+
```
74+
75+
- Navigate to the folder containing this sample
76+
77+
```bash
78+
cd samples
79+
cd react-bot-framework-secure
7380
```
7481

7582
### [Setup bot](./bot/README.md)
7683

84+
- Go to `./bot`
85+
7786
- Install modules
7887

7988
```bash
8089
npm install
8190
```
8291

83-
- Register Connections. You can get it done by [deploy your bot to Azure](https://aka.ms/azuredeployment). Save your bot service endpoint like: "https://YOUR_BOT.azurewebsites.net". Save your AAD Id as YOUR_APP_ID and secret as YOUR_APP_PSW.
92+
- Register Connections. You can get it done by [deploy your bot to Azure](https://aka.ms/azuredeployment). Save your bot service endpoint like: "https://YOUR_BOT.azurewebsites.net". Save your AAD Id as `YOUR_APP_ID` and secret as `YOUR_APP_PSW`.
8493

8594
- [Connect to direct line](https://docs.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-directline?view=azure-bot-service-4.0), copy one of the Secret Key values as YOUR_DIRECT_LINE_SECRET and store this for later usage. This is your ‘Direct Line Secret’.
8695

@@ -96,28 +105,18 @@ Version|Date|Comments
96105

97106
### [Setup extension](./extension/README.md)
98107

99-
- Install modules
100-
101-
```bash
102-
npm install
103-
```
104-
105108
- Edit "BotFrameworkChatPopupApplicationChat.tsx" file to set your bot endpoint (`props.botEndpoint`) directly like `https://YOUR_BOT.azurewebsites.net` for testing purpose (instead of setting it in the Tenant Wide Extensions list):
106109

107110
```ts
108-
generateToken(props.botEndpoint, md5(userId)).then((token: string) => { //change props.botEndpoint to the endpoint directly if you want to test it
109-
if (token) {
110-
setDirectLine(createDirectLine({ token }));
111-
}
112-
});
111+
const token = await this.generateToken(this.props.botEndpoint, md5(userId));
113112
```
114113

115114
- Config CORS \
116115
[CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) must be set on bot app service to enable SharePoint client to get resource from bot service. Follow these steps to add your workbench to bot app service CORS configration:
117116

118117
1. Go to your azure portal
119-
1. Navigate to your bot app service, search for CORS settings
120-
1. Add https://localhost:4321 and https://<YOUR_SITE>.sharepoint.com to CORS origins
118+
2. Navigate to your bot app service, search for CORS settings
119+
3. Add https://localhost:4321 and https://<YOUR_SITE>.sharepoint.com to CORS origins
121120

122121
- In the command line run
123122

samples/react-bot-framework-secure/extension/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ An extension sample that uses the [botframework-webchat module](https://www.npmj
3131
- Edit "BotFrameworkChatPopupApplicationChat.tsx" file to set your bot endpoint (`props.botEndpoint`) directly like `https://YOUR_BOT.azurewebsites.net` for testing purpose (instead of setting it in the Tenant Wide Extensions list):
3232

3333
```ts
34-
generateToken(props.botEndpoint, md5(userId)).then((token: string) => { //change props.botEndpoint to the endpoint directly if you want to test it
35-
if (token) {
36-
setDirectLine(createDirectLine({ token }));
37-
}
38-
});
34+
const token = await this.generateToken(this.props.botEndpoint, md5(userId));
3935
```
4036

4137
- In the command line run
@@ -67,3 +63,5 @@ This Extension illustrates the following concepts on top of the SharePoint Frame
6763

6864
- Using the Bot Framework webchat React component as some kind of flyout element in modern pages
6965
- Adding a bot to modern pages and let users interact with a bot hosted in the Azure Bot Service
66+
67+
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-extensions/samples/react-bot-framework-secure" />

samples/react-bot-framework-sso/README.md

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Sharepoint extension sample with SSO
1+
# SharePoint extension sample with SSO
22

33
## Summary
44

@@ -20,7 +20,7 @@ This demo does not include any threat models and is designed for educational pur
2020

2121
## Used SharePoint Framework Version
2222

23-
![SPFx 1.10](https://img.shields.io/badge/version-1.10-green.svg)
23+
![SPFx 1.10.0](https://img.shields.io/badge/drop-1.10.0-green.svg)
2424

2525
## Applies to
2626

@@ -48,8 +48,8 @@ This demo does not include any threat models and is designed for educational pur
4848

4949
Solution|Author(s)
5050
--------|---------
51-
webpart | STCA BF Channel and ABS (stcabfchannel@microsoft.com) <br/> Stephan Bisser (@stephanbisser, bisser.io)
52-
bot | STCA BF Channel and ABS (stcabfchannel@microsoft.com)
51+
extension | Bot Framework Discussions (msbots@service.microsoft.com) <br/> Stephan Bisser (@stephanbisser, bisser.io)
52+
bot | Bot Framework Discussions (msbots@service.microsoft.com)
5353

5454
## Version history
5555

@@ -70,30 +70,37 @@ Version|Date|Comments
7070
- Clone the repository
7171

7272
```bash
73-
git clone [Placeholder]
73+
git clone https://github.com/pnp/sp-dev-fx-extensions
7474
```
7575

76-
### [Setup bot with Direct Line](./bot/README.md)
76+
- In a terminal, navigate to `sp-dev-fx-extensions`
7777

78-
This part is the same as [the extension web chat sample](Placeholder).
78+
```bash
79+
cd sp-dev-fx-extensions
80+
```
7981

80-
- In a terminal, navigate to `[Placeholder]`
82+
- Navigate to the folder containing this sample
8183

8284
```bash
83-
cd [Placeholder]
85+
cd samples
86+
cd react-bot-framework-sso
8487
```
8588

89+
### [Setup bot with Direct Line](./bot/README.md)
90+
91+
- Go to `./bot`
92+
8693
- Install modules
8794

8895
```bash
8996
npm install
9097
```
9198

92-
- Register connections. You can get it done by [deploy your bot to Azure](https://aka.ms/azuredeployment). Save your bot service endpoint like: "https://YOUR_BOT.azurewebsites.net". Save your AAD Id as YOUR_APP_ID, AAD Name as YOUR_APP_Name and secret as YOUR_APP_PSW.
99+
- Register connections. You can get it done by [deploy your bot to Azure](https://aka.ms/azuredeployment). Save your bot service endpoint like: "https://YOUR_BOT.azurewebsites.net". Save your AAD Id as `YOUR_APP_ID`, AAD Name as `YOUR_APP_Name` and secret as `YOUR_APP_PSW`.
93100

94-
- [Connect to direct line](https://docs.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-directline?view=azure-bot-service-4.0), copy one of the Secret Key values as YOUR_DIRECT_LINE_SECRET and store this for later. This is your Direct Line Secret.
101+
- [Connect to direct line](https://docs.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-directline?view=azure-bot-service-4.0), copy one of the Secret Key values as `YOUR_DIRECT_LINE_SECRET` and store this for later. This is your `Direct Line Secret`.
95102

96-
- Add Direct Line Secret to an .env config file under ./bot
103+
- Add `Direct Line Secret` to an .env config file under ./bot
97104

98105
```bash
99106
MicrosoftAppId=YOUR_APP_ID
@@ -110,7 +117,7 @@ application setup for use in Azure Bot Service.
110117
- Open your bot's application registration
111118
- Save the tenant ID
112119
- Select the "Overview" blade
113-
- On the main pane, copy the content of "Directory (tenant) ID" as YOUR_APP_TENANT and store this for later
120+
- On the main pane, copy the content of "Directory (tenant) ID" as `YOUR_APP_TENANT` and store this for later
114121
- Update Authentication
115122
- Select the "Authentication" blade
116123
- Click "Add a platform" to add web if Web is not added
@@ -122,7 +129,7 @@ application setup for use in Azure Bot Service.
122129
- Select the "Expose an API" blade
123130
- Click the "Add a scope" button under "Scopes defined by this API"
124131
- Click "Save and continue"
125-
- Add a scope named YOUR_AAD_SCOPE_NAME
132+
- Add a scope named `YOUR_AAD_SCOPE_NAME`
126133
- Set "Who can consent?" to "Admins and users"
127134
- Add an admin consent display name
128135
- Add an admin consent description
@@ -131,7 +138,7 @@ application setup for use in Azure Bot Service.
131138
- api://123a45b6-789c-01de-f23g-h4ij5k67a8bc/<YOUR_AAD_SCOPE_NAME>
132139
- Select API permissions
133140
- Click "API Permissions", select"Add a permission"
134-
- Select "My APIs", YOUR_APP_ID, and enable YOUR_AAD_SCOPE_NAME scope \
141+
- Select "My APIs", `YOUR_APP_ID`, and enable `YOUR_AAD_SCOPE_NAME` scope \
135142
Otherwise the non-admin user cannot use SSO.
136143
137144
### Setup Authentication via Azure Bot Services for the Bot
@@ -192,10 +199,19 @@ application setup for use in Azure Bot Service.
192199
],
193200
```
194201
195-
- [Publish and host webpart](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/hosting-webpart-from-office-365-cdn), prepare for approving permissions
202+
- Install modules
203+
204+
```bash
205+
cd ../extension
206+
npm install
207+
```
208+
209+
- [Publish and host extension](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/get-started/hosting-extension-from-office365-cdn), prepare for approving permissions
196210
197211
- Refer [Connect to Azure AD-secured APIs](https://docs.microsoft.com/en-us/sharepoint/api-access) to publish and approve permissions from admin site
198-
- Go to sharepoint admin center
212+
- Please ensure your service principal had been enabled for your AAD account.
213+
- Check "Managed application in local directory" in your AAD overview blade in Azure Portal
214+
- Go to SharePoint admin center
199215
- Find "API Access", approve "<YOUR_APP_Name>"
200216
201217
- (Opt. for hosted bot service) Config CORS \
@@ -204,22 +220,6 @@ application setup for use in Azure Bot Service.
204220
2. Navigate to your bot app service, search for CORS settings
205221
3. Add https://localhost:4321 and https://<YOUR_SITE>.sharepoint.com to CORS origins
206222
207-
- In the command line run
208-
209-
```bash
210-
cd ../extension
211-
npm install
212-
gulp serve --nobrowser
213-
```
214-
215-
- Open up a SharePoint modern page and add the following string to your URL:
216-
217-
```url
218-
?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"f50b07b5-76a5-4e80-9cab-b4ee9a591bf6":{"location":"ClientSideExtension.ApplicationCustomizer"}}
219-
```
220-
221-
If you want to deploy it follow the steps [here](./extension/README.md#deploy).
222-
223223
### Setup OAuth via Azure Active Directory for the SharePoint
224224
225225
The following operations will need an admin account.
@@ -228,7 +228,7 @@ The following operations will need an admin account.
228228
- Open "App registrations", find "SharePoint Online Client Extensibility Web Application Principal"
229229
- Save the client ID
230230
- Select the "Overview" blade
231-
- On the main pane, copy the content of "Application ID" as YOUR_SHAREPOINT_ID and store this for later usage
231+
- On the main pane, copy the content of "Application ID" as `YOUR_SHAREPOINT_ID` and store this for later usage
232232
- Update App Registration Manifest
233233
- Select the "Manifest" blade
234234
- Set `accessTokenAcceptedVersion` to `2`
@@ -238,10 +238,25 @@ The following operations will need an admin account.
238238
- Open your bot's application registration
239239
- Select the "Expose an API" blade
240240
- Click the "Add a client application" under "Authorized client applications"
241-
- Set the client id to the YOUR_SHAREPOINT_ID
241+
- Set the client id to the `YOUR_SHAREPOINT_ID`
242242
- Check the box next to the scope we added in the previous step under "Authorized scopes"
243243
- Click "Add application"
244244

245+
### Test extension
246+
- Go to `extension` folder, in the command line run
247+
248+
```bash
249+
gulp serve --nobrowser
250+
```
251+
252+
- Open up a SharePoint modern page and add the following string to your URL:
253+
254+
```url
255+
?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"f50b07b5-76a5-4e80-9cab-b4ee9a591bf6":{"location":"ClientSideExtension.ApplicationCustomizer"}}
256+
```
257+
258+
If you want to deploy it follow the steps [here](./extension/README.md#deploy).
259+
245260
## Features
246261

247262
**Web Chat integration with SSO**
@@ -335,7 +350,7 @@ const handleClick = useCallback(() => {
335350
336351
Note: The first time users try SSO, users may be presented with an OAuth card to log in. This is because users have not yet given consent to the bot's Azure AD app. To avoid this, users can grant admin consent for any graph permissions requested by the Azure AD app.
337352
338-
Note: due to a SDK bug [here](https://github.com/microsoft/botbuilder-js/issues/3006), the consent card could not be shown properly yet. Granting admin consent may be necessary to workaround this.
353+
Note: due to a [SDK bug](https://github.com/microsoft/botbuilder-js/issues/3006), the consent card could not be shown properly yet. Granting admin consent may be necessary to workaround this.
339354
340355
## Debug URL for testing
341356

samples/react-bot-framework-sso/extension/config/package-solution.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"isDomainIsolated": false,
1010
"webApiPermissionRequests": [
1111
{
12-
"resource": "<YOUR_APP_ID>",
12+
"resource": "<YOUR_APP_Name>",
1313
"scope": "<Your_AAD_Scope_Name>"
1414
}
1515
],

0 commit comments

Comments
 (0)