From a689e77cb7505955d31cf953b927fe818d3897c5 Mon Sep 17 00:00:00 2001 From: PramodKumarHK89 Date: Tue, 26 Jul 2022 11:37:27 +0530 Subject: [PATCH] Few more samples --- IdAceCodeEditor/Config/appsettings.json | 472 ++++++++++++++++++ IdAceCodeEditor/Models/PortalSetting.cs | 1 + .../Services/ConfigureAzureAdApp.cs | 13 +- 3 files changed, 484 insertions(+), 2 deletions(-) diff --git a/IdAceCodeEditor/Config/appsettings.json b/IdAceCodeEditor/Config/appsettings.json index 1287ce8..d5d202b 100644 --- a/IdAceCodeEditor/Config/appsettings.json +++ b/IdAceCodeEditor/Config/appsettings.json @@ -2066,6 +2066,478 @@ //} ] }, + { + "Name": "Node", + "DisplayName": "Node.js", + "Samples": [ + { + "Name": "Sign In Users", + "Type": "JS", + "DisplayName": "A Node.js & Express web app authenticating users against Azure AD with MSAL Nod", + "WorkingFolder": "1-Authentication\\1-sign-in", + "Tags": [ + { "Name": "Node" }, + { "Name": "MSAL JS" }, + { "Name": "Auth Code Flow" } + ], + "GitHubRepoSettings": { + "ReadMeLink": "https://github.com/Azure-Samples/ms-identity-javascript-nodejs-tutorial/blob/main/1-Authentication/1-sign-in/README.md", + "TutorialLink": "https://docs.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-nodejs-webapp-msal", + "ClonePath": "https://github.com/Azure-Samples/ms-identity-javascript-nodejs-tutorial.git", + "LocalPath": "NodeJS\\SignIn" + }, + "Projects": [ + { + "Name": "Client Project", + "ProjectPath": "1-Authentication\\1-sign-in", + "Order": "0", + "PortalSettings": { + "DisplayName": "msal-node-webapp", + "SignInAudience": "AzureADMyOrg", + "AppType": "Web", + "RedirectUri": "http://localhost:4000/redirect", + "IsHybridFlow": "True", + "IsDeviceCodeFlow": "", + "SecretName": "appsecret", + "Certificate": "", + "RequiredResourceAccesss": [ + { + "ResourceAppId": "00000003-0000-0000-c000-000000000000", + "ResourceAccesss": [ + { + "Id": "e1fe6dd8-ba31-4d61-89e7-88639da4683d", + "Type": "Scope" + } + ] + } + ] + }, + "ReplacementFields": [ + { + "Name": "ClientId", + "ReplacementType": "TXT", + "Format": "", + "Source": "persistdata:Projects[0].App.AppId", + "Destination": "Enter_the_Application_Id_Here", + "FileName": "App\\appSettings.js" + }, + { + "Name": "TenantId", + "ReplacementType": "TXT", + "Format": "", + "Source": "persistdata:Projects[0].TenantId", + "Destination": "Enter_the_Tenant_Info_Here", + "FileName": "App\\appSettings.js" + }, + { + "Name": "ClientSecret", + "ReplacementType": "TXT", + "Format": "", + "Source": "persistdata:Projects[0].SecretText", + "Destination": "Enter_the_Client_Secret_Here", + "FileName": "App\\appSettings.js" + } + ] + } + ], + "Prerequisites": [ + { + "Name": "VSCode", + "DownloadLink": "https://code.visualstudio.com/download" + }, + { + "Name": "NPM", + "DownloadLink": "https://docs.npmjs.com/downloading-and-installing-node-js-and-npm" + } + ] + } + //{ + // "Name": "SPA calling Graph API", + // "Type": "React", + // "DisplayName": "React single-page application using MSAL React to sign-in users and call Graph API against Azure Active Directory", + // "WorkingFolder": "2-Authorization-I\\1-call-graph\\SPA", + // "Tags": [ + // { "Name": "Spa" }, + // { "Name": "MSAL React" }, + // { "Name": "PKCE" } + // ], + // "GitHubRepoSettings": { + // "ReadMeLink": "https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/blob/main/2-Authorization-I/1-call-graph/README.md", + // "TutorialLink": "https://docs.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-react", + // "ClonePath": "https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial.git", + // "LocalPath": "React\\SpaCallingGraph" + // }, + // "Projects": [ + // { + // "Name": "Client Project", + // "ProjectPath": "2-Authorization-I\\1-call-graph", + // "Order": "0", + // "PortalSettings": { + // "DisplayName": "msal-react-spa", + // "SignInAudience": "AzureADMyOrg", + // "AppType": "Spa", + // "RedirectUri": "http://localhost:3000/", + // "IsHybridFlow": "", + // "IsDeviceCodeFlow": "", + // "SecretName": "", + // "Certificate": "", + // "RequiredResourceAccesss": [ + // { + // "ResourceAppId": "00000003-0000-0000-c000-000000000000", + // "ResourceAccesss": [ + // { + // "Id": "e1fe6dd8-ba31-4d61-89e7-88639da4683d", + // "Type": "Scope" + // }, + // { + // "Id": "570282fd-fa5c-430d-a7fd-fc8dc98a9dca", //Mail.Read + // "Type": "Scope" + // } + // ] + // }, + // { + // "ResourceAppId": "797f4846-ba00-4fd7-ba43-dac1f8f63013", + // "ResourceAccesss": [ + // { + // "Id": "41094075-9dad-400e-a0bd-54e686782033", // Azure Service management User_impersonation + // "Type": "Scope" + // } + // ] + // } + // ] + // }, + // "ReplacementFields": [ + // { + // "Name": "ClientId", + // "ReplacementType": "TXT", + // "Format": "", + // "Source": "persistdata:Projects[0].App.AppId", + // "Destination": "Enter_the_Application_Id_Here", + // "FileName": "SPA\\src\\authConfig.js" + // }, + // { + // "Name": "TenantId", + // "ReplacementType": "TXT", + // "Format": "", + // "Source": "persistdata:Projects[0].TenantId", + // "Destination": "Enter_the_Tenant_Info_Here", + // "FileName": "SPA\\src\\authConfig.js" + // }, + // { + // "Name": "redirectURi", + // "ReplacementType": "TXT", + // "Format": "", + // "Source": "\"https://localhost:3000/\"", + // "Destination": "\"/\"", + // "FileName": "SPA\\src\\authConfig.js" + // } + // ] + // } + // ], + // "Prerequisites": [ + // { + // "Name": "VSCode", + // "DownloadLink": "https://code.visualstudio.com/download" + // }, + // { + // "Name": "NPM", + // "DownloadLink": "https://docs.npmjs.com/downloading-and-installing-node-js-and-npm" + // } + // ] + //}, + //{ + // "Name": "SPA calling NodeJS API", + // "Type": "React", + // "DisplayName": "A React single-page application using MSAL React to authorize users for calling a protected web API on Azure Active Directory", + // "WorkingFolder": "3-Authorization-II\\1-call-api", + // "Tags": [ + // { "Name": "Spa" }, + // { "Name": "MSAL React" }, + // { "Name": "PKCE" } + // ], + // "GitHubRepoSettings": { + // "ReadMeLink": "https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/3-Authorization-II/1-call-api", + // "TutorialLink": "https://docs.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-react", + // "ClonePath": "https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial.git", + // "LocalPath": "React\\SpaCallinApi" + // }, + // "Projects": [ + // { + // "Name": "API Project", + // "ProjectPath": "3-Authorization-II\\1-call-api\\API", + // "Order": "0", + // "PortalSettings": { + // "DisplayName": "msal-react-api", + // "SignInAudience": "AzureADMyOrg", + // "AppType": "Api", + // "RedirectUri": "", + // "IsHybridFlow": "", + // "IsDeviceCodeFlow": "", + // "SecretName": "", + // "Certificate": "", + // "RequiredResourceAccesss": [ + // { + // "ResourceAppId": "00000003-0000-0000-c000-000000000000", + // "ResourceAccesss": [ + // { + // "Id": "e1fe6dd8-ba31-4d61-89e7-88639da4683d", + // "Type": "Scope" + // } + // ] + // } + // ], + // "PermissionScopes": [ + // { + // "Value": "access_as_user", + // "Type": "User", + // "AdminConsentDisplayName": "Access msal-react-api", + // "UserConsentDisplayName": "Access msal-react-api", + // "AdminConsentDescription": "Allows the app to access msal-react-api as the signed-in user", + // "UserConsentDescription": "Allow the application to access msal-react-api on your behalf." + // } + // ] + // }, + // "ReplacementFields": [ + // { + // "Name": "ClientId", + // "ReplacementType": "JSON", + // "Section": "credentials", + // "Format": "", + // "Source": "persistdata:Projects[0].App.AppId", + // "Destination": "clientID", + // "FileName": "config.json" + // }, + // { + // "Name": "TenantId", + // "ReplacementType": "JSON", + // "Section": "credentials", + // "Format": "", + // "Source": "persistdata:Projects[0].TenantId", + // "Destination": "tenantID", + // "FileName": "config.json" + // } + // ] + // }, + // { + // "Name": "Client Project", + // "ProjectPath": "3-Authorization-II\\1-call-api\\SPA", + // "Order": "1", + // "PortalSettings": { + // "DisplayName": "msal-react-spa", + // "SignInAudience": "AzureADMyOrg", + // "AppType": "Spa", + // "RedirectUri": "http://localhost:3000/", + // "IsHybridFlow": "", + // "IsDeviceCodeFlow": "", + // "SecretName": "", + // "Certificate": "", + // "RequiredResourceAccesss": [ + // { + // "ResourceAppId": "00000003-0000-0000-c000-000000000000", + // "ResourceAccesss": [ + // { + // "Id": "e1fe6dd8-ba31-4d61-89e7-88639da4683d", + // "Type": "Scope" + // } + // ] + // }, + // { + // "ResourceAppId": "persistdata:Projects[0].App.AppId", + // "ResourceAccesss": [ + // { + // "Id": "persistdata:Projects[0].PermissionScopes[0].Id", + // "Type": "Scope" + // } + // ] + + // } + // ] + // }, + // "ReplacementFields": [ + // { + // "Name": "ClientId", + // "ReplacementType": "TXT", + // "Format": "", + // "Source": "persistdata:Projects[1].App.AppId", + // "Destination": "Enter_the_Application_Id_Here", + // "FileName": "src\\authConfig.js" + // }, + // { + // "Name": "TenantId", + // "ReplacementType": "TXT", + // "Format": "", + // "Source": "persistdata:Projects[1].TenantId", + // "Destination": "Enter_the_Tenant_Info_Here", + // "FileName": "src\\authConfig.js" + // }, + // { + // "Name": "ApiScope", + // "ReplacementType": "TXT", + // "Format": "api://{0}/access_as_user", + // "Source": "persistdata:Projects[0].App.AppId", + // "Destination": "Enter_the_Web_Api_Scope_Here", + // "FileName": "src\\authConfig.js" + // } + // ] + // } + // ], + // "Prerequisites": [ + // { + // "Name": "VSCode", + // "DownloadLink": "https://code.visualstudio.com/download" + // }, + // { + // "Name": "NPM", + // "DownloadLink": "https://docs.npmjs.com/downloading-and-installing-node-js-and-npm" + // } + // ] + //} + ] + }, + { + "Name": "WPF", + "DisplayName": "WPF", + "Samples": [ + { + "Name": "WPF app calling Graph", + "Type": "WPFMSAL", + "DisplayName": "WPF application signing in users with Microsoft and calling the Microsoft Graph", + "WorkingFolder": "", + "Tags": [ + { "Name": "Desktop" }, + { "Name": "WPF" }, + { "Name": "MSAL.NET" }, + { "Name": "WAM" }, + { "Name": "System browser" }, + { "Name": "PKCE Flow" } + ], + "GitHubRepoSettings": { + "ReadMeLink": "https://github.com/Azure-Samples/active-directory-dotnet-desktop-msgraph-v2/blob/master/README.md", + "TutorialLink": "https://docs.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-windows-desktop", + "ClonePath": "https://github.com/Azure-Samples/active-directory-dotnet-desktop-msgraph-v2.git", + "LocalPath": "WPF\\CallGraphAPI" + }, + "Projects": [ + { + "Name": "Client Project", + "ProjectPath": "", + "Order": "0", + "PortalSettings": { + "DisplayName": "WpfApp", + "SignInAudience": "AzureADandPersonalMicrosoftAccount", + "AppType": "Desktop", + "RedirectUri": "https://login.microsoftonline.com/common/oauth2/nativeclient", + "BrokeredUri": "ms-appx-web://microsoft.aad.brokerplugin/{0}", + "IsHybridFlow": "", + "IsDeviceCodeFlow": "", + "SecretName": "", + "Certificate": "", + "RequiredResourceAccesss": [ + { + "ResourceAppId": "00000003-0000-0000-c000-000000000000", + "ResourceAccesss": [ + { + "id": "b340eb25-3456-403f-be2f-af7a0d370277", + "Type": "Scope" + } + ] + } + ] + }, + "ReplacementFields": [ + { + "Name": "ClientId", + "ReplacementType": "TXT", + "Section": "client", + "Source": "persistdata:Projects[0].App.AppId", + "Destination": "4a1aa1d5-c567-49d0-ad0b-cd957a47f842", + "FileName": "active-directory-wpf-msgraph-v2\\App.xaml.cs" + } + ] + } + ], + "Prerequisites": [ + { + "Name": "VSCode", + "DownloadLink": "https://code.visualstudio.com/download" + }, + { + "Name": "VisualStudio", + "DownloadLink": "https://visualstudio.microsoft.com/downloads/" + } + ] + } + //{ + // "Name": "WPF app calling ASP.NET core", + // "Type": "WPFMSAL", + // "DisplayName": "Sign-in a user with the Microsoft Identity Platform in a WPF Desktop application and call an ASP.NET Core Web API", + // "WorkingFolder": "1. Desktop app calls Web API", + // "Tags": [ + // { "Name": "Desktop" }, + // { "Name": "WPF" }, + // { "Name": "MSAL.NET" }, + // { "Name": "WAM" }, + // { "Name": "System browser" }, + // { "Name": "PKCE Flow" } + // ], + // "GitHubRepoSettings": { + // "ReadMeLink": "https://github.com/Azure-Samples/active-directory-dotnet-native-aspnetcore-v2/blob/master/1.%20Desktop%20app%20calls%20Web%20API/README.md", + // "TutorialLink": "https://docs.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-windows-desktop", + // "ClonePath": "https://github.com/Azure-Samples/active-directory-dotnet-native-aspnetcore-v2.git", + // "LocalPath": "WPF\\CallCustomAPI" + // }, + // "Projects": [ + // { + // "Name": "Client Project", + // "ProjectPath": "", + // "Order": "0", + // "PortalSettings": { + // "DisplayName": "WpfApp", + // "SignInAudience": "AzureADandPersonalMicrosoftAccount", + // "AppType": "Desktop", + // "RedirectUri": "https://login.microsoftonline.com/common/oauth2/nativeclient", + // "BrokeredUri": "ms-appx-web://microsoft.aad.brokerplugin/{0}", + // "IsHybridFlow": "", + // "IsDeviceCodeFlow": "", + // "SecretName": "", + // "Certificate": "", + // "RequiredResourceAccesss": [ + // { + // "ResourceAppId": "00000003-0000-0000-c000-000000000000", + // "ResourceAccesss": [ + // { + // "id": "b340eb25-3456-403f-be2f-af7a0d370277", + // "Type": "Scope" + // } + // ] + // } + // ] + // }, + // "ReplacementFields": [ + // { + // "Name": "ClientId", + // "ReplacementType": "TXT", + // "Section": "client", + // "Source": "persistdata:Projects[0].App.AppId", + // "Destination": "4a1aa1d5-c567-49d0-ad0b-cd957a47f842", + // "FileName": "active-directory-wpf-msgraph-v2\\App.xaml.cs" + // } + // ] + // } + // ], + // "Prerequisites": [ + // { + // "Name": "VSCode", + // "DownloadLink": "https://code.visualstudio.com/download" + // }, + // { + // "Name": "VisualStudio", + // "DownloadLink": "https://visualstudio.microsoft.com/downloads/" + // } + // ] + //} + ] + }, { "Name": "Python", "DisplayName": "Python", diff --git a/IdAceCodeEditor/Models/PortalSetting.cs b/IdAceCodeEditor/Models/PortalSetting.cs index 0945cba..089dea5 100644 --- a/IdAceCodeEditor/Models/PortalSetting.cs +++ b/IdAceCodeEditor/Models/PortalSetting.cs @@ -10,6 +10,7 @@ public class PortalSetting public string SignInAudience { get; set; } public string AppType { get; set; } public string RedirectUri { get; set; } + public string BrokeredUri { get; set; } public string IsHybridFlow { get; set; } public string IsDeviceCodeFlow { get; set; } public string SecretName{ get; set; } diff --git a/IdAceCodeEditor/Services/ConfigureAzureAdApp.cs b/IdAceCodeEditor/Services/ConfigureAzureAdApp.cs index 57c89e8..0c69d9b 100644 --- a/IdAceCodeEditor/Services/ConfigureAzureAdApp.cs +++ b/IdAceCodeEditor/Services/ConfigureAzureAdApp.cs @@ -157,9 +157,9 @@ public async Task CreateAppRegistration() break; case "Desktop": application.PublicClient = new Microsoft.Graph.PublicClientApplication - { - + { RedirectUris = _project.PortalSettings.RedirectUri.Split(" ") + }; break; default: @@ -171,6 +171,15 @@ public async Task CreateAppRegistration() .Request() .AddAsync(application); + if(!string.IsNullOrEmpty(_project.PortalSettings.BrokeredUri)) + { + _project.PortalSettings.BrokeredUri = String.Format(_project.PortalSettings.BrokeredUri, content.AppId); + content.PublicClient.RedirectUris = content.PublicClient.RedirectUris.Concat(_project.PortalSettings.BrokeredUri.Split(" ")); + + await graphClient.Applications[content.Id] + .Request() + .UpdateAsync(content); + } string key = string.Format("persistdata:Projects[{0}]", _project.Order); _persistData.Add(key + ".App.AppId", content.AppId);