Class IdentityAuthProvider<TModel, TUser>
Auth provider that uses ASP.NET Core Identity to authorize the user
Implements
Namespace: Seltzr.Auth
Assembly: Seltzr.dll
Syntax
public class IdentityAuthProvider<TModel, TUser> : IAuthProvider<TModel, TUser> where TModel : class where TUser : class
Type Parameters
TModel
The type of model that this API handles
TUser
The type of the authenticated user context
Constructors
Initializes a new instance of the IdentityAuthProvider<TModel, TUser> class.
public IdentityAuthProvider()
Initializes a new instance of the IdentityAuthProvider<TModel, TUser> class.
public IdentityAuthProvider(IEnumerable<string> roles)
Parameters
roles
IEnumerable<String>
The roles that the must be in to authenticate
Initializes a new instance of the IdentityAuthProvider<TModel, TUser> class.
public IdentityAuthProvider(string policy)
Parameters
policy
String
The policy that the must fulfill to authenticate
Initializes a new instance of the IdentityAuthProvider<TModel, TUser> class.
public IdentityAuthProvider(string policy, IEnumerable<string> roles)
Parameters
policy
String
The policy that the must fulfill to authenticate
roles
IEnumerable<String>
The roles that the must be in to authenticate
Methods
Authenticates the given request context, and returns the authenticated user
public virtual Task<TUser> AuthenticateAsync(IApiContext<TModel, TUser> context)
Parameters
context
IApiContext<TModel, TUser>
The current API context
Returns
Task<TUser>
The currently authenticated user context
Gets whether or not the given request can be authenticated for
public virtual Task<bool> CanAuthAsync(IApiContext<TModel, TUser> context)
Parameters
context
IApiContext<TModel, TUser>
The current API context
Returns
true always