#69 Make auth APIs use IEnumerable instead of IList.
This commit is contained in:
parent
bc2cf1223e
commit
10d8b1015e
|
|
@ -57,14 +57,14 @@ namespace Microsoft.AspNet.Http
|
||||||
return Authenticate(new[] { authenticationType }).SingleOrDefault();
|
return Authenticate(new[] { authenticationType }).SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract IEnumerable<AuthenticationResult> Authenticate(IList<string> authenticationTypes);
|
public abstract IEnumerable<AuthenticationResult> Authenticate(IEnumerable<string> authenticationTypes);
|
||||||
|
|
||||||
public virtual async Task<AuthenticationResult> AuthenticateAsync(string authenticationType)
|
public virtual async Task<AuthenticationResult> AuthenticateAsync(string authenticationType)
|
||||||
{
|
{
|
||||||
return (await AuthenticateAsync(new[] { authenticationType })).SingleOrDefault();
|
return (await AuthenticateAsync(new[] { authenticationType })).SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Task<IEnumerable<AuthenticationResult>> AuthenticateAsync(IList<string> authenticationTypes);
|
public abstract Task<IEnumerable<AuthenticationResult>> AuthenticateAsync(IEnumerable<string> authenticationTypes);
|
||||||
|
|
||||||
public virtual Task<WebSocket> AcceptWebSocketAsync()
|
public virtual Task<WebSocket> AcceptWebSocketAsync()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -55,12 +55,12 @@ namespace Microsoft.AspNet.Http
|
||||||
Challenge(new[] { authenticationType }, properties);
|
Challenge(new[] { authenticationType }, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Challenge(IList<string> authenticationTypes)
|
public virtual void Challenge(IEnumerable<string> authenticationTypes)
|
||||||
{
|
{
|
||||||
Challenge(authenticationTypes, properties: null);
|
Challenge(authenticationTypes, properties: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Challenge(IList<string> authenticationTypes, AuthenticationProperties properties);
|
public abstract void Challenge(IEnumerable<string> authenticationTypes, AuthenticationProperties properties);
|
||||||
|
|
||||||
public virtual void SignIn(ClaimsIdentity identity)
|
public virtual void SignIn(ClaimsIdentity identity)
|
||||||
{
|
{
|
||||||
|
|
@ -72,12 +72,12 @@ namespace Microsoft.AspNet.Http
|
||||||
SignIn(new[] { identity }, properties);
|
SignIn(new[] { identity }, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SignIn(IList<ClaimsIdentity> identities)
|
public virtual void SignIn(IEnumerable<ClaimsIdentity> identities)
|
||||||
{
|
{
|
||||||
SignIn(identities, properties: null);
|
SignIn(identities, properties: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void SignIn(IList<ClaimsIdentity> identities, AuthenticationProperties properties);
|
public abstract void SignIn(IEnumerable<ClaimsIdentity> identities, AuthenticationProperties properties);
|
||||||
|
|
||||||
public virtual void SignOut()
|
public virtual void SignOut()
|
||||||
{
|
{
|
||||||
|
|
@ -89,6 +89,6 @@ namespace Microsoft.AspNet.Http
|
||||||
SignOut(new[] { authenticationType });
|
SignOut(new[] { authenticationType });
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void SignOut(IList<string> authenticationTypes);
|
public abstract void SignOut(IEnumerable<string> authenticationTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNet.HttpFeature.Security
|
||||||
[AssemblyNeutral]
|
[AssemblyNeutral]
|
||||||
public interface IAuthenticateContext
|
public interface IAuthenticateContext
|
||||||
{
|
{
|
||||||
IList<string> AuthenticationTypes { get; }
|
IEnumerable<string> AuthenticationTypes { get; }
|
||||||
|
|
||||||
void Authenticated(ClaimsIdentity identity, IDictionary<string, string> properties, IDictionary<string, object> description);
|
void Authenticated(ClaimsIdentity identity, IDictionary<string, string> properties, IDictionary<string, object> description);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNet.HttpFeature.Security
|
||||||
[AssemblyNeutral]
|
[AssemblyNeutral]
|
||||||
public interface IChallengeContext
|
public interface IChallengeContext
|
||||||
{
|
{
|
||||||
IList<string> AuthenticationTypes {get;}
|
IEnumerable<string> AuthenticationTypes {get;}
|
||||||
IDictionary<string,string> Properties {get;}
|
IDictionary<string,string> Properties {get;}
|
||||||
|
|
||||||
void Accept(string authenticationType, IDictionary<string,object> description);
|
void Accept(string authenticationType, IDictionary<string,object> description);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNet.HttpFeature.Security
|
||||||
[AssemblyNeutral]
|
[AssemblyNeutral]
|
||||||
public interface ISignInContext
|
public interface ISignInContext
|
||||||
{
|
{
|
||||||
IList<ClaimsIdentity> Identities { get; }
|
IEnumerable<ClaimsIdentity> Identities { get; }
|
||||||
IDictionary<string, string> Properties { get; }
|
IDictionary<string, string> Properties { get; }
|
||||||
|
|
||||||
void Accept(string authenticationType, IDictionary<string, object> description);
|
void Accept(string authenticationType, IDictionary<string, object> description);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNet.HttpFeature.Security
|
||||||
[AssemblyNeutral]
|
[AssemblyNeutral]
|
||||||
public interface ISignOutContext
|
public interface ISignOutContext
|
||||||
{
|
{
|
||||||
IList<string> AuthenticationTypes { get; }
|
IEnumerable<string> AuthenticationTypes { get; }
|
||||||
|
|
||||||
void Accept(string authenticationType, IDictionary<string, object> description);
|
void Accept(string authenticationType, IDictionary<string, object> description);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ namespace Microsoft.AspNet.PipelineCore
|
||||||
return authTypeContext.Results;
|
return authTypeContext.Results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<AuthenticationResult> Authenticate(IList<string> authenticationTypes)
|
public override IEnumerable<AuthenticationResult> Authenticate(IEnumerable<string> authenticationTypes)
|
||||||
{
|
{
|
||||||
if (authenticationTypes == null)
|
if (authenticationTypes == null)
|
||||||
{
|
{
|
||||||
|
|
@ -202,7 +202,7 @@ namespace Microsoft.AspNet.PipelineCore
|
||||||
return authenticateContext.Results;
|
return authenticateContext.Results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<IEnumerable<AuthenticationResult>> AuthenticateAsync(IList<string> authenticationTypes)
|
public override async Task<IEnumerable<AuthenticationResult>> AuthenticateAsync(IEnumerable<string> authenticationTypes)
|
||||||
{
|
{
|
||||||
if (authenticationTypes == null)
|
if (authenticationTypes == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ namespace Microsoft.AspNet.PipelineCore
|
||||||
return Body.WriteAsync(bytes, 0, bytes.Length);
|
return Body.WriteAsync(bytes, 0, bytes.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Challenge(IList<string> authenticationTypes, AuthenticationProperties properties)
|
public override void Challenge(IEnumerable<string> authenticationTypes, AuthenticationProperties properties)
|
||||||
{
|
{
|
||||||
if (authenticationTypes == null)
|
if (authenticationTypes == null)
|
||||||
{
|
{
|
||||||
|
|
@ -153,7 +153,7 @@ namespace Microsoft.AspNet.PipelineCore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SignIn(IList<ClaimsIdentity> identities, AuthenticationProperties properties)
|
public override void SignIn(IEnumerable<ClaimsIdentity> identities, AuthenticationProperties properties)
|
||||||
{
|
{
|
||||||
if (identities == null)
|
if (identities == null)
|
||||||
{
|
{
|
||||||
|
|
@ -175,7 +175,7 @@ namespace Microsoft.AspNet.PipelineCore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SignOut(IList<string> authenticationTypes)
|
public override void SignOut(IEnumerable<string> authenticationTypes)
|
||||||
{
|
{
|
||||||
if (authenticationTypes == null)
|
if (authenticationTypes == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,21 @@ namespace Microsoft.AspNet.PipelineCore.Security
|
||||||
{
|
{
|
||||||
public class AuthTypeContext : IAuthTypeContext
|
public class AuthTypeContext : IAuthTypeContext
|
||||||
{
|
{
|
||||||
|
private List<AuthenticationDescription> _results;
|
||||||
|
|
||||||
public AuthTypeContext()
|
public AuthTypeContext()
|
||||||
{
|
{
|
||||||
Results = new List<AuthenticationDescription>();
|
_results = new List<AuthenticationDescription>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<AuthenticationDescription> Results { get; private set; }
|
public IEnumerable<AuthenticationDescription> Results
|
||||||
|
{
|
||||||
|
get { return _results; }
|
||||||
|
}
|
||||||
|
|
||||||
public void Accept(IDictionary<string, object> description)
|
public void Accept(IDictionary<string, object> description)
|
||||||
{
|
{
|
||||||
Results.Add(new AuthenticationDescription(description));
|
_results.Add(new AuthenticationDescription(description));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,33 +14,42 @@ namespace Microsoft.AspNet.PipelineCore.Security
|
||||||
{
|
{
|
||||||
public class AuthenticateContext : IAuthenticateContext
|
public class AuthenticateContext : IAuthenticateContext
|
||||||
{
|
{
|
||||||
public AuthenticateContext(IList<string> authenticationTypes)
|
private List<AuthenticationResult> _results;
|
||||||
|
private List<string> _accepted;
|
||||||
|
|
||||||
|
public AuthenticateContext(IEnumerable<string> authenticationTypes)
|
||||||
{
|
{
|
||||||
if (authenticationTypes == null)
|
if (authenticationTypes == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("authenticationType");
|
throw new ArgumentNullException("authenticationType");
|
||||||
}
|
}
|
||||||
AuthenticationTypes = authenticationTypes;
|
AuthenticationTypes = authenticationTypes;
|
||||||
Results = new List<AuthenticationResult>();
|
_results = new List<AuthenticationResult>();
|
||||||
Accepted = new List<string>();
|
_accepted = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<string> AuthenticationTypes { get; private set; }
|
public IEnumerable<string> AuthenticationTypes { get; private set; }
|
||||||
|
|
||||||
public IList<AuthenticationResult> Results { get; private set; }
|
public IEnumerable<AuthenticationResult> Results
|
||||||
|
{
|
||||||
|
get { return _results; }
|
||||||
|
}
|
||||||
|
|
||||||
public IList<string> Accepted { get; private set; }
|
public IEnumerable<string> Accepted
|
||||||
|
{
|
||||||
|
get { return _accepted; }
|
||||||
|
}
|
||||||
|
|
||||||
public void Authenticated(ClaimsIdentity identity, IDictionary<string, string> properties, IDictionary<string, object> description)
|
public void Authenticated(ClaimsIdentity identity, IDictionary<string, string> properties, IDictionary<string, object> description)
|
||||||
{
|
{
|
||||||
var descrip = new AuthenticationDescription(description);
|
var descrip = new AuthenticationDescription(description);
|
||||||
Accepted.Add(descrip.AuthenticationType); // may not match identity.AuthType
|
_accepted.Add(descrip.AuthenticationType); // may not match identity.AuthType
|
||||||
Results.Add(new AuthenticationResult(identity, new AuthenticationProperties(properties), descrip));
|
_results.Add(new AuthenticationResult(identity, new AuthenticationProperties(properties), descrip));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NotAuthenticated(string authenticationType, IDictionary<string, string> properties, IDictionary<string, object> description)
|
public void NotAuthenticated(string authenticationType, IDictionary<string, string> properties, IDictionary<string, object> description)
|
||||||
{
|
{
|
||||||
Accepted.Add(authenticationType);
|
_accepted.Add(authenticationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,9 @@ namespace Microsoft.AspNet.PipelineCore.Security
|
||||||
{
|
{
|
||||||
public class ChallengeContext : IChallengeContext
|
public class ChallengeContext : IChallengeContext
|
||||||
{
|
{
|
||||||
public ChallengeContext(IList<string> authenticationTypes, IDictionary<string, string> properties)
|
private List<string> _accepted;
|
||||||
|
|
||||||
|
public ChallengeContext(IEnumerable<string> authenticationTypes, IDictionary<string, string> properties)
|
||||||
{
|
{
|
||||||
if (authenticationTypes == null)
|
if (authenticationTypes == null)
|
||||||
{
|
{
|
||||||
|
|
@ -20,18 +22,21 @@ namespace Microsoft.AspNet.PipelineCore.Security
|
||||||
}
|
}
|
||||||
AuthenticationTypes = authenticationTypes;
|
AuthenticationTypes = authenticationTypes;
|
||||||
Properties = properties ?? new Dictionary<string, string>(StringComparer.Ordinal);
|
Properties = properties ?? new Dictionary<string, string>(StringComparer.Ordinal);
|
||||||
Accepted = new List<string>();
|
_accepted = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<string> AuthenticationTypes { get; private set; }
|
public IEnumerable<string> AuthenticationTypes { get; private set; }
|
||||||
|
|
||||||
public IDictionary<string, string> Properties { get; private set; }
|
public IDictionary<string, string> Properties { get; private set; }
|
||||||
|
|
||||||
public IList<string> Accepted { get; private set; }
|
public IEnumerable<string> Accepted
|
||||||
|
{
|
||||||
|
get { return _accepted; }
|
||||||
|
}
|
||||||
|
|
||||||
public void Accept(string authenticationType, IDictionary<string, object> description)
|
public void Accept(string authenticationType, IDictionary<string, object> description)
|
||||||
{
|
{
|
||||||
Accepted.Add(authenticationType);
|
_accepted.Add(authenticationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@ namespace Microsoft.AspNet.PipelineCore.Security
|
||||||
{
|
{
|
||||||
public class SignInContext : ISignInContext
|
public class SignInContext : ISignInContext
|
||||||
{
|
{
|
||||||
public SignInContext(IList<ClaimsIdentity> identities, IDictionary<string, string> dictionary)
|
private List<string> _accepted;
|
||||||
|
|
||||||
|
public SignInContext(IEnumerable<ClaimsIdentity> identities, IDictionary<string, string> dictionary)
|
||||||
{
|
{
|
||||||
if (identities == null)
|
if (identities == null)
|
||||||
{
|
{
|
||||||
|
|
@ -18,18 +20,21 @@ namespace Microsoft.AspNet.PipelineCore.Security
|
||||||
}
|
}
|
||||||
Identities = identities;
|
Identities = identities;
|
||||||
Properties = dictionary ?? new Dictionary<string, string>(StringComparer.Ordinal);
|
Properties = dictionary ?? new Dictionary<string, string>(StringComparer.Ordinal);
|
||||||
Accepted = new List<string>();
|
_accepted = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<ClaimsIdentity> Identities { get; private set; }
|
public IEnumerable<ClaimsIdentity> Identities { get; private set; }
|
||||||
|
|
||||||
public IDictionary<string, string> Properties { get; private set; }
|
public IDictionary<string, string> Properties { get; private set; }
|
||||||
|
|
||||||
public IList<string> Accepted { get; private set; }
|
public IEnumerable<string> Accepted
|
||||||
|
{
|
||||||
|
get { return _accepted; }
|
||||||
|
}
|
||||||
|
|
||||||
public void Accept(string authenticationType, IDictionary<string, object> description)
|
public void Accept(string authenticationType, IDictionary<string, object> description)
|
||||||
{
|
{
|
||||||
Accepted.Add(authenticationType);
|
_accepted.Add(authenticationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,23 +9,28 @@ namespace Microsoft.AspNet.PipelineCore.Security
|
||||||
{
|
{
|
||||||
public class SignOutContext : ISignOutContext
|
public class SignOutContext : ISignOutContext
|
||||||
{
|
{
|
||||||
public SignOutContext(IList<string> authenticationTypes)
|
private List<string> _accepted;
|
||||||
|
|
||||||
|
public SignOutContext(IEnumerable<string> authenticationTypes)
|
||||||
{
|
{
|
||||||
if (authenticationTypes == null)
|
if (authenticationTypes == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("authenticationTypes");
|
throw new ArgumentNullException("authenticationTypes");
|
||||||
}
|
}
|
||||||
AuthenticationTypes = authenticationTypes;
|
AuthenticationTypes = authenticationTypes;
|
||||||
Accepted = new List<string>();
|
_accepted = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<string> AuthenticationTypes { get; private set; }
|
public IEnumerable<string> AuthenticationTypes { get; private set; }
|
||||||
|
|
||||||
public IList<string> Accepted { get; private set; }
|
public IEnumerable<string> Accepted
|
||||||
|
{
|
||||||
|
get { return _accepted; }
|
||||||
|
}
|
||||||
|
|
||||||
public void Accept(string authenticationType, IDictionary<string, object> description)
|
public void Accept(string authenticationType, IDictionary<string, object> description)
|
||||||
{
|
{
|
||||||
Accepted.Add(authenticationType);
|
_accepted.Add(authenticationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue