diff --git a/GraphExplorerAppModeService/GraphExplorerAppModeService.csproj b/GraphExplorerAppModeService/GraphExplorerAppModeService.csproj new file mode 100644 index 000000000..522ad66e5 --- /dev/null +++ b/GraphExplorerAppModeService/GraphExplorerAppModeService.csproj @@ -0,0 +1,12 @@ + + + + net5.0 + dotnet-GraphExplorerAppModeService-10DEC1C0-DF4C-4EA8-B0A8-54951DB93792 + Library + + + + + + diff --git a/GraphExplorerAppModeService/Interfaces/IGraphAppAuthProvider.cs b/GraphExplorerAppModeService/Interfaces/IGraphAppAuthProvider.cs new file mode 100644 index 000000000..669e3feeb --- /dev/null +++ b/GraphExplorerAppModeService/Interfaces/IGraphAppAuthProvider.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GraphExplorerAppModeService.Interfaces +{ + interface IGraphAppAuthProvider + { + } +} diff --git a/GraphExplorerAppModeService/Interfaces/IGraphServiceClient.cs b/GraphExplorerAppModeService/Interfaces/IGraphServiceClient.cs new file mode 100644 index 000000000..21d8c5757 --- /dev/null +++ b/GraphExplorerAppModeService/Interfaces/IGraphServiceClient.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GraphExplorerAppModeService.Interfaces +{ + interface IGraphServiceClient + { + } +} diff --git a/GraphExplorerAppModeService/Services/GraphAppAuthProvider.cs b/GraphExplorerAppModeService/Services/GraphAppAuthProvider.cs new file mode 100644 index 000000000..67f55c01a --- /dev/null +++ b/GraphExplorerAppModeService/Services/GraphAppAuthProvider.cs @@ -0,0 +1,19 @@ +using GraphExplorerAppModeService.Interfaces; +using Microsoft.Extensions.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +namespace GraphExplorerAppModeService.Services +{ + public class GraphAppAuthProvider : IGraphAppAuthProvider + { + public GraphAppAuthProvider(IConfiguration configuration) + { + + } + } +} diff --git a/GraphExplorerAppModeService/Services/GraphClientService.cs b/GraphExplorerAppModeService/Services/GraphClientService.cs new file mode 100644 index 000000000..eb90cd15b --- /dev/null +++ b/GraphExplorerAppModeService/Services/GraphClientService.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using GraphExplorerAppModeService.Interfaces; +using Microsoft.Extensions.Configuration; + +namespace GraphExplorerAppModeService.Services +{ + class GraphClientService : IGraphServiceClient + { + public GraphClientService(IConfiguration configuration) + { + + } + } +} diff --git a/GraphWebApi/Controllers/GraphExplorerAppModeController.cs b/GraphWebApi/Controllers/GraphExplorerAppModeController.cs new file mode 100644 index 000000000..e8668b485 --- /dev/null +++ b/GraphWebApi/Controllers/GraphExplorerAppModeController.cs @@ -0,0 +1,61 @@ +using System; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using GraphExplorerAppModeService.Interfaces; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace GraphWebApi.Controllers +{ + [ApiController] + public class GraphExplorerAppModeController : ControllerBase + { + [Route("api/[controller]/{*all}")] + [Route("graphproxy/{*all}")] + [HttpGet] + public async Task GetAsync(string all, [FromHeader] string Authorization) + { + return await ProcessRequestAsync("GET", all, null, Authorization).ConfigureAwait(false); + } + + [Route("api/[controller]/{*all}")] + [Route("graphproxy/{*all}")] + [HttpPost] + public async Task PostAsync(string all, [FromBody] object body, [FromHeader] string Authorization) + { + return await ProcessRequestAsync("POST", all, body, Authorization).ConfigureAwait(false); + } + + [Route("api/[controller]/{*all}")] + [Route("graphproxy/{*all}")] + [HttpDelete] + public async Task DeleteAsync(string all, [FromHeader] string Authorization) + { + return await ProcessRequestAsync("DELETE", all, null, Authorization).ConfigureAwait(false); + } + + [Route("api/[controller]/{*all}")] + [Route("graphproxy/{*all}")] + [HttpPut] + public async Task PutAsync(string all, [FromBody] object body, [FromHeader] string Authorization) + { + return await ProcessRequestAsync("PUT", all, body, Authorization).ConfigureAwait(false); + } + + [Route("api/[controller]/{*all}")] + [Route("graphproxy/{*all}")] + [HttpPatch] + public async Task PatchAsync(string all, [FromBody] object body, [FromHeader] string Authorization) + { + return await ProcessRequestAsync("PATCH", all, body, Authorization).ConfigureAwait(false); + } + + private async Task ProcessRequestAsync(string method, string all, object content, string Authorizaton) + { + + return Ok(); + } + } +} diff --git a/GraphWebApi/GraphWebApi.csproj b/GraphWebApi/GraphWebApi.csproj index 9daa4263b..d2424b25c 100644 --- a/GraphWebApi/GraphWebApi.csproj +++ b/GraphWebApi/GraphWebApi.csproj @@ -61,6 +61,7 @@ + diff --git a/GraphWebApi/Startup.cs b/GraphWebApi/Startup.cs index 0ccb62e18..106cde847 100644 --- a/GraphWebApi/Startup.cs +++ b/GraphWebApi/Startup.cs @@ -27,6 +27,7 @@ using TelemetrySanitizerService; using OpenAPIService.Interfaces; using OpenAPIService; +using System.Threading.Tasks; namespace GraphWebApi { @@ -57,6 +58,16 @@ public void ConfigureServices(IServiceCollection services) ValidAudience = Configuration["AzureAd:Audience"], ValidIssuer = Configuration["AzureAd:Issuer"] }; + // This is to allow local testing using postman + // To be removed when merged into dev + option.Events = new JwtBearerEvents() + { + OnAuthenticationFailed = context => + { + context.NoResult(); + return Task.FromResult(0); + } + }; }); #region AppInsights diff --git a/GraphWebApi/appsettings.json b/GraphWebApi/appsettings.json index b349e66a9..e596398ee 100644 --- a/GraphWebApi/appsettings.json +++ b/GraphWebApi/appsettings.json @@ -3,7 +3,11 @@ "Instance": "https://login.microsoftonline.com/", "TenantId": "ENTER_TENANT_ID", "Audience": "ENTER_APP_ID_URI", - "Issuer": "ENTER_ISSUER_URI" + "Issuer": "ENTER_ISSUER_URI", + "ClientId": "YOUR_APP_ID_HERE", + "ClientSecret": "YOUR_APP_PASSWORD_HERE", + "Scopes": "openid email profile offline_access", + "GraphResourceId": "https://graph.microsoft.com/" }, "Logging": { "LogLevel": { @@ -52,5 +56,8 @@ "SampleQueries": "24", "Permissions": "24", "ChangeLog": "24" + }, + "GEApplicationMode": { + } } \ No newline at end of file diff --git a/MSGraphWebApi.sln b/MSGraphWebApi.sln index 95c992d8c..600414ab3 100644 --- a/MSGraphWebApi.sln +++ b/MSGraphWebApi.sln @@ -43,6 +43,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UtilityService", "UtilitySe EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UtilityService.Test", "UtilityService.Test\UtilityService.Test.csproj", "{0F4A15DC-F4CD-415D-A62D-6B0D95ED25E8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphExplorerAppModeService", "GraphExplorerAppModeService\GraphExplorerAppModeService.csproj", "{AF515BB3-08B5-41A1-80E6-4529670A6B1C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -129,6 +131,10 @@ Global {0F4A15DC-F4CD-415D-A62D-6B0D95ED25E8}.Debug|Any CPU.Build.0 = Debug|Any CPU {0F4A15DC-F4CD-415D-A62D-6B0D95ED25E8}.Release|Any CPU.ActiveCfg = Release|Any CPU {0F4A15DC-F4CD-415D-A62D-6B0D95ED25E8}.Release|Any CPU.Build.0 = Release|Any CPU + {AF515BB3-08B5-41A1-80E6-4529670A6B1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF515BB3-08B5-41A1-80E6-4529670A6B1C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF515BB3-08B5-41A1-80E6-4529670A6B1C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF515BB3-08B5-41A1-80E6-4529670A6B1C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE