Skip to content

Commit

Permalink
Merge pull request OfficeDev#1334 from OfficeDev/v-hrajandira/CsharpN…
Browse files Browse the repository at this point in the history
…ewToolkitPR13

PR 13 - Implement New toolkit version csharp samples
  • Loading branch information
Harikrishnan-MSFT authored Aug 21, 2024
2 parents 08c1ccf + bf264fa commit dbc79cb
Show file tree
Hide file tree
Showing 79 changed files with 1,752 additions and 160 deletions.
15 changes: 13 additions & 2 deletions samples/app-sso/csharp/App SSO Sample.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31313.79
# Visual Studio Version 17
VisualStudioVersion = 17.10.35027.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "App SSO Sample", "App SSO Sample\App SSO Sample.csproj", "{AC80CEAA-E474-43CC-AE28-02B96BE44532}"
EndProject
Project("{A9E3F50B-275E-4AF7-ADCE-8BE12D41E305}") = "TeamsApp", "TeamsApp\TeamsApp.ttkproj", "{69E88168-FA38-42BB-BA99-200D2BD3F67C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{67D0E302-B7C0-428B-ACE8-2F07E00FCD58}"
ProjectSection(SolutionItems) = preProject
App SSO Sample.slnLaunch.user = App SSO Sample.slnLaunch.user
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +22,10 @@ Global
{AC80CEAA-E474-43CC-AE28-02B96BE44532}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC80CEAA-E474-43CC-AE28-02B96BE44532}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC80CEAA-E474-43CC-AE28-02B96BE44532}.Release|Any CPU.Build.0 = Release|Any CPU
{69E88168-FA38-42BB-BA99-200D2BD3F67C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69E88168-FA38-42BB-BA99-200D2BD3F67C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69E88168-FA38-42BB-BA99-200D2BD3F67C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69E88168-FA38-42BB-BA99-200D2BD3F67C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
47 changes: 47 additions & 0 deletions samples/app-sso/csharp/App SSO Sample.slnLaunch.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"Name": "Microsoft Teams (browser)",
"Projects": [
{
"Path": "App SSO Sample\\App SSO Sample.csproj",
"Action": "Start",
"DebugTarget": "Start Project"
},
{
"Path": "TeamsApp\\TeamsApp.ttkproj",
"Action": "StartWithoutDebugging",
"DebugTarget": "Microsoft Teams (browser)"
}
]
},
{
"Name": "Microsoft 365 app (browser)",
"Projects": [
{
"Path": "App SSO Sample\\App SSO Sample.csproj",
"Action": "Start",
"DebugTarget": "Start Project"
},
{
"Path": "TeamsApp\\TeamsApp.ttkproj",
"Action": "StartWithoutDebugging",
"DebugTarget": "Microsoft 365 app (browser)"
}
]
},
{
"Name": "Outlook (browser)",
"Projects": [
{
"Path": "App SSO Sample\\App SSO Sample.csproj",
"Action": "Start",
"DebugTarget": "Start Project"
},
{
"Path": "TeamsApp\\TeamsApp.ttkproj",
"Action": "StartWithoutDebugging",
"DebugTarget": "Outlook (browser)"
}
]
}
]
25 changes: 25 additions & 0 deletions samples/app-sso/csharp/App SSO Sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# TeamsFx files
build
appPackage/build
env/.env.*.user
env/.env.local
appsettings.Development.json
.deployment

# User-specific files
*.user

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

