Skip to content

Commit 603d530

Browse files
Merge pull request #2 from andresmoschini/dplr-10952-upgrade-to-rc1
DPLR-10952 - Upgrade to RC1
2 parents e4fee8e + d1d7fd0 commit 603d530

File tree

7 files changed

+35
-30
lines changed

7 files changed

+35
-30
lines changed

appveyor.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
nuget:
22
account_feed: true
33

4-
version: 0.1.0-beta8-{build}
4+
version: 0.1.0-rc1-final-{build}
55

66
# init:
77
# - git config --global core.autocrlf true
@@ -11,15 +11,15 @@ version: 0.1.0-beta8-{build}
1111
# - cmd: nuget sources add -Name aspnetrelease -Source https://www.myget.org/F/aspnetrelease/api/v2
1212

1313
#environment:
14-
# DNX_BUILD_VERSION: beta8
14+
# DNX_BUILD_VERSION: rc1-final
1515
# DNX_ASSEMBLY_FILE_VERSION: 2.0.0
1616

1717
before_build:
18-
- ps: dnvm install 1.0.0-beta8
18+
- ps: dnvm install 1.0.0-rc1-final
1919
- ps: dnvm upgrade
2020
- ps: dnvm update-self
2121
- ps: dnvm list
22-
- ps: dnvm use 1.0.0-beta8
22+
- ps: dnvm use 1.0.0-rc1-final
2323
- ps: dnu restore
2424
- cmd: set DNX_BUILD_VERSION=%APPVEYOR_BUILD_NUMBER%
2525

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"projects": [ "src", "test" ],
33
"sdk": {
4-
"version": "1.0.0-beta8"
4+
"version": "1.0.0-rc1-update1"
55
}
66
}

src/MakingSense.AspNet.Authentication.SimpleToken/SimpleTokenAppBuilderExtensions.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
using System;
2+
using System.IdentityModel.Tokens;
23
using MakingSense.AspNet.Authentication.SimpleToken;
3-
using Microsoft.Framework.DependencyInjection;
4+
using Microsoft.Extensions.DependencyInjection;
45
using Microsoft.Framework.Internal;
5-
using Microsoft.Framework.OptionsModel;
6-
using System.IdentityModel.Tokens;
76

87
namespace Microsoft.AspNet.Builder
98
{
109
public static class SimpleTokenAppBuilderExtensions
1110
{
12-
public static IApplicationBuilder UseSimpleTokenAuthentication([NotNull] this IApplicationBuilder app, Action<SimpleTokenAuthenticationOptions> configureOptions = null, string optionsName = "")
11+
public static IApplicationBuilder UseSimpleTokenAuthentication([NotNull] this IApplicationBuilder app, Action<SimpleTokenAuthenticationOptions> configureOptions = null, string authenticationScheme = "Bearer")
1312
{
1413
var options = new SimpleTokenAuthenticationOptions()
1514
{
16-
AuthenticationScheme = optionsName
15+
AuthenticationScheme = authenticationScheme
1716
};
1817

1918
if (configureOptions != null)

src/MakingSense.AspNet.Authentication.SimpleToken/SimpleTokenAuthenticationHandler.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System;
2-
using Microsoft.AspNet.Http.Authentication;
32
using System.IdentityModel.Tokens;
4-
using Microsoft.AspNet.Http;
53
using System.Text;
64
using System.Threading.Tasks;
75
using MakingSense.AspNet.Authentication.Abstractions;
86
using Microsoft.AspNet.Authentication;
7+
using Microsoft.AspNet.Http;
8+
using Microsoft.AspNet.Http.Authentication;
99
using Microsoft.Net.Http.Headers;
1010

1111
namespace MakingSense.AspNet.Authentication.SimpleToken
@@ -50,6 +50,7 @@ public static string ExtractToken(HttpRequest request)
5050
}
5151
}
5252

53+
// Not so nice, but AuthenticateResult.Fail does not allow us to show the error
5354
throw new AuthenticationException("Authorization header exists but does not contains valid information.");
5455
}
5556

@@ -63,19 +64,24 @@ public static string ExtractToken(HttpRequest request)
6364
return null;
6465
}
6566

67+
static readonly Task DoneTask = Task.FromResult(0);
6668

