hacky auth working

This commit is contained in:
Tom Gardham-Pallister
2017-02-24 19:52:48 +00:00
parent bd07af6926
commit 112a9c303e
19 changed files with 448 additions and 94 deletions

View File

@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CacheManager.Core;
using IdentityServer4.AccessTokenValidation;
using IdentityServer4.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
@ -15,7 +18,7 @@ namespace Ocelot.ManualTest
{
public class Startup
{
private IdentityServerConfiguration _identityServerConfig;
private IIdentityServerConfiguration _identityServerConfig;
public Startup(IHostingEnvironment env)
{
@ -27,9 +30,6 @@ namespace Ocelot.ManualTest
.AddEnvironmentVariables();
Configuration = builder.Build();
var identityServerConfigProvider = new HardCodedIdentityServerConfigurationProvider();
_identityServerConfig = identityServerConfigProvider.Get();
}
public IConfigurationRoot Configuration { get; }
@ -46,15 +46,36 @@ namespace Ocelot.ManualTest
};
services.AddOcelotOutputCaching(settings);
services.AddOcelotFileConfiguration(Configuration);
services.AddOcelot(_identityServerConfig);
var username = Environment.GetEnvironmentVariable("OCELOT_USERNAME");
var hash = Environment.GetEnvironmentVariable("OCELOT_HASH");
var salt = Environment.GetEnvironmentVariable("OCELOT_SALT");
_identityServerConfig = new IdentityServerConfiguration(
"admin",
false,
SupportedTokens.Both,
"secret",
new List<string> {"admin", "openid", "offline_access"},
"Ocelot Administration",
true,
GrantTypes.ResourceOwnerPassword,
AccessTokenType.Jwt,
false,
new List<User>
{
new User("admin", username, hash, salt)
}
);
services.AddOcelot(Configuration, _identityServerConfig);
}
public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
await app.UseOcelot(_identityServerConfig);
await app.UseOcelot();
}
}
}

View File

@ -14,7 +14,8 @@
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.NETCore.App": "1.1.0",
"Consul": "0.7.2.1",
"Polly": "5.0.3"
"Polly": "5.0.3",
"Microsoft.AspNetCore.Cryptography.KeyDerivation": "1.1.0"
},
"tools": {