diff --git a/Stormpath.AspNet.sln b/Stormpath.AspNet.sln index 517a9ca..19c65f1 100644 --- a/Stormpath.AspNet.sln +++ b/Stormpath.AspNet.sln @@ -1,20 +1,25 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26403.7 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C9C891A0-8043-4EAF-9DF1-39ACD3EFA488}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stormpath.AspNet", "src\Stormpath.AspNet\Stormpath.AspNet.xproj", "{869166A9-F474-46DB-B06B-FD9922674D38}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{1A140068-0DEB-471A-97E3-3AFBD0EB9FE1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stormpath.AspNet.TckHarness", "test\Stormpath.AspNet.TckHarness\Stormpath.AspNet.TckHarness.csproj", "{42CED7DE-0739-47EF-9089-1FA85347E124}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{6D732EF3-2AFE-482D-9EE3-C88C8907D755}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stormpath.AspNet", "src\Stormpath.AspNet\Stormpath.AspNet.csproj", "{869166A9-F474-46DB-B06B-FD9922674D38}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stormpath.AspNet.TckHarness", "test\Stormpath.AspNet.TckHarness\Stormpath.AspNet.TckHarness.csproj", "{42CED7DE-0739-47EF-9089-1FA85347E124}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stormpath.AspNet.DocExamples", "docs\Stormpath.AspNet.DocExamples\Stormpath.AspNet.DocExamples.csproj", "{DF2E96E0-169B-4F69-B92A-A9CC30CAE2C2}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{584D2977-BBEB-4508-B996-9164E06BA8BF}" + ProjectSection(SolutionItems) = preProject + build.cake = build.cake + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/build.cake b/build.cake index 165530c..4c040f0 100644 --- a/build.cake +++ b/build.cake @@ -15,16 +15,22 @@ Task("Restore") Task("Build") .Does(() => { - DotNetCoreBuild("./src/**/project.json", new DotNetCoreBuildSettings + var projects = GetFiles("./src/**/*.csproj"); + Console.WriteLine("Building {0} projects", projects.Count()); + + foreach (var project in projects) { - Configuration = configuration - }); + DotNetCoreBuild(project.FullPath, new DotNetCoreBuildSettings + { + Configuration = configuration + }); + } }); Task("Pack") .Does(() => { - var projects = GetFiles("./src/**/project.json"); + var projects = GetFiles("./src/**/*.csproj"); Console.WriteLine("Packing {0} projects", projects.Count()); foreach (var project in projects) diff --git a/src/Stormpath.AspNet/AccountIdentityTransformer.cs b/src/Stormpath.AspNet/AccountIdentityTransformer.cs index bb55924..81f1840 100644 --- a/src/Stormpath.AspNet/AccountIdentityTransformer.cs +++ b/src/Stormpath.AspNet/AccountIdentityTransformer.cs @@ -1,12 +1,12 @@ using System.Collections.Generic; using System.Security.Claims; -using Stormpath.SDK.Account; +using Stormpath.Owin.Abstractions; namespace Stormpath.AspNet { public static class AccountIdentityTransformer { - public static ClaimsPrincipal CreatePrincipal(IAccount account, string scheme) + public static ClaimsPrincipal CreatePrincipal(ICompatibleOktaAccount account, string scheme) { var identity = CreateIdentity(account, scheme); @@ -15,7 +15,7 @@ public static ClaimsPrincipal CreatePrincipal(IAccount account, string scheme) : new ClaimsPrincipal(identity); } - public static ClaimsIdentity CreateIdentity(IAccount account, string scheme) + public static ClaimsIdentity CreateIdentity(ICompatibleOktaAccount account, string scheme) { if (account == null) { diff --git a/src/Stormpath.AspNet/HttpRequestExtensions.cs b/src/Stormpath.AspNet/HttpRequestExtensions.cs index 6d55772..725aa43 100644 --- a/src/Stormpath.AspNet/HttpRequestExtensions.cs +++ b/src/Stormpath.AspNet/HttpRequestExtensions.cs @@ -2,47 +2,21 @@ using System.Web; using Stormpath.Configuration.Abstractions.Immutable; using Stormpath.Owin.Abstractions; -using Stormpath.SDK.Account; -using Stormpath.SDK.Application; -using Stormpath.SDK.Client; -using Stormpath.SDK.Sync; namespace Stormpath.AspNet { public static class HttpRequestExtensions { - public static IClient GetStormpathClient(this HttpRequestBase request) - => request.GetOwinContext().Get(OwinKeys.StormpathClient); + public static ICompatibleOktaAccount GetStormpathAccount(this HttpRequestBase request) + => request.GetOwinContext().Get(OwinKeys.StormpathUser); - public static IClient GetStormpathClient(this HttpRequestMessage request) - => request.GetOwinContext().Get(OwinKeys.StormpathClient); - - public static IAccount GetStormpathAccount(this HttpRequestBase request) - => request.GetOwinContext().Get(OwinKeys.StormpathUser); - - public static IAccount GetStormpathAccount(this HttpRequestMessage request) - => request.GetOwinContext().Get(OwinKeys.StormpathUser); + public static ICompatibleOktaAccount GetStormpathAccount(this HttpRequestMessage request) + => request.GetOwinContext().Get(OwinKeys.StormpathUser); public static StormpathConfiguration GetStormpathConfiguration(this HttpRequestBase request) => request.GetOwinContext().Get(OwinKeys.StormpathConfiguration); public static StormpathConfiguration GetStormpathConfiguration(this HttpRequestMessage request) => request.GetOwinContext().Get(OwinKeys.StormpathConfiguration); - - public static IApplication GetStormpathApplication(this HttpRequestBase request) - { - var client = request.GetStormpathClient(); - var configuration = request.GetStormpathConfiguration(); - - return client.GetApplication(configuration.Application.Href); - } - - public static IApplication GetStormpathApplication(this HttpRequestMessage request) - { - var client = request.GetStormpathClient(); - var configuration = request.GetStormpathConfiguration(); - - return client.GetApplication(configuration.Application.Href); - } } } diff --git a/src/Stormpath.AspNet/RazorViewRenderer.cs b/src/Stormpath.AspNet/RazorViewRenderer.cs index 2159b0a..692e3a3 100644 --- a/src/Stormpath.AspNet/RazorViewRenderer.cs +++ b/src/Stormpath.AspNet/RazorViewRenderer.cs @@ -6,12 +6,11 @@ using System.Web; using System.Web.Mvc; using System.Web.Routing; +using Microsoft.Extensions.Logging; using Stormpath.Configuration.Abstractions.Immutable; using Stormpath.Owin.Abstractions; +using Stormpath.Owin.Abstractions.Configuration; using Stormpath.Owin.Middleware; -using Stormpath.SDK.Account; -using Stormpath.SDK.Client; -using Stormpath.SDK.Logging; namespace Stormpath.AspNet { @@ -33,7 +32,7 @@ public Task RenderAsync(string name, object model, IOwinEnvironment contex var httpContext = context.Request[HttpContextKey] as HttpContextWrapper; if (httpContext == null) { - _logger.Error($"Request did not include item '{HttpContextKey}'", nameof(RazorViewRenderer)); + _logger.LogError($"Request did not include item '{HttpContextKey}'", nameof(RazorViewRenderer)); return Task.FromResult(false); } @@ -63,7 +62,7 @@ public Task RenderAsync(string name, object model, IOwinEnvironment contex } catch (Exception ex) { - _logger.Error(ex, null, nameof(RazorViewRenderer)); + _logger.LogError(1000, ex, null, nameof(RazorViewRenderer)); return Task.FromResult(false); } } @@ -74,7 +73,7 @@ private static IView FindView(string path, object model, ControllerContext contr if (viewEngineResult?.View == null) { - logger.Trace($"Could not find Razor view '{path}'", nameof(RazorViewRenderer)); + logger.LogTrace($"Could not find Razor view '{path}'", nameof(RazorViewRenderer)); return null; } @@ -87,12 +86,11 @@ private static IView FindView(string path, object model, ControllerContext contr private static void GetUserIdentity(HttpContextBase httpContext, ILogger logger) { var owinContext = httpContext.GetOwinContext(); - var client = owinContext.Get(OwinKeys.StormpathClient); - var config = owinContext.Get(OwinKeys.StormpathConfiguration); + var config = owinContext.Get(OwinKeys.StormpathConfiguration); var scheme = owinContext.Get(OwinKeys.StormpathUserScheme); - var account = owinContext.Get(OwinKeys.StormpathUser); + var account = owinContext.Get(OwinKeys.StormpathUser); - var handler = new RouteProtector(client, config, null, null, null, null, logger); + var handler = new RouteProtector(config, null, null, null, null, logger); var isAuthenticatedRequest = handler.IsAuthenticated(scheme, scheme, account); if (isAuthenticatedRequest) diff --git a/src/Stormpath.AspNet/Stormpath.AspNet.csproj b/src/Stormpath.AspNet/Stormpath.AspNet.csproj new file mode 100644 index 0000000..7d5d4b6 --- /dev/null +++ b/src/Stormpath.AspNet/Stormpath.AspNet.csproj @@ -0,0 +1,37 @@ + + + + Stormpath middleware for ASP.NET 4.5+. Easily add authentication and authorization to ASP.NET applications. + (c) 2016 Stormpath, Inc. + 4.0.0-rc1 + Nate Barbettini + net451 + $(NoWarn);CS1591 + true + true + Stormpath.AspNet + Stormpath.AspNet + stormpath;authentication;authorization + https://raw.githubusercontent.com/stormpath/stormpath-sdk-dotnet/master/icon.png + https://github.com/stormpath/stormpath-aspnet + https://github.com/stormpath/stormpath-aspnet/blob/master/LICENSE + https://github.com/stormpath/stormpath-aspnet + + + + + + + + + + + + + + + + + + + diff --git a/src/Stormpath.AspNet/Stormpath.AspNet.xproj b/src/Stormpath.AspNet/Stormpath.AspNet.xproj deleted file mode 100644 index c4aabf6..0000000 --- a/src/Stormpath.AspNet/Stormpath.AspNet.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 869166a9-f474-46db-b06b-fd9922674d38 - Stormpath.AspNet - .\obj - .\bin\ - - - 2.0 - - - diff --git a/src/Stormpath.AspNet/StormpathAppBuilderExtensions.cs b/src/Stormpath.AspNet/StormpathAppBuilderExtensions.cs index 58a2249..c6d8a73 100644 --- a/src/Stormpath.AspNet/StormpathAppBuilderExtensions.cs +++ b/src/Stormpath.AspNet/StormpathAppBuilderExtensions.cs @@ -42,7 +42,6 @@ public static IAppBuilder UseStormpath(this IAppBuilder app, StormpathMiddleware Configuration = options?.Configuration, ConfigurationFileRoot = AppDomain.CurrentDomain.BaseDirectory, Logger = options?.Logger, - CacheProvider = options?.CacheProvider, PostChangePasswordHandler = options?.PostChangePasswordHandler, PostLoginHandler = options?.PostLoginHandler, PostLogoutHandler = options?.PostLogoutHandler, @@ -53,12 +52,12 @@ public static IAppBuilder UseStormpath(this IAppBuilder app, StormpathMiddleware PreLogoutHandler = options?.PreLogoutHandler, PreRegistrationHandler = options?.PreRegistrationHandler, PreVerifyEmailHandler = options?.PreVerifyEmailHandler, + SendVerificationEmailHandler = options?.SendVerificationEmailHandler }); app.Use(stormpathMiddleware); app.Use( - stormpathMiddleware.GetClient(), new StormpathAuthenticationOptions() { AllowedAuthenticationSchemes = new[] { "Cookie", "Bearer" } }, stormpathMiddleware.Configuration, options?.Logger); diff --git a/src/Stormpath.AspNet/StormpathAuthenticationHandler.cs b/src/Stormpath.AspNet/StormpathAuthenticationHandler.cs index ae3f9ba..8cbe550 100644 --- a/src/Stormpath.AspNet/StormpathAuthenticationHandler.cs +++ b/src/Stormpath.AspNet/StormpathAuthenticationHandler.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; using Microsoft.Owin; using Microsoft.Owin.Security; using Microsoft.Owin.Security.Infrastructure; @@ -8,28 +9,24 @@ using Stormpath.Owin.Abstractions; using Stormpath.Owin.Abstractions.Configuration; using Stormpath.Owin.Middleware; -using Stormpath.SDK.Account; -using Stormpath.SDK.Client; -using Stormpath.SDK.Logging; namespace Stormpath.AspNet { public sealed class StormpathAuthenticationHandler : AuthenticationHandler { - private readonly SDK.Logging.ILogger _stormpathLogger; + private readonly ILogger _logger; private readonly RouteProtector _protector; public StormpathAuthenticationHandler( - IClient client, - IntegrationConfiguration configuration - , SDK.Logging.ILogger stormpathLogger) + IntegrationConfiguration configuration, + ILogger logger) { - _stormpathLogger = stormpathLogger; + _logger = logger; - _protector = CreateRouteProtector(client, configuration); + _protector = CreateRouteProtector(configuration); } - private RouteProtector CreateRouteProtector(IClient client, IntegrationConfiguration configuration) + private RouteProtector CreateRouteProtector(IntegrationConfiguration configuration) { var deleteCookieAction = new Action(cookie => { @@ -45,19 +42,18 @@ private RouteProtector CreateRouteProtector(IClient client, IntegrationConfigura var redirectAction = new Action(location => Response.Redirect(location)); return new RouteProtector( - client, configuration, deleteCookieAction, setStatusCodeAction, setHeaderAction, redirectAction, - _stormpathLogger); + _logger); } protected override Task AuthenticateCoreAsync() { var scheme = Context.Get(OwinKeys.StormpathUserScheme); - var account = Context.Get(OwinKeys.StormpathUser); + var account = Context.Get(OwinKeys.StormpathUser); if (Options.AllowedAuthenticationSchemes.Any(potentialScheme => _protector.IsAuthenticated(scheme, potentialScheme, account))) { @@ -66,7 +62,7 @@ protected override Task AuthenticateCoreAsync() return Task.FromResult(ticket); } - _stormpathLogger.Trace("Request is not authenticated", source: nameof(StormpathAuthenticationHandler)); + _logger.LogTrace("Request is not authenticated", nameof(StormpathAuthenticationHandler)); return Task.FromResult(null); } diff --git a/src/Stormpath.AspNet/StormpathAuthenticationMiddleware.cs b/src/Stormpath.AspNet/StormpathAuthenticationMiddleware.cs index 53fbcc5..1ff0cdd 100644 --- a/src/Stormpath.AspNet/StormpathAuthenticationMiddleware.cs +++ b/src/Stormpath.AspNet/StormpathAuthenticationMiddleware.cs @@ -1,21 +1,18 @@ using System; +using Microsoft.Extensions.Logging; using Microsoft.Owin; using Microsoft.Owin.Security.Infrastructure; using Stormpath.Owin.Abstractions.Configuration; -using Stormpath.SDK.Client; -using Stormpath.SDK.Logging; namespace Stormpath.AspNet { public class StormpathAuthenticationMiddleware : AuthenticationMiddleware { - private readonly IClient _client; // TODO remove when refactoring JWT stuff private readonly IntegrationConfiguration _configuration; - private readonly ILogger _stormpathLogger; + private readonly ILogger _logger; public StormpathAuthenticationMiddleware( OwinMiddleware next, - IClient client, StormpathAuthenticationOptions options, IntegrationConfiguration configuration, ILogger logger) @@ -26,11 +23,6 @@ public StormpathAuthenticationMiddleware( throw new ArgumentNullException(nameof(next)); } - if (client == null) - { - throw new ArgumentNullException(nameof(client)); - } - if (options == null) { throw new ArgumentNullException(nameof(options)); @@ -41,18 +33,14 @@ public StormpathAuthenticationMiddleware( throw new ArgumentNullException(nameof(configuration)); } - _client = client; _configuration = configuration; - _stormpathLogger = logger; + _logger = logger; } // Called for each request, to create a handler for each request. protected override AuthenticationHandler CreateHandler() { - return new StormpathAuthenticationHandler( - _client, - _configuration, - _stormpathLogger); + return new StormpathAuthenticationHandler(_configuration, _logger); } } } diff --git a/src/Stormpath.AspNet/StormpathMiddlewareOptions.cs b/src/Stormpath.AspNet/StormpathMiddlewareOptions.cs index fdac998..b006e66 100644 --- a/src/Stormpath.AspNet/StormpathMiddlewareOptions.cs +++ b/src/Stormpath.AspNet/StormpathMiddlewareOptions.cs @@ -1,9 +1,8 @@ using System; using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; using Stormpath.Owin.Middleware; -using Stormpath.SDK.Cache; -using Stormpath.SDK.Logging; namespace Stormpath.AspNet { @@ -13,8 +12,6 @@ public sealed class StormpathMiddlewareOptions public ILogger Logger { get; set; } - public ICacheProviderBuilder CacheProvider { get; set; } - public Func PreChangePasswordHandler { get; set; } public Func PostChangePasswordHandler { get; set; } @@ -34,5 +31,7 @@ public sealed class StormpathMiddlewareOptions public Func PreVerifyEmailHandler { get; set; } public Func PostVerifyEmailHandler { get; set; } + + public Func SendVerificationEmailHandler { get; set; } } } diff --git a/src/Stormpath.AspNet/WebApi/StormpathCustomDataRequiredAttribute.cs b/src/Stormpath.AspNet/WebApi/StormpathCustomDataRequiredAttribute.cs index 0d6b6de..cdb878d 100644 --- a/src/Stormpath.AspNet/WebApi/StormpathCustomDataRequiredAttribute.cs +++ b/src/Stormpath.AspNet/WebApi/StormpathCustomDataRequiredAttribute.cs @@ -41,23 +41,25 @@ public StormpathCustomDataRequiredAttribute(string key, object value, IEqualityC _comparer = comparer; } - public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken) + public Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken) { if (!context.Principal.Identity.IsAuthenticated) { context.ErrorResult = new AuthorizationFailureResult(HttpStatusCode.Unauthorized, "Not authenticated", context.Request); - return; + return Task.FromResult(0); } var account = context.Request.GetStormpathAccount(); var requireCustomDataFilter = new RequireCustomDataFilter(_key, _value, _comparer); - var authorized = await requireCustomDataFilter.IsAuthorizedAsync(account, cancellationToken); + var authorized = requireCustomDataFilter.IsAuthorized(account); if (!authorized) { context.ErrorResult = new AuthorizationFailureResult(HttpStatusCode.Forbidden, "Not Authorized", context.Request); } + + return Task.FromResult(0); } public Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken) diff --git a/src/Stormpath.AspNet/WebApi/StormpathGroupsRequiredAttribute.cs b/src/Stormpath.AspNet/WebApi/StormpathGroupsRequiredAttribute.cs index bf38036..27313fe 100644 --- a/src/Stormpath.AspNet/WebApi/StormpathGroupsRequiredAttribute.cs +++ b/src/Stormpath.AspNet/WebApi/StormpathGroupsRequiredAttribute.cs @@ -1,6 +1,4 @@ -using Stormpath.SDK; -using System; -using System.Linq; +using System; using System.Net; using System.Threading; using System.Threading.Tasks; @@ -31,23 +29,25 @@ public StormpathGroupsRequiredAttribute(params string[] allowedNamesorHrefs) _allowedGroupNamesOrHrefs = allowedNamesorHrefs; } - public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken) + public Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken) { if (!context.Principal.Identity.IsAuthenticated) { context.ErrorResult = new AuthorizationFailureResult(HttpStatusCode.Unauthorized, "Not authenticated", context.Request); - return; + return Task.FromResult(0); } var account = context.Request.GetStormpathAccount(); var requireGroupsFilter = new RequireGroupsFilter(_allowedGroupNamesOrHrefs); - var authorized = await requireGroupsFilter.IsAuthorizedAsync(account, cancellationToken); + var authorized = requireGroupsFilter.IsAuthorized(account); if (!authorized) { context.ErrorResult = new AuthorizationFailureResult(HttpStatusCode.Forbidden, "Not Authorized", context.Request); } + + return Task.FromResult(0); } public Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken) diff --git a/src/Stormpath.AspNet/project.json b/src/Stormpath.AspNet/project.json deleted file mode 100644 index b567534..0000000 --- a/src/Stormpath.AspNet/project.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "authors": [ "Nate Barbettini" ], - "buildOptions": { - "nowarn": [ - "CS1591" - ], - "warningsAsErrors": true, - "xmlDoc": true - }, - "copyright": "(c) 2016 Stormpath, Inc.", - "dependencies": { - "Microsoft.AspNet.Mvc": "5.2.3", - "Microsoft.AspNet.WebApi.Owin": "5.2.3", - "Microsoft.Owin": "3.0.1", - "Microsoft.Owin.Host.SystemWeb": "3.0.1", - "Microsoft.Owin.Security": "3.0.1", - "Stormpath.Owin.Middleware": "3.2.0", - "Stormpath.Owin.Views.Precompiled": "0.4.4" - }, - "description": "Stormpath middleware for ASP.NET 4.5+. Easily add authentication and authorization to ASP.NET applications.", - "frameworks": { - "net45": { - "frameworkAssemblies": { - "System.Web": "4.0.0.0" - } - } - }, - "packOptions": { - "iconUrl": "https://raw.githubusercontent.com/stormpath/stormpath-sdk-dotnet/master/icon.png", - "licenseUrl": "https://github.com/stormpath/stormpath-aspnet/blob/master/LICENSE", - "owners": [ "Stormpath, Inc." ], - "projectUrl": "https://github.com/stormpath/stormpath-aspnet", - "repository": { - "url": "https://github.com/stormpath/stormpath-aspnet" - }, - "tags": [ "stormpath", "authentication", "authorization" ] - }, - "tooling": { - "defaultNamespace": "Stormpath.AspNet" - }, - "version": "0.9.0" -} diff --git a/test/Stormpath.AspNet.TckHarness/Controllers/ApplicationController.cs b/test/Stormpath.AspNet.TckHarness/Controllers/ApplicationController.cs deleted file mode 100644 index 59a8891..0000000 --- a/test/Stormpath.AspNet.TckHarness/Controllers/ApplicationController.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Web.Mvc; - -namespace Stormpath.AspNet.TckHarness.Controllers -{ - [Route("/application")] - public class ApplicationController : Controller - { - public string Index() - { - return Request.GetStormpathApplication().Href; - } - } -} \ No newline at end of file diff --git a/test/Stormpath.AspNet.TckHarness/Controllers/ClientController.cs b/test/Stormpath.AspNet.TckHarness/Controllers/ClientController.cs deleted file mode 100644 index 685e1c6..0000000 --- a/test/Stormpath.AspNet.TckHarness/Controllers/ClientController.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Threading.Tasks; -using System.Web.Mvc; - -namespace Stormpath.AspNet.TckHarness.Controllers -{ - [Route("/client")] - public class ClientController : Controller - { - public async Task Index() - { - var tenant = await Request.GetStormpathClient().GetCurrentTenantAsync(); - - return tenant.Href; - } - } -} \ No newline at end of file diff --git a/test/Stormpath.AspNet.TckHarness/Controllers/ConfigController.cs b/test/Stormpath.AspNet.TckHarness/Controllers/ConfigController.cs index 668c5fd..0913cec 100644 --- a/test/Stormpath.AspNet.TckHarness/Controllers/ConfigController.cs +++ b/test/Stormpath.AspNet.TckHarness/Controllers/ConfigController.cs @@ -7,7 +7,7 @@ public class ConfigController : Controller { public string Index() { - return Request.GetStormpathConfiguration().Application.Name; + return Request.GetStormpathConfiguration().Application.Id; } } } \ No newline at end of file diff --git a/test/Stormpath.AspNet.TckHarness/Startup.Auth.cs b/test/Stormpath.AspNet.TckHarness/Startup.Auth.cs index 0fb74cb..a37675a 100644 --- a/test/Stormpath.AspNet.TckHarness/Startup.Auth.cs +++ b/test/Stormpath.AspNet.TckHarness/Startup.Auth.cs @@ -1,9 +1,9 @@ using System; using System.IO; using System.Text; +using Microsoft.Extensions.Logging; using Owin; using Stormpath.Configuration.Abstractions; -using Stormpath.SDK.Logging; namespace Stormpath.AspNet.TckHarness { @@ -13,8 +13,19 @@ public void ConfigureAuth(IAppBuilder app) { var logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StormpathMiddleware.log"); + var stormpathConfiguration = new StormpathConfiguration + { + Org = "https://dev-123456.oktapreview.com", + ApiToken = "your_api_token", + Application = new OktaApplicationConfiguration + { + Id = "abcd12345" + } + }; + app.UseStormpath(new StormpathMiddlewareOptions() { + Configuration = stormpathConfiguration, Logger = new FileLogger(logPath, LogLevel.Trace) }); } @@ -33,29 +44,25 @@ public FileLogger(string path, LogLevel severity) _severity = severity; } - public void Log(LogEntry entry) + public IDisposable BeginScope(TState state) { - if (entry.Severity < _severity) - { - return; - } + throw new NotImplementedException(); + } - var logBuilder = new StringBuilder() - .Append($"[{entry.Severity}] {entry.Source}: "); + public bool IsEnabled(LogLevel logLevel) => true; - if (entry.Exception != null) + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + { + if (logLevel < _severity) { - logBuilder.Append($"Exception {entry.Exception.GetType().Name} \"{entry.Exception.Message}\" in {entry.Exception.Source} "); + return; } - bool isMessageUseful = !string.IsNullOrEmpty(entry.Message) - && !entry.Message.Equals(entry.Exception?.Message, StringComparison.Ordinal); - if (isMessageUseful) - { - logBuilder.Append($"\"{entry.Message}\""); - } + var logBuilder = new StringBuilder() + .Append($"[{logLevel}] {eventId}: "); - logBuilder.Append("\n"); + var message = formatter(state, exception); + logBuilder.AppendLine(message); lock (_lock) { diff --git a/test/Stormpath.AspNet.TckHarness/Stormpath.AspNet.TckHarness.csproj b/test/Stormpath.AspNet.TckHarness/Stormpath.AspNet.TckHarness.csproj index 7235253..3852476 100644 --- a/test/Stormpath.AspNet.TckHarness/Stormpath.AspNet.TckHarness.csproj +++ b/test/Stormpath.AspNet.TckHarness/Stormpath.AspNet.TckHarness.csproj @@ -54,17 +54,32 @@ True - - ..\..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll - True + + ..\..\packages\Microsoft.Extensions.Logging.Abstractions.1.1.1\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll - - ..\..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll - True + + ..\..\packages\Microsoft.IdentityModel.Logging.1.1.3\lib\net451\Microsoft.IdentityModel.Logging.dll - - ..\..\packages\Microsoft.Owin.Security.3.0.1\lib\net45\Microsoft.Owin.Security.dll - True + + ..\..\packages\Microsoft.IdentityModel.Protocols.2.1.3\lib\net451\Microsoft.IdentityModel.Protocols.dll + + + ..\..\packages\Microsoft.IdentityModel.Protocols.OpenIdConnect.2.1.3\lib\net451\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll + + + ..\..\packages\Microsoft.IdentityModel.Tokens.5.1.3\lib\net451\Microsoft.IdentityModel.Tokens.dll + + + ..\..\packages\Microsoft.Owin.3.1.0\lib\net45\Microsoft.Owin.dll + + + ..\..\packages\Microsoft.Owin.Host.SystemWeb.3.1.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll + + + ..\..\packages\Microsoft.Owin.Security.3.1.0\lib\net45\Microsoft.Owin.Security.dll + + + ..\..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll ..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll @@ -82,53 +97,78 @@ ..\..\packages\RestSharp.105.2.3\lib\net46\RestSharp.dll True - - False - ..\..\src\Stormpath.AspNet\bin\Debug\net45\Stormpath.AspNet.dll + + ..\..\packages\Stormpath.Configuration.7.0.0-beta3\lib\net45\Stormpath.Configuration.dll - - ..\..\packages\Stormpath.Configuration.6.0.0\lib\net45\Stormpath.Configuration.dll - True + + ..\..\packages\Stormpath.Configuration.Abstractions.7.0.0-beta3\lib\net45\Stormpath.Configuration.Abstractions.dll - - ..\..\packages\Stormpath.Configuration.Abstractions.6.0.0\lib\net45\Stormpath.Configuration.Abstractions.dll - True + + ..\..\packages\Stormpath.Owin.Abstractions.2.0.0-beta1\lib\net45\Stormpath.Owin.Abstractions.dll - - ..\..\packages\Stormpath.Owin.Abstractions.1.7.2\lib\net45\Stormpath.Owin.Abstractions.dll - True - - - ..\..\packages\Stormpath.Owin.Middleware.3.2.0\lib\net45\Stormpath.Owin.Middleware.dll - True - - - ..\..\packages\Stormpath.Owin.Views.Precompiled.0.4.4\lib\net45\Stormpath.Owin.Views.Precompiled.dll - True + + ..\..\packages\Stormpath.Owin.Middleware.4.0.0-rc1\lib\net451\Stormpath.Owin.Middleware.dll - - ..\..\packages\Stormpath.SDK.Abstractions.0.95.1\lib\net45\Stormpath.SDK.Abstractions.dll - True - - - ..\..\packages\Stormpath.SDK.Core.0.95.1\lib\net45\Stormpath.SDK.Core.dll - True + + ..\..\packages\Stormpath.Owin.Views.Precompiled.1.0.0-beta1\lib\net45\Stormpath.Owin.Views.Precompiled.dll - - ..\..\packages\Stormpath.SDK.JsonNetSerializer.0.91.0\lib\net45\Stormpath.SDK.JsonNetSerializer.dll - True + + + ..\..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll - - ..\..\packages\Stormpath.SDK.RestSharpClient.0.94.0\lib\net45\Stormpath.SDK.RestSharpClient.dll - True + + + ..\..\packages\System.Console.4.3.0\lib\net46\System.Console.dll - + + ..\..\packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + - - ..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.0.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - True + + ..\..\packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll + + + ..\..\packages\System.IdentityModel.Tokens.Jwt.5.1.3\lib\net451\System.IdentityModel.Tokens.Jwt.dll + + + ..\..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + + + + ..\..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll + + + ..\..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + + + ..\..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + + + ..\..\packages\System.Net.Http.4.3.1\lib\net46\System.Net.Http.dll + + + ..\..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll + + + + ..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + ..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll @@ -150,8 +190,6 @@ True ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - @@ -182,6 +220,9 @@ ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll + + ..\..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + True ..\..\packages\WebGrease.1.5.2\lib\WebGrease.dll @@ -211,8 +252,6 @@ - - @@ -264,7 +303,6 @@ - @@ -276,6 +314,12 @@ + + + {869166a9-f474-46db-b06b-fd9922674d38} + Stormpath.AspNet + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/test/Stormpath.AspNet.TckHarness/Web.config b/test/Stormpath.AspNet.TckHarness/Web.config index f12bd21..abc3d45 100644 --- a/test/Stormpath.AspNet.TckHarness/Web.config +++ b/test/Stormpath.AspNet.TckHarness/Web.config @@ -58,7 +58,19 @@ - + + + + + + + + + + + + + diff --git a/test/Stormpath.AspNet.TckHarness/packages.config b/test/Stormpath.AspNet.TckHarness/packages.config index 85bb04a..e92a616 100644 --- a/test/Stormpath.AspNet.TckHarness/packages.config +++ b/test/Stormpath.AspNet.TckHarness/packages.config @@ -15,29 +15,76 @@ + + + + + - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Stormpath.AspNet.TckHarness/stormpath.yaml b/test/Stormpath.AspNet.TckHarness/stormpath.yaml deleted file mode 100644 index 1c4118a..0000000 --- a/test/Stormpath.AspNet.TckHarness/stormpath.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -application: - name: "My Application" \ No newline at end of file