React to WebEncoders changes.
This commit is contained in:
parent
36c267843a
commit
1a59b385a0
|
|
@ -2,6 +2,7 @@ using System.Linq;
|
|||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authentication.Cookies;
|
||||
using Microsoft.AspNet.Authentication.Google;
|
||||
|
|
@ -13,7 +14,6 @@ using Microsoft.AspNet.Http;
|
|||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace CookieSample
|
||||
|
|
@ -66,7 +66,7 @@ namespace CookieSample
|
|||
OnRemoteError = ctx =>
|
||||
|
||||
{
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.UrlEncode(ctx.Error.Message));
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message));
|
||||
ctx.HandleResponse();
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ namespace CookieSample
|
|||
{
|
||||
OnRemoteError = ctx =>
|
||||
{
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.UrlEncode(ctx.Error.Message));
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message));
|
||||
ctx.HandleResponse();
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.Cookies
|
||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
/// </summary>
|
||||
public class ChunkingCookieManager : ICookieManager
|
||||
{
|
||||
public ChunkingCookieManager(IUrlEncoder urlEncoder)
|
||||
public ChunkingCookieManager(UrlEncoder urlEncoder)
|
||||
{
|
||||
// Lowest common denominator. Safari has the lowest known limit (4093), and we leave little extra just in case.
|
||||
// See http://browsercookielimits.x64.me/.
|
||||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
/// </summary>
|
||||
public bool ThrowForPartialCookies { get; set; }
|
||||
|
||||
private IUrlEncoder Encoder { get; set; }
|
||||
private UrlEncoder Encoder { get; set; }
|
||||
|
||||
// Parse the "chunks:XX" to determine how many chunks there should be.
|
||||
private static int ParseChunksCount(string value)
|
||||
|
|
@ -149,7 +149,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
var escapedKey = Encoder.UrlEncode(key);
|
||||
var escapedKey = Encoder.Encode(key);
|
||||
|
||||
var template = new SetCookieHeaderValue(escapedKey)
|
||||
{
|
||||
|
|
@ -169,7 +169,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
quoted = true;
|
||||
value = RemoveQuotes(value);
|
||||
}
|
||||
var escapedValue = Encoder.UrlEncode(value);
|
||||
var escapedValue = Encoder.Encode(value);
|
||||
|
||||
// Normal cookie
|
||||
var responseHeaders = context.Response.Headers;
|
||||
|
|
@ -239,7 +239,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
var escapedKey = Encoder.UrlEncode(key);
|
||||
var escapedKey = Encoder.Encode(key);
|
||||
var keys = new List<string>();
|
||||
keys.Add(escapedKey + "=");
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.Cookies
|
||||
{
|
||||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IUrlEncoder urlEncoder,
|
||||
UrlEncoder urlEncoder,
|
||||
CookieAuthenticationOptions options)
|
||||
: base(next, options, loggerFactory, urlEncoder)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Authentication.OAuth;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.Facebook
|
||||
{
|
||||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Authentication.Facebook
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IUrlEncoder encoder,
|
||||
UrlEncoder encoder,
|
||||
IOptions<SharedAuthenticationOptions> sharedOptions,
|
||||
FacebookOptions options)
|
||||
: base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options)
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Authentication.OAuth;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.Google
|
||||
{
|
||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IUrlEncoder encoder,
|
||||
UrlEncoder encoder,
|
||||
IOptions<SharedAuthenticationOptions> sharedOptions,
|
||||
GoogleOptions options)
|
||||
: base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options)
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Microsoft.IdentityModel.Protocols;
|
||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
|
|||
public JwtBearerMiddleware(
|
||||
RequestDelegate next,
|
||||
ILoggerFactory loggerFactory,
|
||||
IUrlEncoder encoder,
|
||||
UrlEncoder encoder,
|
||||
JwtBearerOptions options)
|
||||
: base(next, options, loggerFactory, encoder)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Authentication.OAuth;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.MicrosoftAccount
|
||||
{
|
||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IUrlEncoder encoder,
|
||||
UrlEncoder encoder,
|
||||
IOptions<SharedAuthenticationOptions> sharedOptions,
|
||||
MicrosoftAccountOptions options)
|
||||
: base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options)
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ using System;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Net.Http;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.OAuth
|
||||
{
|
||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Authentication.OAuth
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IUrlEncoder encoder,
|
||||
UrlEncoder encoder,
|
||||
IOptions<SharedAuthenticationOptions> sharedOptions,
|
||||
TOptions options)
|
||||
: base(next, options, loggerFactory, encoder)
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ using System.Net.Http.Headers;
|
|||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.AspNet.Http.Features.Authentication;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
|
@ -53,9 +53,9 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
|
|||
|
||||
protected HttpClient Backchannel { get; private set; }
|
||||
|
||||
protected IHtmlEncoder HtmlEncoder { get; private set; }
|
||||
protected HtmlEncoder HtmlEncoder { get; private set; }
|
||||
|
||||
public OpenIdConnectHandler(HttpClient backchannel, IHtmlEncoder htmlEncoder)
|
||||
public OpenIdConnectHandler(HttpClient backchannel, HtmlEncoder htmlEncoder)
|
||||
{
|
||||
Backchannel = backchannel;
|
||||
HtmlEncoder = htmlEncoder;
|
||||
|
|
@ -133,14 +133,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
|
|||
var inputs = new StringBuilder();
|
||||
foreach (var parameter in message.Parameters)
|
||||
{
|
||||
var name = HtmlEncoder.HtmlEncode(parameter.Key);
|
||||
var value = HtmlEncoder.HtmlEncode(parameter.Value);
|
||||
var name = HtmlEncoder.Encode(parameter.Key);
|
||||
var value = HtmlEncoder.Encode(parameter.Value);
|
||||
|
||||
var input = string.Format(CultureInfo.InvariantCulture, InputTagFormat, name, value);
|
||||
inputs.AppendLine(input);
|
||||
}
|
||||
|
||||
var issuer = HtmlEncoder.HtmlEncode(message.IssuerAddress);
|
||||
var issuer = HtmlEncoder.Encode(message.IssuerAddress);
|
||||
|
||||
var content = string.Format(CultureInfo.InvariantCulture, HtmlFormFormat, issuer, inputs);
|
||||
var buffer = Encoding.UTF8.GetBytes(content);
|
||||
|
|
@ -260,14 +260,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
|
|||
var inputs = new StringBuilder();
|
||||
foreach (var parameter in message.Parameters)
|
||||
{
|
||||
var name = HtmlEncoder.HtmlEncode(parameter.Key);
|
||||
var value = HtmlEncoder.HtmlEncode(parameter.Value);
|
||||
var name = HtmlEncoder.Encode(parameter.Key);
|
||||
var value = HtmlEncoder.Encode(parameter.Value);
|
||||
|
||||
var input = string.Format(CultureInfo.InvariantCulture, InputTagFormat, name, value);
|
||||
inputs.AppendLine(input);
|
||||
}
|
||||
|
||||
var issuer = HtmlEncoder.HtmlEncode(message.IssuerAddress);
|
||||
var issuer = HtmlEncoder.Encode(message.IssuerAddress);
|
||||
|
||||
var content = string.Format(CultureInfo.InvariantCulture, HtmlFormFormat, issuer, inputs);
|
||||
var buffer = Encoding.UTF8.GetBytes(content);
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ using System;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Microsoft.IdentityModel.Protocols;
|
||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||
|
||||
|
|
@ -36,11 +36,11 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IUrlEncoder encoder,
|
||||
UrlEncoder encoder,
|
||||
IServiceProvider services,
|
||||
IOptions<SharedAuthenticationOptions> sharedOptions,
|
||||
OpenIdConnectOptions options,
|
||||
IHtmlEncoder htmlEncoder)
|
||||
HtmlEncoder htmlEncoder)
|
||||
: base(next, options, loggerFactory, encoder)
|
||||
{
|
||||
if (next == null)
|
||||
|
|
@ -169,7 +169,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
|
|||
|
||||
protected HttpClient Backchannel { get; private set; }
|
||||
|
||||
protected IHtmlEncoder HtmlEncoder { get; private set; }
|
||||
protected HtmlEncoder HtmlEncoder { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides the <see cref="AuthenticationHandler"/> object for processing authentication-related requests.
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
|
|||
var parameterBuilder = new StringBuilder();
|
||||
foreach (var authorizationKey in authorizationParts)
|
||||
{
|
||||
parameterBuilder.AppendFormat("{0}={1}&", UrlEncoder.UrlEncode(authorizationKey.Key), UrlEncoder.UrlEncode(authorizationKey.Value));
|
||||
parameterBuilder.AppendFormat("{0}={1}&", UrlEncoder.Encode(authorizationKey.Key), UrlEncoder.Encode(authorizationKey.Value));
|
||||
}
|
||||
parameterBuilder.Length--;
|
||||
var parameterString = parameterBuilder.ToString();
|
||||
|
|
@ -172,9 +172,9 @@ namespace Microsoft.AspNet.Authentication.Twitter
|
|||
var canonicalizedRequestBuilder = new StringBuilder();
|
||||
canonicalizedRequestBuilder.Append(HttpMethod.Post.Method);
|
||||
canonicalizedRequestBuilder.Append("&");
|
||||
canonicalizedRequestBuilder.Append(UrlEncoder.UrlEncode(RequestTokenEndpoint));
|
||||
canonicalizedRequestBuilder.Append(UrlEncoder.Encode(RequestTokenEndpoint));
|
||||
canonicalizedRequestBuilder.Append("&");
|
||||
canonicalizedRequestBuilder.Append(UrlEncoder.UrlEncode(parameterString));
|
||||
canonicalizedRequestBuilder.Append(UrlEncoder.Encode(parameterString));
|
||||
|
||||
var signature = ComputeSignature(consumerSecret, null, canonicalizedRequestBuilder.ToString());
|
||||
authorizationParts.Add("oauth_signature", signature);
|
||||
|
|
@ -184,7 +184,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
|
|||
foreach (var authorizationPart in authorizationParts)
|
||||
{
|
||||
authorizationHeaderBuilder.AppendFormat(
|
||||
"{0}=\"{1}\", ", authorizationPart.Key, UrlEncoder.UrlEncode(authorizationPart.Value));
|
||||
"{0}=\"{1}\", ", authorizationPart.Key, UrlEncoder.Encode(authorizationPart.Value));
|
||||
}
|
||||
authorizationHeaderBuilder.Length = authorizationHeaderBuilder.Length - 2;
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
|
|||
var parameterBuilder = new StringBuilder();
|
||||
foreach (var authorizationKey in authorizationParts)
|
||||
{
|
||||
parameterBuilder.AppendFormat("{0}={1}&", UrlEncoder.UrlEncode(authorizationKey.Key), UrlEncoder.UrlEncode(authorizationKey.Value));
|
||||
parameterBuilder.AppendFormat("{0}={1}&", UrlEncoder.Encode(authorizationKey.Key), UrlEncoder.Encode(authorizationKey.Value));
|
||||
}
|
||||
parameterBuilder.Length--;
|
||||
var parameterString = parameterBuilder.ToString();
|
||||
|
|
@ -234,9 +234,9 @@ namespace Microsoft.AspNet.Authentication.Twitter
|
|||
var canonicalizedRequestBuilder = new StringBuilder();
|
||||
canonicalizedRequestBuilder.Append(HttpMethod.Post.Method);
|
||||
canonicalizedRequestBuilder.Append("&");
|
||||
canonicalizedRequestBuilder.Append(UrlEncoder.UrlEncode(AccessTokenEndpoint));
|
||||
canonicalizedRequestBuilder.Append(UrlEncoder.Encode(AccessTokenEndpoint));
|
||||
canonicalizedRequestBuilder.Append("&");
|
||||
canonicalizedRequestBuilder.Append(UrlEncoder.UrlEncode(parameterString));
|
||||
canonicalizedRequestBuilder.Append(UrlEncoder.Encode(parameterString));
|
||||
|
||||
var signature = ComputeSignature(consumerSecret, token.TokenSecret, canonicalizedRequestBuilder.ToString());
|
||||
authorizationParts.Add("oauth_signature", signature);
|
||||
|
|
@ -247,7 +247,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
|
|||
foreach (var authorizationPart in authorizationParts)
|
||||
{
|
||||
authorizationHeaderBuilder.AppendFormat(
|
||||
"{0}=\"{1}\", ", authorizationPart.Key, UrlEncoder.UrlEncode(authorizationPart.Value));
|
||||
"{0}=\"{1}\", ", authorizationPart.Key, UrlEncoder.Encode(authorizationPart.Value));
|
||||
}
|
||||
authorizationHeaderBuilder.Length = authorizationHeaderBuilder.Length - 2;
|
||||
|
||||
|
|
@ -294,8 +294,8 @@ namespace Microsoft.AspNet.Authentication.Twitter
|
|||
algorithm.Key = Encoding.ASCII.GetBytes(
|
||||
string.Format(CultureInfo.InvariantCulture,
|
||||
"{0}&{1}",
|
||||
UrlEncoder.UrlEncode(consumerSecret),
|
||||
string.IsNullOrEmpty(tokenSecret) ? string.Empty : UrlEncoder.UrlEncode(tokenSecret)));
|
||||
UrlEncoder.Encode(consumerSecret),
|
||||
string.IsNullOrEmpty(tokenSecret) ? string.Empty : UrlEncoder.Encode(tokenSecret)));
|
||||
var hash = algorithm.ComputeHash(Encoding.ASCII.GetBytes(signatureData));
|
||||
return Convert.ToBase64String(hash);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ using System;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Net.Http;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.Twitter
|
||||
{
|
||||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IUrlEncoder encoder,
|
||||
UrlEncoder encoder,
|
||||
IOptions<SharedAuthenticationOptions> sharedOptions,
|
||||
TwitterOptions options)
|
||||
: base(next, options, loggerFactory, encoder)
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.AspNet.Http.Features.Authentication;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication
|
||||
{
|
||||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Authentication
|
|||
|
||||
protected ILogger Logger { get; private set; }
|
||||
|
||||
protected IUrlEncoder UrlEncoder { get; private set; }
|
||||
protected UrlEncoder UrlEncoder { get; private set; }
|
||||
|
||||
public IAuthenticationHandler PriorHandler { get; set; }
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ namespace Microsoft.AspNet.Authentication
|
|||
/// <param name="context">The utility object to observe the current request and response</param>
|
||||
/// <param name="logger">The logging factory used to create loggers</param>
|
||||
/// <returns>async completion</returns>
|
||||
public async Task InitializeAsync(TOptions options, HttpContext context, ILogger logger, IUrlEncoder encoder)
|
||||
public async Task InitializeAsync(TOptions options, HttpContext context, ILogger logger, UrlEncoder encoder)
|
||||
{
|
||||
if (options == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication
|
||||
{
|
||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Authentication
|
|||
RequestDelegate next,
|
||||
TOptions options,
|
||||
ILoggerFactory loggerFactory,
|
||||
IUrlEncoder encoder)
|
||||
UrlEncoder encoder)
|
||||
{
|
||||
if (next == null)
|
||||
{
|
||||
|
|
@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Authentication
|
|||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public IUrlEncoder UrlEncoder { get; set; }
|
||||
public UrlEncoder UrlEncoder { get; set; }
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Claims;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
|
|
@ -90,7 +91,7 @@ namespace Microsoft.AspNet.Authentication
|
|||
await handler.InitializeAsync(
|
||||
new CountOptions(), context,
|
||||
new LoggerFactory().CreateLogger("CountHandler"),
|
||||
Extensions.WebEncoders.UrlEncoder.Default);
|
||||
UrlEncoder.Default);
|
||||
handler.Options.AuthenticationScheme = scheme;
|
||||
handler.Options.AutomaticAuthenticate = true;
|
||||
return handler;
|
||||
|
|
@ -116,7 +117,7 @@ namespace Microsoft.AspNet.Authentication
|
|||
await handler.InitializeAsync(
|
||||
new TestOptions(), context,
|
||||
new LoggerFactory().CreateLogger("TestHandler"),
|
||||
Extensions.WebEncoders.UrlEncoder.Default);
|
||||
UrlEncoder.Default);
|
||||
handler.Options.AuthenticationScheme = scheme;
|
||||
return handler;
|
||||
}
|
||||
|
|
@ -149,7 +150,7 @@ namespace Microsoft.AspNet.Authentication
|
|||
await handler.InitializeAsync(
|
||||
new TestAutoOptions(), context,
|
||||
new LoggerFactory().CreateLogger("TestAutoHandler"),
|
||||
Extensions.WebEncoders.UrlEncoder.Default);
|
||||
UrlEncoder.Default);
|
||||
handler.Options.AuthenticationScheme = scheme;
|
||||
handler.Options.AutomaticAuthenticate = auto;
|
||||
return handler;
|
||||
|
|
|
|||
|
|
@ -2,12 +2,14 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authentication.Cookies;
|
||||
using Microsoft.AspNet.Authentication.OAuth;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
|
|
@ -15,11 +17,8 @@ using Microsoft.AspNet.Http;
|
|||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNet.Authentication.Cookies;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.Facebook
|
||||
{
|
||||
|
|
@ -90,7 +89,7 @@ namespace Microsoft.AspNet.Authentication.Facebook
|
|||
Assert.Contains("https://www.facebook.com/v2.2/dialog/oauth", location);
|
||||
Assert.Contains("response_type=code", location);
|
||||
Assert.Contains("client_id=", location);
|
||||
Assert.Contains("redirect_uri=" + UrlEncoder.Default.UrlEncode("http://example.com/base/signin-facebook"), location);
|
||||
Assert.Contains("redirect_uri=" + UrlEncoder.Default.Encode("http://example.com/base/signin-facebook"), location);
|
||||
Assert.Contains("scope=", location);
|
||||
Assert.Contains("state=", location);
|
||||
}
|
||||
|
|
@ -117,7 +116,7 @@ namespace Microsoft.AspNet.Authentication.Facebook
|
|||
Assert.Contains("https://www.facebook.com/v2.2/dialog/oauth", location);
|
||||
Assert.Contains("response_type=code", location);
|
||||
Assert.Contains("client_id=", location);
|
||||
Assert.Contains("redirect_uri="+ UrlEncoder.Default.UrlEncode("http://example.com/signin-facebook"), location);
|
||||
Assert.Contains("redirect_uri="+ UrlEncoder.Default.Encode("http://example.com/signin-facebook"), location);
|
||||
Assert.Contains("scope=", location);
|
||||
Assert.Contains("state=", location);
|
||||
}
|
||||
|
|
@ -216,7 +215,7 @@ namespace Microsoft.AspNet.Authentication.Facebook
|
|||
properties.RedirectUri = "/me";
|
||||
var state = stateFormat.Protect(properties);
|
||||
var transaction = await server.SendAsync(
|
||||
"https://example.com/signin-facebook?code=TestCode&state=" + UrlEncoder.Default.UrlEncode(state),
|
||||
"https://example.com/signin-facebook?code=TestCode&state=" + UrlEncoder.Default.Encode(state),
|
||||
correlationKey + "=" + correlationValue);
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First());
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authentication.OAuth;
|
||||
using Microsoft.AspNet.Builder;
|
||||
|
|
@ -16,7 +17,6 @@ using Microsoft.AspNet.Http.Authentication;
|
|||
using Microsoft.AspNet.Http.Features.Authentication;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
var transaction = await server.SendAsync("https://example.com/challenge");
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
var query = transaction.Response.Headers.Location.Query;
|
||||
Assert.Contains("&scope=" + UrlEncoder.Default.UrlEncode("openid profile email"), query);
|
||||
Assert.Contains("&scope=" + UrlEncoder.Default.Encode("openid profile email"), query);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -152,7 +152,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
var transaction = await server.SendAsync("https://example.com/401");
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
var query = transaction.Response.Headers.Location.Query;
|
||||
Assert.Contains("&scope=" + UrlEncoder.Default.UrlEncode("openid profile email"), query);
|
||||
Assert.Contains("&scope=" + UrlEncoder.Default.Encode("openid profile email"), query);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -185,10 +185,10 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
var transaction = await server.SendAsync("https://example.com/challenge2");
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
var query = transaction.Response.Headers.Location.Query;
|
||||
Assert.Contains("scope=" + UrlEncoder.Default.UrlEncode("https://www.googleapis.com/auth/plus.login"), query);
|
||||
Assert.Contains("scope=" + UrlEncoder.Default.Encode("https://www.googleapis.com/auth/plus.login"), query);
|
||||
Assert.Contains("access_type=offline", query);
|
||||
Assert.Contains("approval_prompt=force", query);
|
||||
Assert.Contains("login_hint=" + UrlEncoder.Default.UrlEncode("test@example.com"), query);
|
||||
Assert.Contains("login_hint=" + UrlEncoder.Default.Encode("test@example.com"), query);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -263,7 +263,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
{
|
||||
OnRemoteError = ctx =>
|
||||
{
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.UrlEncode(ctx.Error.Message));
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message));
|
||||
ctx.HandleResponse();
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
|
@ -341,7 +341,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
properties.RedirectUri = "/me";
|
||||
var state = stateFormat.Protect(properties);
|
||||
var transaction = await server.SendAsync(
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.UrlEncode(state),
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state),
|
||||
correlationKey + "=" + correlationValue);
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First());
|
||||
|
|
@ -388,7 +388,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
{
|
||||
OnRemoteError = ctx =>
|
||||
{
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.UrlEncode(ctx.Error.Message));
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message));
|
||||
ctx.HandleResponse();
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
|
@ -404,16 +404,16 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
var state = stateFormat.Protect(properties);
|
||||
|
||||
await Assert.ThrowsAsync<HttpRequestException>(() => server.SendAsync(
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.UrlEncode(state),
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state),
|
||||
correlationKey + "=" + correlationValue));
|
||||
|
||||
//var transaction = await server.SendAsync(
|
||||
// "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.UrlEncode(state),
|
||||
// "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state),
|
||||
// correlationKey + "=" + correlationValue);
|
||||
//if (redirect)
|
||||
//{
|
||||
// Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
// Assert.Equal("/error?ErrorMessage=" + UrlEncoder.Default.UrlEncode("Access token was not found."),
|
||||
// Assert.Equal("/error?ErrorMessage=" + UrlEncoder.Default.Encode("Access token was not found."),
|
||||
// transaction.Response.Headers.GetValues("Location").First());
|
||||
//}
|
||||
//else
|
||||
|
|
@ -446,7 +446,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
{
|
||||
OnRemoteError = ctx =>
|
||||
{
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.UrlEncode(ctx.Error.Message));
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message));
|
||||
ctx.HandleResponse();
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
|
@ -460,12 +460,12 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
properties.RedirectUri = "/me";
|
||||
var state = stateFormat.Protect(properties);
|
||||
var transaction = await server.SendAsync(
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.UrlEncode(state),
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state),
|
||||
correlationKey + "=" + correlationValue);
|
||||
if (redirect)
|
||||
{
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
Assert.Equal("/error?ErrorMessage=" + UrlEncoder.Default.UrlEncode("Access token was not found."),
|
||||
Assert.Equal("/error?ErrorMessage=" + UrlEncoder.Default.Encode("Access token was not found."),
|
||||
transaction.Response.Headers.GetValues("Location").First());
|
||||
}
|
||||
else
|
||||
|
|
@ -540,7 +540,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
properties.RedirectUri = "/me";
|
||||
var state = stateFormat.Protect(properties);
|
||||
var transaction = await server.SendAsync(
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.UrlEncode(state),
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state),
|
||||
correlationKey + "=" + correlationValue);
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First());
|
||||
|
|
@ -618,7 +618,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
properties.Items.Add(correlationKey, correlationValue);
|
||||
var state = stateFormat.Protect(properties);
|
||||
var transaction = await server.SendAsync(
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.UrlEncode(state),
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state),
|
||||
correlationKey + "=" + correlationValue);
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
Assert.Equal("/", transaction.Response.Headers.GetValues("Location").First());
|
||||
|
|
@ -704,7 +704,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
|
||||
//Post a message to the Google middleware
|
||||
var transaction = await server.SendAsync(
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.UrlEncode(state),
|
||||
"https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state),
|
||||
correlationKey + "=" + correlationValue);
|
||||
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
|
|
@ -740,7 +740,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
{
|
||||
OnRemoteError = ctx =>
|
||||
{
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.UrlEncode(ctx.Error.Message));
|
||||
ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message));
|
||||
ctx.HandleResponse();
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
|
@ -752,7 +752,7 @@ namespace Microsoft.AspNet.Authentication.Google
|
|||
"https://example.com/signin-google?code=TestCode");
|
||||
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
Assert.Equal("/error?ErrorMessage=" + UrlEncoder.Default.UrlEncode("The oauth state was missing or invalid."),
|
||||
Assert.Equal("/error?ErrorMessage=" + UrlEncoder.Default.Encode("The oauth state was missing or invalid."),
|
||||
transaction.Response.Headers.GetValues("Location").First());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authentication.MicrosoftAccount;
|
||||
using Microsoft.AspNet.Authentication.OAuth;
|
||||
|
|
@ -15,7 +16,6 @@ using Microsoft.AspNet.Http;
|
|||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount
|
|||
properties.RedirectUri = "/me";
|
||||
var state = stateFormat.Protect(properties);
|
||||
var transaction = await server.SendAsync(
|
||||
"https://example.com/signin-microsoft?code=TestCode&state=" + UrlEncoder.Default.UrlEncode(state),
|
||||
"https://example.com/signin-microsoft?code=TestCode&state=" + UrlEncoder.Default.Encode(state),
|
||||
correlationKey + "=" + correlationValue);
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First());
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
|
||||
{
|
||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
|
|||
var sb = new StringBuilder();
|
||||
foreach(var item in data.Items)
|
||||
{
|
||||
sb.Append(encoder.UrlEncode(item.Key) + " " + encoder.UrlEncode(item.Value) + " ");
|
||||
sb.Append(encoder.Encode(item.Key) + " " + encoder.Encode(item.Value) + " ");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -144,32 +144,32 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
|
|||
|
||||
public string ExpectedClientId
|
||||
{
|
||||
get { return OpenIdConnectParameterNames.ClientId + "=" + Encoder.UrlEncode(ClientId); }
|
||||
get { return OpenIdConnectParameterNames.ClientId + "=" + Encoder.Encode(ClientId); }
|
||||
}
|
||||
|
||||
public string ExpectedRedirectUri
|
||||
{
|
||||
get { return OpenIdConnectParameterNames.RedirectUri + "=" + Encoder.UrlEncode(RedirectUri); }
|
||||
get { return OpenIdConnectParameterNames.RedirectUri + "=" + Encoder.Encode(RedirectUri); }
|
||||
}
|
||||
|
||||
public string ExpectedResource
|
||||
{
|
||||
get { return OpenIdConnectParameterNames.Resource + "=" + Encoder.UrlEncode(Resource); }
|
||||
get { return OpenIdConnectParameterNames.Resource + "=" + Encoder.Encode(Resource); }
|
||||
}
|
||||
|
||||
public string ExpectedResponseMode
|
||||
{
|
||||
get { return OpenIdConnectParameterNames.ResponseMode + "=" + Encoder.UrlEncode(ResponseMode); }
|
||||
get { return OpenIdConnectParameterNames.ResponseMode + "=" + Encoder.Encode(ResponseMode); }
|
||||
}
|
||||
|
||||
public string ExpectedScope
|
||||
{
|
||||
get { return OpenIdConnectParameterNames.Scope + "=" + Encoder.UrlEncode(Scope); }
|
||||
get { return OpenIdConnectParameterNames.Scope + "=" + Encoder.Encode(Scope); }
|
||||
}
|
||||
|
||||
public string ExpectedState
|
||||
{
|
||||
get { return Encoder.UrlEncode(State); }
|
||||
get { return Encoder.Encode(State); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ using System.IdentityModel.Tokens.Jwt;
|
|||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Security.Claims;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authentication.OpenIdConnect;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
|
|||
// expected user state is added to the message.Parameters.Items[ExpectedStateParameter]
|
||||
// Userstate == null
|
||||
var message = new OpenIdConnectMessage();
|
||||
message.State = UrlEncoder.Default.UrlEncode(formater.Protect(properties));
|
||||
message.State = UrlEncoder.Default.Encode(formater.Protect(properties));
|
||||
message.Code = Guid.NewGuid().ToString();
|
||||
message.Parameters.Add(ExpectedStateParameter, null);
|
||||
dataset.Add(SetStateOptions, message);
|
||||
|
|
@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
|
|||
var userstate = Guid.NewGuid().ToString();
|
||||
message.Code = Guid.NewGuid().ToString();
|
||||
properties.Items.Add(OpenIdConnectDefaults.UserstatePropertiesKey, userstate);
|
||||
message.State = UrlEncoder.Default.UrlEncode(formater.Protect(properties));
|
||||
message.State = UrlEncoder.Default.Encode(formater.Protect(properties));
|
||||
message.Parameters.Add(ExpectedStateParameter, userstate);
|
||||
dataset.Add(SetStateOptions, message);
|
||||
return dataset;
|
||||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
|
|||
};
|
||||
}
|
||||
|
||||
private static TestServer CreateServer(Action<OpenIdConnectOptions> configureOptions, IUrlEncoder encoder, OpenIdConnectHandler handler = null)
|
||||
private static TestServer CreateServer(Action<OpenIdConnectOptions> configureOptions, UrlEncoder encoder, OpenIdConnectHandler handler = null)
|
||||
{
|
||||
return TestServer.Create(
|
||||
app =>
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Authentication.OpenIdConnect;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
|
||||
{
|
||||
|
|
@ -24,11 +24,11 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IUrlEncoder encoder,
|
||||
UrlEncoder encoder,
|
||||
IServiceProvider services,
|
||||
IOptions<SharedAuthenticationOptions> sharedOptions,
|
||||
OpenIdConnectOptions options,
|
||||
IHtmlEncoder htmlEncoder,
|
||||
HtmlEncoder htmlEncoder,
|
||||
OpenIdConnectHandler handler = null
|
||||
)
|
||||
: base(next, dataProtectionProvider, loggerFactory, encoder, services, sharedOptions, options, htmlEncoder)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Security.Claims;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.AspNet.Authentication.Cookies;
|
||||
|
|
@ -17,7 +18,6 @@ using Microsoft.AspNet.Http;
|
|||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -358,7 +358,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
|
|||
|
||||
var transaction = await SendAsync(server, DefaultHost + Signout);
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
Assert.Contains(UrlEncoder.Default.UrlEncode("https://example.com/logout"), transaction.Response.Headers.Location.AbsoluteUri);
|
||||
Assert.Contains(UrlEncoder.Default.Encode("https://example.com/logout"), transaction.Response.Headers.Location.AbsoluteUri);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -375,7 +375,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
|
|||
|
||||
var transaction = await SendAsync(server, "https://example.com/signout_with_specific_redirect_uri");
|
||||
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
|
||||
Assert.Contains(UrlEncoder.Default.UrlEncode("http://www.example.com/specific_redirect_uri"), transaction.Response.Headers.Location.AbsoluteUri);
|
||||
Assert.Contains(UrlEncoder.Default.Encode("http://www.example.com/specific_redirect_uri"), transaction.Response.Headers.Location.AbsoluteUri);
|
||||
}
|
||||
|
||||
private static TestServer CreateServer(Action<OpenIdConnectOptions> configureOptions, Func<HttpContext, Task> handler = null, AuthenticationProperties properties = null)
|
||||
|
|
|
|||
Loading…
Reference in New Issue