Skip to content

Commit faf4ed8

Browse files
committed
Added Azure Key Vault sample code
1 parent 2404db2 commit faf4ed8

Some content is hidden

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

63 files changed

+21311
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29709.97
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer", "IdentityServer\IdentityServer.csproj", "{81312131-6AB5-42ED-A4E5-2FE39A0A3C66}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{81312131-6AB5-42ED-A4E5-2FE39A0A3C66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{81312131-6AB5-42ED-A4E5-2FE39A0A3C66}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{81312131-6AB5-42ED-A4E5-2FE39A0A3C66}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{81312131-6AB5-42ED-A4E5-2FE39A0A3C66}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {6F4248FD-FD84-4AB1-B74D-29659E6C974C}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
4+
5+
using IdentityServer4.Models;
6+
using System.Collections.Generic;
7+
8+
namespace IdentityServer
9+
{
10+
public static class Config
11+
{
12+
public static IEnumerable<IdentityResource> Ids =>
13+
new IdentityResource[]
14+
{
15+
new IdentityResources.OpenId(),
16+
new IdentityResources.Profile(),
17+
};
18+
19+
20+
public static IEnumerable<ApiResource> Apis =>
21+
new ApiResource[]
22+
{
23+
new ApiResource("api1", "My API #1")
24+
};
25+
26+
27+
public static IEnumerable<Client> Clients =>
28+
new Client[]
29+
{
30+
// client credentials flow client
31+
new Client
32+
{
33+
ClientId = "client",
34+
ClientName = "Client Credentials Client",
35+
36+
AllowedGrantTypes = GrantTypes.ClientCredentials,
37+
ClientSecrets = { new Secret("511536EF-F270-4058-80CA-1C89C192F69A".Sha256()) },
38+
39+
AllowedScopes = { "api1" }
40+
},
41+
42+
// MVC client using code flow + pkce
43+
new Client
44+
{
45+
ClientId = "mvc",
46+
ClientName = "MVC Client",
47+
48+
AllowedGrantTypes = GrantTypes.CodeAndClientCredentials,
49+
RequirePkce = true,
50+
ClientSecrets = { new Secret("49C1A7E1-0C79-4A89-A3D6-A37998FB86B0".Sha256()) },
51+
52+
RedirectUris = { "http://localhost:5003/signin-oidc" },
53+
FrontChannelLogoutUri = "http://localhost:5003/signout-oidc",
54+
PostLogoutRedirectUris = { "http://localhost:5003/signout-callback-oidc" },
55+
56+
AllowOfflineAccess = true,
57+
AllowedScopes = { "openid", "profile", "api1" }
58+
},
59+
60+
// SPA client using code flow + pkce
61+
new Client
62+
{
63+
ClientId = "spa",
64+
ClientName = "SPA Client",
65+
ClientUri = "http://identityserver.io",
66+
67+
AllowedGrantTypes = GrantTypes.Code,
68+
RequirePkce = true,
69+
RequireClientSecret = false,
70+
71+
RedirectUris =
72+
{
73+
"http://localhost:5002/index.html",
74+
"http://localhost:5002/callback.html",
75+
"http://localhost:5002/silent.html",
76+
"http://localhost:5002/popup.html",
77+
},
78+
79+
PostLogoutRedirectUris = { "http://localhost:5002/index.html" },
80+
AllowedCorsOrigins = { "http://localhost:5002" },
81+
82+
AllowedScopes = { "openid", "profile", "api1" }
83+
}
84+
};
85+
}
86+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Azure.Identity" Version="1.1.0" />
9+
<PackageReference Include="Azure.Security.KeyVault.Keys" Version="4.0.1" />
10+
<PackageReference Include="IdentityServer4" Version="4.0.0-preview.1" />
11+
12+
<PackageReference Include="Serilog" Version="2.9.0" />
13+
<PackageReference Include="Serilog.AspNetCore" Version="3.1.0" />
14+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
15+
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
16+
</ItemGroup>
17+
18+
</Project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. 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 IdentityServer
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("System", LogEventLevel.Warning)
22+
.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
23+
.Enrich.FromLogContext()
24+
// uncomment to write to Azure diagnostics stream
25+
//.WriteTo.File(
26+
// @"D:\home\LogFiles\Application\identityserver.txt",
27+
// fileSizeLimitBytes: 1_000_000,
28+
// rollOnFileSizeLimit: true,
29+
// shared: true,
30+
// flushToDiskInterval: TimeSpan.FromSeconds(1))
31+
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Literate)
32+
.CreateLogger();
33+
34+
try
35+
{
36+
Log.Information("Starting host...");
37+
CreateHostBuilder(args).Build().Run();
38+
return 0;
39+
}
40+
catch (Exception ex)
41+
{
42+
Log.Fatal(ex, "Host terminated unexpectedly.");
43+
return 1;
44+
}
45+
finally
46+
{
47+
Log.CloseAndFlush();
48+
}
49+
}
50+
51+
public static IHostBuilder CreateHostBuilder(string[] args) =>
52+
Host.CreateDefaultBuilder(args)
53+
.ConfigureWebHostDefaults(webBuilder =>
54+
{
55+
webBuilder.UseStartup<Startup>();
56+
webBuilder.UseSerilog();
57+
});
58+
}
59+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:5000/",
7+
"sslPort": 0
8+
}
9+
},
10+
"profiles": {
11+
"SelfHost": {
12+
"commandName": "Project",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
},
17+
"applicationUrl": "http://localhost:5000"
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)