Skip to content

Commit

Permalink
Merge pull request #4 from AzureAD/webhost
Browse files Browse the repository at this point in the history
Moved webhost outside the main library
  • Loading branch information
marcusca10 authored Feb 23, 2020
2 parents 95c923b + c9009ab commit 145339d
Show file tree
Hide file tree
Showing 18 changed files with 154 additions and 274 deletions.
74 changes: 0 additions & 74 deletions Microsoft.SCIM.Sample/App.config

This file was deleted.

37 changes: 0 additions & 37 deletions Microsoft.SCIM.Sample/Startup.cs

This file was deleted.

12 changes: 12 additions & 0 deletions Microsoft.SCIM.WebHostSample/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "3.1.2",
"commands": [
"dotnet-ef"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>DEBUG</DefineConstants>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.SystemForCrossDomainIdentityManagement\Microsoft.SCIM.csproj" />
</ItemGroup>
Expand Down
26 changes: 26 additions & 0 deletions Microsoft.SCIM.WebHostSample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace Microsoft.SCIM.WebHostSample
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------

namespace Microsoft.SCIM.Sample
namespace Microsoft.SCIM.WebHostSample.Provider
{
using System;
using System.Collections.Generic;
Expand All @@ -11,7 +11,7 @@ namespace Microsoft.SCIM.Sample
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.SCIM;
using Microsoft.SCIM.Sample.Properties;
using Microsoft.SCIM.WebHostSample.Resources;

public class InMemoryGroupProvider : ProviderBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------

namespace Microsoft.SCIM.Sample
namespace Microsoft.SCIM.WebHostSample.Provider
{
using System;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------

namespace Microsoft.SCIM.Sample
namespace Microsoft.SCIM.WebHostSample.Provider
{
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------

namespace Microsoft.SCIM.Sample
namespace Microsoft.SCIM.WebHostSample.Provider
{
using System;
using System.Collections.Generic;
Expand All @@ -11,7 +11,7 @@ namespace Microsoft.SCIM.Sample
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.SCIM;
using Microsoft.SCIM.Sample.Properties;
using Microsoft.SCIM.WebHostSample.Resources;

public class InMemoryUserProvider : ProviderBase
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions Microsoft.SCIM.WebHostSample/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using Microsoft.SCIM.WebHostSample.Provider;

namespace Microsoft.SCIM.WebHostSample
{
public class Startup
{
public IMonitor MonitoringBehavior { get; set; }
public IProvider ProviderBehavior { get; set; }

public Startup()
{
this.MonitoringBehavior = new ConsoleMonitor();
this.ProviderBehavior = new InMemoryProvider();
}

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.TokenValidationParameters =
new TokenValidationParameters
{
ValidateIssuer = false,
ValidateAudience = false,
ValidateLifetime = false,
ValidateIssuerSigningKey = false,
ValidIssuer = ServiceConstants.TokenIssuer,
ValidAudience = ServiceConstants.TokenAudience,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(ServiceConstants.TokenIssuer))
};
});

services.AddControllers().AddNewtonsoftJson();

services.AddSingleton(typeof(IProvider), this.ProviderBehavior);
services.AddSingleton(typeof(IMonitor), this.MonitoringBehavior);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseHsts();

app.UseRouting();
app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();

app.UseEndpoints(
(IEndpointRouteBuilder endpoints) =>
{
endpoints.MapDefaultControllerRoute();
});
}
}
}
9 changes: 9 additions & 0 deletions Microsoft.SCIM.WebHostSample/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
10 changes: 10 additions & 0 deletions Microsoft.SCIM.WebHostSample/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
10 changes: 5 additions & 5 deletions Microsoft.SCIM.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SCIM", "Microsoft.SystemForCrossDomainIdentityManagement\Microsoft.SCIM.csproj", "{C9ED6410-1995-4B98-AD57-C02D5F16631C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SCIM.Sample", "Microsoft.SCIM.Sample\Microsoft.SCIM.Sample.csproj", "{06220587-471C-4AB0-BBB6-F1D9E35DBDDF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SCIM.WebHostSample", "Microsoft.SCIM.WebHostSample\Microsoft.SCIM.WebHostSample.csproj", "{238F1B05-D3EE-4AB4-871E-ADEA0A1665CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -17,10 +17,10 @@ Global
{C9ED6410-1995-4B98-AD57-C02D5F16631C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9ED6410-1995-4B98-AD57-C02D5F16631C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9ED6410-1995-4B98-AD57-C02D5F16631C}.Release|Any CPU.Build.0 = Release|Any CPU
{06220587-471C-4AB0-BBB6-F1D9E35DBDDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06220587-471C-4AB0-BBB6-F1D9E35DBDDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06220587-471C-4AB0-BBB6-F1D9E35DBDDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06220587-471C-4AB0-BBB6-F1D9E35DBDDF}.Release|Any CPU.Build.0 = Release|Any CPU
{238F1B05-D3EE-4AB4-871E-ADEA0A1665CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{238F1B05-D3EE-4AB4-871E-ADEA0A1665CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{238F1B05-D3EE-4AB4-871E-ADEA0A1665CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{238F1B05-D3EE-4AB4-871E-ADEA0A1665CF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading

0 comments on commit 145339d

Please sign in to comment.