Class HeaderAuthProvider<TModel, TUser>
Auth provider that uses header value authentication to authorize the user
Implements
IAuthProvider<TModel, TUser>
Namespace: Seltzr.Auth
Assembly: Seltzr.dll
Syntax
C#
public class HeaderAuthProvider<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 HeaderAuthProvider<TModel, TUser> class.
C#
public HeaderAuthProvider(string headerName, Func<string, Task<TUser>> authDelegate)
Parameters
headerName
String
The name of the header containing the API key
Methods
Authenticates the given request context, and returns the authenticated user
C#
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
C#
public virtual Task<bool> CanAuthAsync(IApiContext<TModel, TUser> context)
Parameters
context
IApiContext<TModel, TUser>
The current API context
Returns
true if this request contains the header value this HeaderAuthProvider<TModel, TUser> authenticates with