# Notification local store
.notification.localstore.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:3978",
"sslPort": 0
}
},
{
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"AuthenticationBot": {
"Start Project": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:3978",
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7130;http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"hotReloadProfile": "aspnetcore"
}
}
}
}
18 changes: 16 additions & 2 deletions samples/app-sso/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Please find below demo manifest which is deployed on Microsoft Azure and you can
- Microsoft Teams is installed and you have an account
- [.NET SDK](https://dotnet.microsoft.com/download) version 6.0
- [dev tunnel](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started?tabs=windows) or [ngrok](https://ngrok.com/) latest version or equivalent tunnelling solution
- [Teams Toolkit for Visual Studio](https://learn.microsoft.com/en-us/microsoftteams/platform/toolkit/toolkit-v4/install-teams-toolkit-vs?pivots=visual-studio-v17-7)

1. A global administrator account for an Office 365 tenant. Testing in a production tenant is not recommended! You can get a free tenant for development use by signing up for the [Office 365 Developer Program](https://developer.microsoft.com/microsoft-365/dev-program) (not a guest account).

Expand All @@ -64,6 +65,19 @@ If you use Ngrok, make sure you've downloaded and installed Ngrok on your local

> NOTE: The free ngrok plan will generate a new URL every time you run it, which requires you to update your Azure AD registration, the Teams app manifest, and the project configuration. A paid account with a permanent ngrok URL is recommended.
## Run the app (Using Teams Toolkit for Visual Studio)

The simplest way to run this sample in Teams is to use Teams Toolkit for Visual Studio.
1. Install Visual Studio 2022 **Version 17.10 Preview 4 or higher** [Visual Studio](https://visualstudio.microsoft.com/downloads/)
1. Install Teams Toolkit for Visual Studio [Teams Toolkit extension](https://learn.microsoft.com/en-us/microsoftteams/platform/toolkit/toolkit-v4/install-teams-toolkit-vs?pivots=visual-studio-v17-7)
1. In the debug dropdown menu of Visual Studio, select Dev Tunnels > Create A Tunnel (set authentication type to Public) or select an existing public dev tunnel.
1. In the debug dropdown menu of Visual Studio, select default startup project > **Microsoft Teams (browser)**
1. In Visual Studio, right-click your **TeamsApp** project and **Select Teams Toolkit > Prepare Teams App Dependencies**
1. Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps.
1. Select **Debug > Start Debugging** or **F5** to run the menu in Visual Studio.
1. In the browser that launches, select the **Add** button to install the app to Teams.
> If you do not have permission to upload custom apps (sideloading), Teams Toolkit will recommend creating and using a Microsoft 365 Developer Program account - a free program to get your own dev environment sandbox that includes Teams.
## Setup

### 1. Setup for Bot SSO
Expand Down Expand Up @@ -186,10 +200,10 @@ Make sure your Application ID Url under Expose and API section is in below forma
### 5. Setup Manifest for Teams

**This step is specific to Teams.**
- **Edit** the `manifest.json` contained in the `AppManifest` folder to replace your Microsoft App Id (that was created when you registered your bot earlier) *everywhere* you see the place holder string `<<YOUR-MICROSOFT-APP-ID>>` (depending on the scenario the Microsoft App Id may occur multiple times in the `manifest.json`)
- **Edit** the `manifest.json` contained in the `appPackage` folder to replace your Microsoft App Id (that was created when you registered your bot earlier) *everywhere* you see the place holder string `<<YOUR-MICROSOFT-APP-ID>>` (depending on the scenario the Microsoft App Id may occur multiple times in the `manifest.json`)
- **Edit** the `manifest.json` for `validDomains` and `<<DOMAIN-NAME>>` with base Url domain. E.g. if you are using ngrok it would be `https://1234.ngrok-free.app` then your domain-name will be `1234.ngrok-free.app` and if you are using dev tunnels then your domain will be like: `12345.devtunnels.ms`.
- **Note:** If you want to test your app across multi hub like: Outlook/Office.com, please update the `manifest.json` in the `app-sso\csharp\App SSO Sample` folder with the required values.
- **Zip** up the contents of the `AppManifest` folder to create a `manifest.zip` or `AppManifest_Hub` folder into a `manifest.zip`.(Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)
- **Zip** up the contents of the `appPackage` folder to create a `manifest.zip` or `AppManifest_Hub` folder into a `manifest.zip`.(Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)
- **Upload** the `manifest.zip` to Teams (In Teams Apps/Manage your apps click "Upload an app". Browse to and Open the .zip file. At the next dialog, click the Add button.)
**Note**: This `manifest.json` specified that the bot will be installed in a "personal" scope only. Please refer to Teams documentation for more details.
Expand Down
9 changes: 9 additions & 0 deletions samples/app-sso/csharp/TeamsApp/TeamsApp.ttkproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.TeamsFx.Sdk">
<PropertyGroup Label="Globals">
<ProjectGuid>69e88168-fa38-42bb-ba99-200d2bd3f67c</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<ProjectCapability Include="ProjectConfigurationsDeclaredDimensions" />
</ItemGroup>
</Project>
123 changes: 123 additions & 0 deletions samples/app-sso/csharp/TeamsApp/aad.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"id": "${{AAD_APP_OBJECT_ID}}",
"appId": "${{AAD_APP_CLIENT_ID}}",
"name": "app-sso-aad",
"accessTokenAcceptedVersion": 2,
"signInAudience": "AzureADMultipleOrgs",
"oauth2AllowIdTokenImplicitFlow": true,
"oauth2AllowImplicitFlow": true,
"optionalClaims": {
"idToken": [],
"accessToken": [
{
"name": "idtyp",
"source": null,
"essential": false,
"additionalProperties": []
}
],
"saml2Token": []
},
"requiredResourceAccess": [
{
"resourceAppId": "Microsoft Graph",
"resourceAccess": [
{
"id": "User.Read",
"type": "Scope"
},
{
"id": "email",
"type": "Scope"
},
{
"id": "offline_access",
"type": "Scope"
},
{
"id": "openid",
"type": "Scope"
},
{
"id": "profile",
"type": "Scope"
}
]
}
],
"oauth2Permissions": [
{
"adminConsentDescription": "Allows Teams to call the app's web APIs as the current user.",
"adminConsentDisplayName": "Teams can access app's web APIs",
"id": "${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}",
"isEnabled": true,
"type": "User",
"userConsentDescription": "Enable Teams to call this app's web APIs with the same rights that you have",
"userConsentDisplayName": "Teams can access app's web APIs and make requests on your behalf",
"value": "access_as_user"
}
],
"preAuthorizedApplications": [
{
"appId": "1fec8e78-bce4-4aaf-ab1b-5451cc387264",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "5e3ce6c0-2b1f-4285-8d4b-75ee78787346",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "d3590ed6-52b3-4102-aeff-aad2292ab01c",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "00000002-0000-0ff1-ce00-000000000000",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "bc59ab01-8403-45c6-8796-ac3ef710b3e3",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "0ec893e0-5785-4de6-99da-4ed124e5296c",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "4765445b-32c6-49b0-83e6-1d93765276ca",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "4345a7b9-9a63-4910-a426-35363201d503",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
}
],
"identifierUris": [
"api://${{BOT_DOMAIN}}/botid-${{AAD_APP_CLIENT_ID}}"
],
"replyUrlsWithType": [
{
"url": "https://${{BOT_DOMAIN}}/Auth/End",
"type": "Spa"
},
{
"url": "https://token.botframework.com/.auth/web/redirect",
"type": "Web"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.12/MicrosoftTeams.schema.json",
"manifestVersion": "1.12",
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
"manifestVersion": "1.16",
"version": "1.0.0",
"id": "<<YOUR-MICROSOFT-APP-ID>>",
"id": "${{TEAMS_APP_ID}}",
"packageName": "com.microsoft.teams.samples.AppSSO",
"developer": {
"name": "Microsoft",
Expand All @@ -11,8 +11,8 @@
"termsOfUseUrl": "https://example.azurewebsites.net/termsofuse"
},
"icons": {
"color": "icon-color.png",
"outline": "icon-outline.png"
"color": "color.png",
"outline": "outline.png"
},
"name": {
"short": "App SSO in csharp",
Expand All @@ -25,7 +25,7 @@
"accentColor": "#FFFFFF",
"composeExtensions": [
{
"botId": "<<YOUR-MICROSOFT-APP-ID>>",
"botId": "${{AAD_APP_CLIENT_ID}}",
"canUpdateConfiguration": true,
"commands": [
{
Expand Down Expand Up @@ -104,14 +104,14 @@
{
"entityId": "auth",
"name": "SSO Tab",
"contentUrl": "https://<<DOMAIN-NAME>>/Home/Index",
"websiteUrl": "https://<<DOMAIN-NAME>>/Index",
"contentUrl": "https://${{BOT_DOMAIN}}/Home/Index",
"websiteUrl": "https://${{BOT_DOMAIN}}/Index",
"scopes": [ "personal" ]
}
],
"bots": [
{
"botId": "<<YOUR-MICROSOFT-APP-ID>>",
"botId": "${{AAD_APP_CLIENT_ID}}",
"scopes": [
"personal"
],
Expand All @@ -120,8 +120,8 @@
}
],
"webApplicationInfo": {
"id": "<<YOUR-MICROSOFT-APP-ID>>",
"resource": "api://<<DOMAIN-NAME>>/botid-<<YOUR-MICROSOFT-APP-ID>>"
"id": "${{AAD_APP_CLIENT_ID}}",
"resource": "api://${{BOT_DOMAIN}}/botid-${{AAD_APP_CLIENT_ID}}"
},

"permissions": [
Expand All @@ -130,7 +130,7 @@
],
"validDomains": [
"*.githubusercontent.com",
"<<DOMAIN-NAME>>",
"${{BOT_DOMAIN}}",
"*.botframework.com"
]
}
Loading

0 comments on commit dbc79cb

Please sign in to comment.