Skip to content

Commit a92a5dc

Browse files
authored
[JS] chore: add ttk settings for oauth samples (#928)
## Linked issues closes: #783 ## Details Provide a list of your changes here. If you are fixing a bug, please provide steps to reproduce the bug. #### Change details > Describe your changes, with screenshots and code snippets as appropriate - add settings to F5/provision/deploy with Teams Toolkit **code snippets**: **screenshots**: ## Attestation Checklist - [x] My code follows the style guidelines of this project - I have checked for/fixed spelling, linting, and other errors - I have commented my code for clarity - I have made corresponding changes to the documentation (we use [TypeDoc](https://typedoc.org/) to document our code) - My changes generate no new warnings - I have added tests that validates my changes, and provides sufficient test coverage. I have tested with: - Local testing - E2E testing in Teams - New and existing unit tests pass locally with my changes ### Additional information > Feel free to add other relevant information below
1 parent 25eeb49 commit a92a5dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1666
-101
lines changed

js/samples/06.auth.oauth.adaptiveCard/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ lib-cov
2222
/**/.vscode
2323
/**/lib
2424
lib
25+
!.vscode
2526

2627
# Coverage directory used by tools like istanbul
2728
coverage
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch Remote (Edge)",
6+
"type": "msedge",
7+
"request": "launch",
8+
"url": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
9+
"presentation": {
10+
"group": "remote",
11+
"order": 1
12+
},
13+
"internalConsoleOptions": "neverOpen"
14+
},
15+
{
16+
"name": "Launch Remote (Chrome)",
17+
"type": "chrome",
18+
"request": "launch",
19+
"url": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
20+
"presentation": {
21+
"group": "remote",
22+
"order": 2
23+
},
24+
"internalConsoleOptions": "neverOpen"
25+
},
26+
{
27+
"name": "Launch App (Edge)",
28+
"type": "msedge",
29+
"request": "launch",
30+
"url": "https://teams.microsoft.com/l/app/${{local:TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
31+
"cascadeTerminateToConfigurations": [
32+
"Attach to Local Service"
33+
],
34+
"presentation": {
35+
"group": "all",
36+
"hidden": true
37+
},
38+
"internalConsoleOptions": "neverOpen"
39+
},
40+
{
41+
"name": "Launch App (Chrome)",
42+
"type": "chrome",
43+
"request": "launch",
44+
"url": "https://teams.microsoft.com/l/app/${{local:TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
45+
"cascadeTerminateToConfigurations": [
46+
"Attach to Local Service"
47+
],
48+
"presentation": {
49+
"group": "all",
50+
"hidden": true
51+
},
52+
"internalConsoleOptions": "neverOpen"
53+
},
54+
{
55+
"name": "Attach to Local Service",
56+
"type": "node",
57+
"request": "attach",
58+
"port": 9239,
59+
"restart": true,
60+
"presentation": {
61+
"group": "all",
62+
"hidden": true
63+
},
64+
"internalConsoleOptions": "neverOpen",
65+
"resolveSourceMapLocations": [
66+
"${workspaceFolder}/**"
67+
]
68+
}
69+
],
70+
"compounds": [
71+
{
72+
"name": "Debug (Edge)",
73+
"configurations": [
74+
"Launch App (Edge)",
75+
"Attach to Local Service"
76+
],
77+
"preLaunchTask": "Start Teams App Locally",
78+
"presentation": {
79+
"group": "all",
80+
"order": 1
81+
},
82+
"stopAll": true
83+
},
84+
{
85+
"name": "Debug (Chrome)",
86+
"configurations": [
87+
"Launch App (Chrome)",
88+
"Attach to Local Service"
89+
],
90+
"preLaunchTask": "Start Teams App Locally",
91+
"presentation": {
92+
"group": "all",
93+
"order": 2
94+
},
95+
"stopAll": true
96+
}
97+
]
98+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// This file is automatically generated by Teams Toolkit.
2+
// The teamsfx tasks defined in this file require Teams Toolkit version >= 5.0.0.
3+
// See https://aka.ms/teamsfx-tasks for details on how to customize each task.
4+
{
5+
"version": "2.0.0",
6+
"tasks": [
7+
{
8+
"label": "Start Teams App Locally",
9+
"dependsOn": [
10+
"Validate prerequisites",
11+
"Start local tunnel",
12+
"Provision",
13+
"Deploy",
14+
"Start application"
15+
],
16+
"dependsOrder": "sequence"
17+
},
18+
{
19+
// Check all required prerequisites.
20+
// See https://aka.ms/teamsfx-tasks/check-prerequisites to know the details and how to customize the args.
21+
"label": "Validate prerequisites",
22+
"type": "teamsfx",
23+
"command": "debug-check-prerequisites",
24+
"args": {
25+
"prerequisites": [
26+
"nodejs", // Validate if Node.js is installed.
27+
"m365Account", // Sign-in prompt for Microsoft 365 account, then validate if the account enables the sideloading permission.
28+
"portOccupancy" // Validate available ports to ensure those debug ones are not occupied.
29+
],
30+
"portOccupancy": [
31+
3978, // app service port
32+
9239 // app inspector port for Node.js debugger
33+
]
34+
}
35+
},
36+
{
37+
// Start the local tunnel service to forward public URL to local port and inspect traffic.
38+
// See https://aka.ms/teamsfx-tasks/local-tunnel for the detailed args definitions.
39+
"label": "Start local tunnel",
40+
"type": "teamsfx",
41+
"command": "debug-start-local-tunnel",
42+
"args": {
43+
"type": "dev-tunnel",
44+
"ports": [
45+
{
46+
"portNumber": 3978,
47+
"protocol": "http",
48+
"access": "public",
49+
"writeToEnvironmentFile": {
50+
"endpoint": "BOT_ENDPOINT", // output tunnel endpoint as BOT_ENDPOINT
51+
"domain": "BOT_DOMAIN" // output tunnel domain as BOT_DOMAIN
52+
}
53+
}
54+
],
55+
"env": "local"
56+
},
57+
"isBackground": true,
58+
"problemMatcher": "$teamsfx-local-tunnel-watch"
59+
},
60+
{
61+
// Create the debug resources.
62+
// See https://aka.ms/teamsfx-tasks/provision to know the details and how to customize the args.
63+
"label": "Provision",
64+
"type": "teamsfx",
65+
"command": "provision",
66+
"args": {
67+
"env": "local"
68+
}
69+
},
70+
{
71+
// Build project.
72+
// See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args.
73+
"label": "Deploy",
74+
"type": "teamsfx",
75+
"command": "deploy",
76+
"args": {
77+
"env": "local"
78+
}
79+
},
80+
{
81+
"label": "Start application",
82+
"type": "shell",
83+
"command": "npm run dev:teamsfx",
84+
"isBackground": true,
85+
"options": {
86+
"cwd": "${workspaceFolder}"
87+
},
88+
"problemMatcher": {
89+
"pattern": [
90+
{
91+
"regexp": "^.*$",
92+
"file": 0,
93+
"location": 1,
94+
"message": 2
95+
}
96+
],
97+
"background": {
98+
"activeOnStart": true,
99+
"beginsPattern": "[nodemon] starting",
100+
"endsPattern": "restify listening to|Bot/ME service listening at|[nodemon] app crashed"
101+
}
102+
}
103+
}
104+
]
105+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.webappignore
2+
.fx
3+
.deployment
4+
.localConfigs
5+
.notification.localstore.json
6+
.vscode
7+
*.js.map
8+
*.ts.map
9+
*.ts
10+
.git*
11+
.tsbuildinfo
12+
CHANGELOG.md
13+
readme.md
14+
local.settings.json
15+
.env
16+
test
17+
tsconfig.json
18+
.DS_Store
19+
teamsapp.yml
20+
teamsapp.*.yml
21+
/env/
22+
/node_modules/.bin
23+
/node_modules/ts-node
24+
/node_modules/typescript
25+
/appPackage/
26+
/infra/
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"id": "${{AAD_APP_OBJECT_ID}}",
3+
"appId": "${{BOT_ID}}",
4+
"name": "AdaptiveCardSSO-${{TEAMSFX_ENV}}",
5+
"accessTokenAcceptedVersion": 2,
6+
"signInAudience": "AzureADMultipleOrgs",
7+
"optionalClaims": {
8+
"idToken": [],
9+
"accessToken": [
10+
{
11+
"name": "idtyp",
12+
"source": null,
13+
"essential": false,
14+
"additionalProperties": []
15+
}
16+
],
17+
"saml2Token": []
18+
},
19+
"requiredResourceAccess": [
20+
{
21+
"resourceAppId": "Microsoft Graph",
22+
"resourceAccess": [
23+
{
24+
"id": "User.Read",
25+
"type": "Scope"
26+
}
27+
]
28+
}
29+
],
30+
"oauth2Permissions": [
31+
{
32+
"adminConsentDescription": "Allows Teams to call the app's web APIs as the current user.",
33+
"adminConsentDisplayName": "Teams can access app's web APIs",
34+
"id": "${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}",
35+
"isEnabled": true,
36+
"type": "User",
37+
"userConsentDescription": "Enable Teams to call this app's web APIs with the same rights that you have",
38+
"userConsentDisplayName": "Teams can access app's web APIs and make requests on your behalf",
39+
"value": "access_as_user"
40+
}
41+
],
42+
"preAuthorizedApplications": [
43+
{
44+
"appId": "1fec8e78-bce4-4aaf-ab1b-5451cc387264",
45+
"permissionIds": [
46+
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
47+
]
48+
},
49+
{
50+
"appId": "5e3ce6c0-2b1f-4285-8d4b-75ee78787346",
51+
"permissionIds": [
52+
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
53+
]
54+
},
55+
{
56+
"appId": "d3590ed6-52b3-4102-aeff-aad2292ab01c",
57+
"permissionIds": [
58+
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
59+
]
60+
},
61+
{
62+
"appId": "00000002-0000-0ff1-ce00-000000000000",
63+
"permissionIds": [
64+
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
65+
]
66+
},
67+
{
68+
"appId": "bc59ab01-8403-45c6-8796-ac3ef710b3e3",
69+
"permissionIds": [
70+
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
71+
]
72+
},
73+
{
74+
"appId": "0ec893e0-5785-4de6-99da-4ed124e5296c",
75+
"permissionIds": [
76+
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
77+
]
78+
},
79+
{
80+
"appId": "4765445b-32c6-49b0-83e6-1d93765276ca",
81+
"permissionIds": [
82+
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
83+
]
84+
},
85+
{
86+
"appId": "4345a7b9-9a63-4910-a426-35363201d503",
87+
"permissionIds": [
88+
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
89+
]
90+
}
91+
],
92+
"identifierUris": [
93+
"api://botid-${{BOT_ID}}"
94+
],
95+
"replyUrlsWithType": [
96+
{
97+
"url": "https://token.botframework.com/.auth/web/redirect",
98+
"type": "Web"
99+
}
100+
]
101+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This file includes environment variables that will be committed to git by default.
2+
3+
# Built-in environment variables
4+
TEAMSFX_ENV=dev
5+
APP_NAME_SUFFIX=dev
6+
7+
# Updating AZURE_SUBSCRIPTION_ID or AZURE_RESOURCE_GROUP_NAME after provision may also require an update to RESOURCE_SUFFIX, because some services require a globally unique name across subscriptions/resource groups.
8+
AZURE_SUBSCRIPTION_ID=
9+
AZURE_RESOURCE_GROUP_NAME=
10+
RESOURCE_SUFFIX=
11+
12+
# Generated during provision, you can also add your own variables.
13+
TEAMS_APP_ID=
14+
BOT_ID=
15+
AAD_APP_OBJECT_ID=
16+
AAD_APP_TENANT_ID=
17+
AAD_APP_ACCESS_AS_USER_PERMISSION_ID=
18+
AAD_APP_OAUTH_AUTHORITY_HOST=
19+
AAD_APP_OAUTH_AUTHORITY=

js/samples/06.auth.oauth.adaptiveCard/infra/azure.bicep

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ param serverfarmsName string = resourceBaseName
1919
param webAppName string = resourceBaseName
2020
param location string = resourceGroup().location
2121

22+
param oauthConnectionName string
23+
2224
// Compute resources for your Web App
2325
resource serverfarm 'Microsoft.Web/serverfarms@2021-02-01' = {
2426
kind: 'app'
@@ -60,6 +62,10 @@ resource webApp 'Microsoft.Web/sites@2021-02-01' = {
6062
name: 'MicrosoftAppPassword'
6163
value: botAadAppClientSecret
6264
}
65+
{
66+
name: 'OAUTH_CONNECTION_NAME'
67+
value: oauthConnectionName
68+
}
6369
]
6470
ftpsState: 'FtpsOnly'
6571
}
@@ -74,6 +80,8 @@ module azureBotRegistration './botRegistration/azurebot.bicep' = {
7480
botAadAppClientId: botAadAppClientId
7581
botAppDomain: webApp.properties.defaultHostName
7682
botDisplayName: botDisplayName
83+
botAddAppClientSecret: botAadAppClientSecret
84+
oauthConnectionName: oauthConnectionName
7785
}
7886
}
7987

0 commit comments

Comments
 (0)