Skip to content

Commit afaac68

Browse files
Merge pull request #35 from RockSolidKnowledge/feature/AddDuendeDynamicProvidersSample
Feature/add duende dynamic providers sample
2 parents 7ec7ab6 + 64a72c1 commit afaac68

File tree

94 files changed

+48728
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+48728
-2
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright (c) Duende Software. All rights reserved.
2+
// See LICENSE in the project root for license information.
3+
4+
5+
using Duende.IdentityServer.Models;
6+
using System.Collections.Generic;
7+
using Duende.IdentityServer;
8+
9+
namespace DuendeDynamicProviders
10+
{
11+
public static class Config
12+
{
13+
public static IEnumerable<IdentityResource> GetIdentityResources()
14+
{
15+
return new IdentityResource[]
16+
{
17+
new IdentityResources.OpenId(),
18+
new IdentityResources.Profile(),
19+
};
20+
}
21+
22+
public static IEnumerable<ApiResource> GetApis()
23+
{
24+
return new ApiResource[]
25+
{
26+
new ApiResource("api1", "My API #1")
27+
};
28+
}
29+
30+
public static IEnumerable<ApiScope> GetApiScopes()
31+
{
32+
return new ApiScope[]
33+
{
34+
new ApiScope("scope1"),
35+
new ApiScope("scope2"),
36+
};
37+
}
38+
39+
public static IEnumerable<Client> GetClients()
40+
{
41+
return new[]
42+
{
43+
new Client
44+
{
45+
ClientId = "https://localhost:5002",
46+
ClientName = "client",
47+
ProtocolType = IdentityServerConstants.ProtocolTypes.OpenIdConnect,
48+
AllowedScopes = {"openid", "profile"}
49+
}
50+
};
51+
}
52+
}
53+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<None Remove="idsrv3test.cer" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Duende.IdentityServer" Version="5.2.1" />
13+
<PackageReference Include="Rsk.Saml" Version="4.2.0" />
14+
<PackageReference Include="Rsk.Saml.DuendeIdentityServer" Version="5.1.0" />
15+
16+
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<None Update="testclient.cer">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</None>
23+
<None Update="testclient.pfx">
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</None>
26+
</ItemGroup>
27+
28+
</Project>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) Duende Software. All rights reserved.
2+
// See LICENSE in the project root for license information.
3+
4+
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.Extensions.Hosting;
7+
using Serilog;
8+
using Serilog.Events;
9+
using Serilog.Sinks.SystemConsole.Themes;
10+
using System;
11+
12+
namespace DuendeDynamicProviders
13+
{
14+
public class Program
15+
{
16+
public static int Main(string[] args)
17+
{
18+
Log.Logger = new LoggerConfiguration()
19+
.MinimumLevel.Debug()
20+
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
21+
.MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Information)
22+
.MinimumLevel.Override("System", LogEventLevel.Warning)
23+
.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
24+
.Enrich.FromLogContext()
25+
// uncomment to write to Azure diagnostics stream
26+
//.WriteTo.File(
27+
// @"D:\home\LogFiles\Application\identityserver.txt",
28+
// fileSizeLimitBytes: 1_000_000,
29+
// rollOnFileSizeLimit: true,
30+
// shared: true,
31+
// flushToDiskInterval: TimeSpan.FromSeconds(1))
32+
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code)
33+
.CreateLogger();
34+
35+
try
36+
{
37+
Log.Information("Starting host...");
38+
CreateHostBuilder(args).Build().Run();
39+
return 0;
40+
}
41+
catch (Exception ex)
42+
{
43+
Log.Fatal(ex, "Host terminated unexpectedly.");
44+
return 1;
45+
}
46+
finally
47+
{
48+
Log.CloseAndFlush();
49+
}
50+
}
51+
52+
public static IHostBuilder CreateHostBuilder(string[] args) =>
53+
Host.CreateDefaultBuilder(args)
54+
.UseSerilog()
55+
.ConfigureWebHostDefaults(webBuilder =>
56+
{
57+
webBuilder.UseStartup<Startup>();
58+
});
59+
}
60+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"profiles": {
3+
"idp": {
4+
"commandName": "Project",
5+
"launchBrowser": true,
6+
"environmentVariables": {
7+
"ASPNETCORE_ENVIRONMENT": "Development"
8+
},
9+
"applicationUrl": "https://localhost:5004"
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)