Skip to content

Commit 145339d

Browse files
authored
Merge pull request #4 from AzureAD/webhost
Moved webhost outside the main library
2 parents 95c923b + c9009ab commit 145339d

18 files changed

+154
-274
lines changed

Microsoft.SCIM.Sample/App.config

-74
This file was deleted.

Microsoft.SCIM.Sample/Startup.cs

-37
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-ef": {
6+
"version": "3.1.2",
7+
"commands": [
8+
"dotnet-ef"
9+
]
10+
}
11+
}
12+
}

Microsoft.SCIM.Sample/Microsoft.SCIM.Sample.csproj Microsoft.SCIM.WebHostSample/Microsoft.SCIM.WebHostSample.csproj

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
54
<TargetFramework>netcoreapp3.1</TargetFramework>
65
</PropertyGroup>
76

8-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
9-
<DefineConstants>DEBUG</DefineConstants>
10-
</PropertyGroup>
11-
127
<ItemGroup>
138
<ProjectReference Include="..\Microsoft.SystemForCrossDomainIdentityManagement\Microsoft.SCIM.csproj" />
149
</ItemGroup>
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Hosting;
8+
using Microsoft.Extensions.Logging;
9+
10+
namespace Microsoft.SCIM.WebHostSample
11+
{
12+
public class Program
13+
{
14+
public static void Main(string[] args)
15+
{
16+
CreateHostBuilder(args).Build().Run();
17+
}
18+
19+
public static IHostBuilder CreateHostBuilder(string[] args) =>
20+
Host.CreateDefaultBuilder(args)
21+
.ConfigureWebHostDefaults(webBuilder =>
22+
{
23+
webBuilder.UseStartup<Startup>();
24+
});
25+
}
26+
}

Microsoft.SCIM.Sample/InMemoryGroupProvider.cs Microsoft.SCIM.WebHostSample/Provider/InMemoryGroupProvider.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Copyright (c) Microsoft Corporation. All rights reserved.
33
//------------------------------------------------------------
44

