remove ref to OWin & changes to AspNet.OAuth.Server
This commit is contained in:
parent
19b41ed9f4
commit
c2f4a71137
26 changed files with 7097 additions and 1451 deletions
|
|
@ -1,14 +0,0 @@
|
|||
|
||||
public interface IApplication
|
||||
{
|
||||
string ApplicationID { get; set; }
|
||||
string DisplayName { get; set; }
|
||||
string RedirectUri { get; set; }
|
||||
string LogoutRedirectUri { get; set; }
|
||||
string Secret { get; set; }
|
||||
}
|
||||
public interface IApplicationStore
|
||||
{
|
||||
IApplication FindApplication(string clientId);
|
||||
|
||||
}
|
||||
|
|
@ -17,12 +17,6 @@ namespace OAuth.AspNet.AuthServer
|
|||
|
||||
public class OAuthAuthorizationServerHandler : AuthenticationHandler<OAuthAuthorizationServerOptions>
|
||||
{
|
||||
public OAuthAuthorizationServerHandler(IApplicationStore applicationStore)
|
||||
{
|
||||
ApplicationStore = applicationStore;
|
||||
}
|
||||
|
||||
public IApplicationStore ApplicationStore { get; private set;}
|
||||
#region non-Public Members
|
||||
|
||||
private AuthorizeEndpointRequest _authorizeEndpointRequest;
|
||||
|
|
@ -335,7 +329,7 @@ namespace OAuth.AspNet.AuthServer
|
|||
{
|
||||
var authorizeRequest = new AuthorizeEndpointRequest(Request.Query);
|
||||
|
||||
var clientContext = new OAuthValidateClientRedirectUriContext(ApplicationStore,Context, Options, authorizeRequest.ClientId, authorizeRequest.RedirectUri);
|
||||
var clientContext = new OAuthValidateClientRedirectUriContext(Context, Options, authorizeRequest.ClientId, authorizeRequest.RedirectUri);
|
||||
|
||||
if (!string.IsNullOrEmpty(authorizeRequest.RedirectUri))
|
||||
{
|
||||
|
|
@ -423,7 +417,7 @@ namespace OAuth.AspNet.AuthServer
|
|||
|
||||
IFormCollection form = await Request.ReadFormAsync();
|
||||
|
||||
var clientContext = new OAuthValidateClientAuthenticationContext(Context, Options, form, ApplicationStore);
|
||||
var clientContext = new OAuthValidateClientAuthenticationContext(Context, Options, form);
|
||||
|
||||
await Options.Provider.ValidateClientAuthentication(clientContext);
|
||||
|
||||
|
|
@ -808,7 +802,7 @@ namespace OAuth.AspNet.AuthServer
|
|||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
|
||||
using Microsoft.AspNet.Authentication;
|
||||
using Microsoft.AspNet.Authentication;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Yavsc.Auth;
|
||||
|
||||
namespace OAuth.AspNet.AuthServer
|
||||
{
|
||||
|
|
@ -21,21 +22,8 @@ namespace OAuth.AspNet.AuthServer
|
|||
/// called by application code directly, instead it is added by calling the the IAppBuilder UseOAuthAuthorizationServer
|
||||
/// extension method.
|
||||
/// </summary>
|
||||
public OAuthAuthorizationServerMiddleware(
|
||||
RequestDelegate next,
|
||||
OAuthAuthorizationServerOptions options,
|
||||
ILoggerFactory loggerFactory,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
IUrlEncoder encoder,
|
||||
IApplicationStore applicationStore
|
||||
) : base(next, options, loggerFactory, encoder)
|
||||
public OAuthAuthorizationServerMiddleware(RequestDelegate next, OAuthAuthorizationServerOptions options, ILoggerFactory loggerFactory, IDataProtectionProvider dataProtectionProvider, IUrlEncoder encoder) : base(next, options, loggerFactory, encoder)
|
||||
{
|
||||
if (applicationStore == null )
|
||||
{
|
||||
throw new InvalidOperationException("No application store");
|
||||
}
|
||||
ApplicationStore = applicationStore;
|
||||
|
||||
if (Options.Provider == null)
|
||||
{
|
||||
Options.Provider = new OAuthAuthorizationServerProvider();
|
||||
|
|
@ -57,8 +45,11 @@ namespace OAuth.AspNet.AuthServer
|
|||
|
||||
if (Options.TokenDataProtector == null)
|
||||
{
|
||||
Options.TokenDataProtector = dataProtectionProvider.CreateProtector("OAuth.AspNet.AuthServer");
|
||||
|
||||
#if DNXCORE50
|
||||
Options.TokenDataProtector = new DataProtectionProvider(new DirectoryInfo(Environment.GetEnvironmentVariable("Temp"))).CreateProtector("OAuth.AspNet.AuthServer");
|
||||
#else
|
||||
Options.TokenDataProtector = new MonoDataProtectionProvider("OAuth.AspNet.AuthServer").CreateProtector("OAuth.Data.Protector");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Options.AccessTokenFormat == null)
|
||||
|
|
@ -82,17 +73,15 @@ namespace OAuth.AspNet.AuthServer
|
|||
{
|
||||
Options.RefreshTokenProvider = new AuthenticationTokenProvider();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private IApplicationStore ApplicationStore { get; set; }
|
||||
/// <summary>
|
||||
/// Called by the AuthenticationMiddleware base class to create a per-request handler.
|
||||
/// </summary>
|
||||
/// <returns>A new instance of the request handler</returns>
|
||||
protected override AuthenticationHandler<OAuthAuthorizationServerOptions> CreateHandler()
|
||||
{
|
||||
return new OAuthAuthorizationServerHandler(ApplicationStore);
|
||||
return new OAuthAuthorizationServerHandler();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using Microsoft.AspNet.Authentication;
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
namespace OAuth.AspNet.AuthServer
|
||||
|
|
|
|||
|
|
@ -16,14 +16,11 @@ namespace OAuth.AspNet.AuthServer
|
|||
/// <param name="context"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="parameters"></param>
|
||||
public OAuthValidateClientAuthenticationContext(HttpContext context, OAuthAuthorizationServerOptions options, IReadableStringCollection parameters, IApplicationStore applicationStore) : base(context, options, null)
|
||||
public OAuthValidateClientAuthenticationContext(HttpContext context, OAuthAuthorizationServerOptions options, IReadableStringCollection parameters) : base(context, options, null)
|
||||
{
|
||||
Parameters = parameters;
|
||||
ApplicationStore = applicationStore;
|
||||
}
|
||||
|
||||
public IApplicationStore ApplicationStore { get; private set;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the set of form parameters from the request.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
|
||||
|
||||
public class OAuthValidateClientCredentialsContext {
|
||||
public OAuthValidateClientCredentialsContext(string clientId,string clientSecret,IApplicationStore applicationStore)
|
||||
{
|
||||
ClientId = clientId;
|
||||
ClientSecret = clientSecret;
|
||||
ApplicationStore = applicationStore;
|
||||
}
|
||||
public string ClientId { get; private set; }
|
||||
public string ClientSecret { get; private set; }
|
||||
public IApplicationStore ApplicationStore { get; private set; }
|
||||
|
||||
}
|
||||
|
|
@ -17,10 +17,9 @@ namespace OAuth.AspNet.AuthServer
|
|||
/// <param name="clientId"></param>
|
||||
/// <param name="redirectUri"></param>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "3#", Justification = "redirect_uri is a string parameter")]
|
||||
public OAuthValidateClientRedirectUriContext(IApplicationStore applicationStore, HttpContext context, OAuthAuthorizationServerOptions options, string clientId, string redirectUri) : base(context, options, clientId)
|
||||
public OAuthValidateClientRedirectUriContext(HttpContext context, OAuthAuthorizationServerOptions options, string clientId, string redirectUri) : base(context, options, clientId)
|
||||
{
|
||||
RedirectUri = redirectUri;
|
||||
ApplicationStore = applicationStore;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -29,8 +28,6 @@ namespace OAuth.AspNet.AuthServer
|
|||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "redirect_uri is a string parameter")]
|
||||
public string RedirectUri { get; private set; }
|
||||
|
||||
public IApplicationStore ApplicationStore { get; private set;}
|
||||
|
||||
/// <summary>
|
||||
/// Marks this context as validated by the application. IsValidated becomes true and HasError becomes false as a result of calling.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue