Skip to content

Commit

Permalink
Initial working solution
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbrady91 committed Jan 31, 2019
1 parent 3e1a36a commit bd16e1c
Show file tree
Hide file tree
Showing 64 changed files with 21,230 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -334,4 +334,7 @@ target
.gradle
local.properties
*.lock
/app/snippets-api
/app/snippets-api

**/tempkey.rsa
**/identityserver4_log.txt
17 changes: 17 additions & 0 deletions AuthorizationServer/AuthorizationServer.csproj
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="IdentityServer4" Version="2.3.0" />

<PackageReference Include="Serilog" Version="2.7.1" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
</ItemGroup>

</Project>
47 changes: 47 additions & 0 deletions AuthorizationServer/Config.cs
@@ -0,0 +1,47 @@
using IdentityServer4.Models;
using System.Collections.Generic;

namespace AuthorizationServer
{
public static class Config
{
public static IEnumerable<IdentityResource> GetIdentityResources()
{
return new IdentityResource[]
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
};
}

public static IEnumerable<ApiResource> GetApis()
{
return new ApiResource[]
{
new ApiResource("api1", "API #1")
{
Scopes =
{
new Scope("api1.read"),
new Scope("api1.write")
}
}
};
}

public static IEnumerable<Client> GetClients()
{
return new Client[]
{
new Client
{
ClientId = "ktor_app",
AllowedGrantTypes = GrantTypes.Code,
AllowedScopes = {"api1.read", "api1.write"},
ClientSecrets = {new Secret("super_secret".Sha256())},
RedirectUris = {"http://localhost:8080/callback"}
}
};
}
}
}
40 changes: 40 additions & 0 deletions AuthorizationServer/Program.cs
@@ -0,0 +1,40 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.


using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Serilog;
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
using System;

namespace AuthorizationServer
{
public class Program
{
public static void Main(string[] args)
{
Console.Title = "IdentityServer4";

CreateWebHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseSerilog((context, configuration) =>
{
configuration
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("System", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.File(@"identityserver4_log.txt")
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Literate);
});
}
}
}
19 changes: 19 additions & 0 deletions AuthorizationServer/Properties/launchSettings.json
@@ -0,0 +1,19 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5000/",
"sslPort": 0
}
},
"profiles": {
"AuthorizationServer": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5000"
}
}
}

0 comments on commit bd16e1c

Please sign in to comment.