-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from elsupergomez/update-asp-net-core-to-2.0
Update asp net core to 2.0
- Loading branch information
Showing
12 changed files
with
187 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,12 @@ | |
<!--To inherit the global NuGet package sources remove the <clear/> line below --> | ||
<clear /> | ||
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" /> | ||
<add key="makingsense-aspnet" value="https://ci.appveyor.com/nuget/makingsense-aspnet" /> | ||
</packageSources> | ||
<packageSourceCredentials> | ||
<makingsense-aspnet> | ||
<add key="Username" value="[email protected]" /> | ||
<add key="ClearTextPassword" value="4@pdw@BlfpQn" /> | ||
</makingsense-aspnet> | ||
</packageSourceCredentials> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
os: Visual Studio 2017 | ||
|
||
version: 1.1.3-alpha-{build} | ||
version: 2.0.0-alpha-{build} | ||
|
||
nuget: | ||
project_feed: true | ||
|
||
install: | ||
- cmd: nuget sources add -Name makingsense-aspnet -Source https://ci.appveyor.com/nuget/makingsense-aspnet -UserName [email protected] -Password 4@pdw@BlfpQn | ||
|
||
before_build: | ||
- cmd: set DOTNET_ASSEMBLY_FILE_VERSION=%APPVEYOR_BUILD_NUMBER% | ||
- cmd: set DOTNET_BUILD_VERSION=%APPVEYOR_BUILD_NUMBER% | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/MakingSense.AspNetCore.Authentication.SimpleToken/SimpleTokenAuthenticationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.IdentityModel.Tokens; | ||
using System; | ||
|
||
namespace MakingSense.AspNetCore.Authentication.SimpleToken | ||
{ | ||
public static class SimpleTokenAuthenticationExtensions | ||
{ | ||
public static AuthenticationBuilder AddSimpleTokenAuthentication(this AuthenticationBuilder builder) | ||
=> builder.AddSimpleTokenAuthentication(SimpleTokenDefaults.AuthenticationScheme, null); | ||
|
||
public static AuthenticationBuilder AddSimpleTokenAuthentication(this AuthenticationBuilder builder, | ||
Action<SimpleTokenAuthenticationOptions> configureOptions) | ||
=> builder.AddSimpleTokenAuthentication(SimpleTokenDefaults.AuthenticationScheme, configureOptions); | ||
|
||
public static AuthenticationBuilder AddSimpleTokenAuthentication(this AuthenticationBuilder builder, | ||
string authenticationScheme, | ||
Action<SimpleTokenAuthenticationOptions> configureOptions) | ||
=> builder.AddSimpleTokenAuthentication(authenticationScheme, SimpleTokenDefaults.DisplayName, configureOptions: configureOptions); | ||
|
||
public static AuthenticationBuilder AddSimpleTokenAuthentication(this AuthenticationBuilder builder, | ||
string authenticationScheme, | ||
string displayName, | ||
Action<SimpleTokenAuthenticationOptions> configureOptions) | ||
{ | ||
return builder.AddScheme<SimpleTokenAuthenticationOptions, SimpleTokenAuthenticationHandler>(authenticationScheme, displayName, | ||
(SimpleTokenAuthenticationOptions options) => { | ||
configureOptions?.Invoke(options); | ||
|
||
if (options.SecurityTokenValidatorsFactory == null) | ||
{ | ||
options.SecurityTokenValidatorsFactory = () => | ||
{ | ||
// TODO: fix it because it is using app services, and it should use scope services, | ||
// a work around could be: | ||
// ``` | ||
// SecurityTokenValidatorsFactory = () => | ||
// { | ||
// var context = builder.Services.BuildServiceProvider().GetService<IHttpContextAccessor>().HttpContext; | ||
// return context.RequestServices.GetServices<ISecurityTokenValidator>(); | ||
// } | ||
// ``` | ||
var serviceProvider = builder.Services.BuildServiceProvider(); | ||
return serviceProvider.GetServices<ISecurityTokenValidator>(); | ||
}; | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.