5-
namespace Microsoft.SCIM.Sample
5+
namespace Microsoft.SCIM.WebHostSample.Provider
66
{
77
using System;
88
using System.Collections.Generic;
@@ -11,7 +11,7 @@ namespace Microsoft.SCIM.Sample
1111
using System.Threading.Tasks;
1212
using System.Web.Http;
1313
using Microsoft.SCIM;
14-
using Microsoft.SCIM.Sample.Properties;
14+
using Microsoft.SCIM.WebHostSample.Resources;
1515

1616
public class InMemoryGroupProvider : ProviderBase
1717
{

Microsoft.SCIM.Sample/InMemoryProvider.cs Microsoft.SCIM.WebHostSample/Provider/InMemoryProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Copyright (c) Microsoft Corporation. All rights reserved.
33
//------------------------------------------------------------
44

5-
namespace Microsoft.SCIM.Sample
5+
namespace Microsoft.SCIM.WebHostSample.Provider
66
{
77
using System;
88
using System.Threading.Tasks;

Microsoft.SCIM.Sample/InMemoryStorage.cs Microsoft.SCIM.WebHostSample/Provider/InMemoryStorage.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Copyright (c) Microsoft Corporation. All rights reserved.
33
//------------------------------------------------------------
44

5-
namespace Microsoft.SCIM.Sample
5+
namespace Microsoft.SCIM.WebHostSample.Provider
66
{
77
using System;
88
using System.Collections.Generic;

Microsoft.SCIM.Sample/InMemoryUserProvider.cs Microsoft.SCIM.WebHostSample/Provider/InMemoryUserProvider.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Copyright (c) Microsoft Corporation. All rights reserved.
33
//------------------------------------------------------------
44

5-
namespace Microsoft.SCIM.Sample
5+
namespace Microsoft.SCIM.WebHostSample.Provider
66
{
77
using System;
88
using System.Collections.Generic;
@@ -11,7 +11,7 @@ namespace Microsoft.SCIM.Sample
1111
using System.Threading.Tasks;
1212
using System.Web.Http;
1313
using Microsoft.SCIM;
14-
using Microsoft.SCIM.Sample.Properties;
14+
using Microsoft.SCIM.WebHostSample.Resources;
1515

1616
public class InMemoryUserProvider : ProviderBase
1717
{

Microsoft.SCIM.Sample/Properties/SampleServiceResources.Designer.cs Microsoft.SCIM.WebHostSample/Resources/SampleServiceResources.Designer.cs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Authentication.JwtBearer;
7+
using Microsoft.AspNetCore.Builder;
8+
using Microsoft.AspNetCore.Hosting;
9+
using Microsoft.AspNetCore.Http;
10+
using Microsoft.AspNetCore.Routing;
11+
using Microsoft.Extensions.DependencyInjection;
12+
using Microsoft.Extensions.Hosting;
13+
using Microsoft.IdentityModel.Tokens;
14+
using Microsoft.SCIM.WebHostSample.Provider;
15+
16+
namespace Microsoft.SCIM.WebHostSample
17+
{
18+
public class Startup
19+
{
20+
public IMonitor MonitoringBehavior { get; set; }
21+
public IProvider ProviderBehavior { get; set; }
22+
23+
public Startup()
24+
{
25+
this.MonitoringBehavior = new ConsoleMonitor();
26+
this.ProviderBehavior = new InMemoryProvider();
27+
}
28+
29+
// This method gets called by the runtime. Use this method to add services to the container.
30+
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
31+
public void ConfigureServices(IServiceCollection services)
32+
{
33+
services.AddAuthentication(options =>
34+
{
35+
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
36+
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
37+
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
38+
})
39+
.AddJwtBearer(options =>
40+
{
41+
options.TokenValidationParameters =
42+
new TokenValidationParameters
43+
{
44+
ValidateIssuer = false,
45+
ValidateAudience = false,
46+
ValidateLifetime = false,
47+
ValidateIssuerSigningKey = false,
48+
ValidIssuer = ServiceConstants.TokenIssuer,
49+
ValidAudience = ServiceConstants.TokenAudience,
50+
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(ServiceConstants.TokenIssuer))
51+
};
52+
});
53+
54+
services.AddControllers().AddNewtonsoftJson();
55+
56+
services.AddSingleton(typeof(IProvider), this.ProviderBehavior);
57+
services.AddSingleton(typeof(IMonitor), this.MonitoringBehavior);
58+
}
59+
60+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
61+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
62+
{
63+
if (env.IsDevelopment())
64+
{
65+
app.UseDeveloperExceptionPage();
66+
}
67+
68+
app.UseHsts();
69+
70+
app.UseRouting();
71+
app.UseHttpsRedirection();
72+
app.UseAuthentication();
73+
app.UseAuthorization();
74+
75+
app.UseEndpoints(
76+
(IEndpointRouteBuilder endpoints) =>
77+
{
78+
endpoints.MapDefaultControllerRoute();
79+
});
80+
}
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
},
9+
"AllowedHosts": "*"
10+
}

Microsoft.SCIM.sln

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.29709.97
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SCIM", "Microsoft.SystemForCrossDomainIdentityManagement\Microsoft.SCIM.csproj", "{C9ED6410-1995-4B98-AD57-C02D5F16631C}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SCIM.Sample", "Microsoft.SCIM.Sample\Microsoft.SCIM.Sample.csproj", "{06220587-471C-4AB0-BBB6-F1D9E35DBDDF}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SCIM.WebHostSample", "Microsoft.SCIM.WebHostSample\Microsoft.SCIM.WebHostSample.csproj", "{238F1B05-D3EE-4AB4-871E-ADEA0A1665CF}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -17,10 +17,10 @@ Global
1717
{C9ED6410-1995-4B98-AD57-C02D5F16631C}.Debug|Any CPU.Build.0 = Debug|Any CPU
1818
{C9ED6410-1995-4B98-AD57-C02D5F16631C}.Release|Any CPU.ActiveCfg = Release|Any CPU
1919
{C9ED6410-1995-4B98-AD57-C02D5F16631C}.Release|Any CPU.Build.0 = Release|Any CPU
20-
{06220587-471C-4AB0-BBB6-F1D9E35DBDDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21-
{06220587-471C-4AB0-BBB6-F1D9E35DBDDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
22-
{06220587-471C-4AB0-BBB6-F1D9E35DBDDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{06220587-471C-4AB0-BBB6-F1D9E35DBDDF}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{238F1B05-D3EE-4AB4-871E-ADEA0A1665CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{238F1B05-D3EE-4AB4-871E-ADEA0A1665CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{238F1B05-D3EE-4AB4-871E-ADEA0A1665CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{238F1B05-D3EE-4AB4-871E-ADEA0A1665CF}.Release|Any CPU.Build.0 = Release|Any CPU
2424
EndGlobalSection
2525
GlobalSection(SolutionProperties) = preSolution
2626
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)