6769
/// <summary>
6870
/// Searches the 'Authorization' header for a 'Bearer' token. If the 'Bearer' token is found, it is validated using <see cref="TokenValidationParameters"/> set in the options.
6971
/// </summary>
7072
/// <returns></returns>
71-
protected override Task<AuthenticationTicket> HandleAuthenticateAsync()
73+
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
7274
{
75+
// Ugly patch to make this method should to be async in order to allow result caching by caller
76+
await DoneTask;
77+
7378
string token = ExtractToken(Request);
7479

7580
// If no token found, no further work possible
7681
if (string.IsNullOrEmpty(token))
7782
{
78-
return Task.FromResult<AuthenticationTicket>(null);
83+
// Not so nice, but AuthenticateResult.Fail has the same behavior
84+
return null;
7985
}
8086

8187
var validationParameters = Options.TokenValidationParameters.Clone();
@@ -88,10 +94,11 @@ protected override Task<AuthenticationTicket> HandleAuthenticateAsync()
8894
{
8995
var principal = validator.ValidateToken(token, validationParameters, out validatedToken);
9096
var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), Options.AuthenticationScheme);
91-
return Task.FromResult(ticket);
97+
return AuthenticateResult.Success(ticket);
9298
}
9399
}
94100

101+
// Not so nice, but AuthenticateResult.Fail does not allow us to show the error
95102
throw new AuthenticationException("Authorization token has been detected but it cannot be read.");
96103
}
97104
}

src/MakingSense.AspNet.Authentication.SimpleToken/SimpleTokenAuthenticationMiddleware.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System;
2+
using Microsoft.AspNet.Authentication;
23
using Microsoft.AspNet.Builder;
4+
using Microsoft.Extensions.Logging;
5+
using Microsoft.Extensions.WebEncoders;
36
using Microsoft.Framework.Internal;
4-
using Microsoft.Framework.Logging;
5-
using Microsoft.Framework.OptionsModel;
6-
using Microsoft.Framework.WebEncoders;
7-
using Microsoft.AspNet.Authentication;
87

98
namespace MakingSense.AspNet.Authentication.SimpleToken
109
{

src/MakingSense.AspNet.Authentication.SimpleToken/SimpleTokenAuthenticationOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using Microsoft.AspNet.Authentication;
2-
using Microsoft.Framework.Internal;
31
using System;
42
using System.Collections.Generic;
53
using System.IdentityModel.Tokens;
4+
using Microsoft.AspNet.Authentication;
5+
using Microsoft.Framework.Internal;
66

77
namespace MakingSense.AspNet.Authentication.SimpleToken
88
{

src/MakingSense.AspNet.Authentication.SimpleToken/project.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.1.0-beta8-*",
2+
"version": "0.1.0-rc1-final-*",
33
"description": "MakingSense.AspNet.Authentication.SimpleToken Class Library",
44
"authors": [ "MakingSense" ],
55
"tags": [ "ASP.NET 5", "vnext", "authentication", "token", "bearer" ],
@@ -10,21 +10,21 @@
1010
"projectUrl": "https://github.com/MakingSense/aspnet-authentication-simpletoken",
1111
"licenseUrl": "http://www.gnu.org/licenses/lgpl.html",
1212
"dependencies": {
13-
"MakingSense.AspNet.Abstractions": "0.1.0-beta8",
14-
"Microsoft.AspNet.Authentication": "1.0.0-beta8",
13+
"MakingSense.AspNet.Abstractions": "0.1.0-rc1-final",
14+
"Microsoft.AspNet.Authentication": "1.0.0-rc1-final",
1515
"Newtonsoft.Json": "6.0.8",
16-
"System.IdentityModel.Tokens": "5.0.0-beta8-210131116"
16+
"System.IdentityModel.Tokens": "5.0.0-rc1-211161024"
1717
},
1818

1919
"frameworks": {
2020
"dnx451": { },
2121
"dnxcore50": {
2222
"dependencies": {
23-
"Microsoft.CSharp": "4.0.1-beta-23409",
24-
"System.Collections": "4.0.11-beta-23409",
25-
"System.Linq": "4.0.1-beta-23409",
26-
"System.Runtime": "4.0.21-beta-23409",
27-
"System.Threading": "4.0.11-beta-23409"
23+
"Microsoft.CSharp": "4.0.1-beta-23516",
24+
"System.Collections": "4.0.11-beta-23516",
25+
"System.Linq": "4.0.1-beta-23516",
26+
"System.Runtime": "4.0.21-beta-23516",
27+
"System.Threading": "4.0.11-beta-23516"
2828
}
2929
}
3030
}

0 commit comments

Comments
 (0)