C# Class Nancy.Authentication.Forms.FormsAuthentication

Nancy forms authentication implementation
Datei anzeigen Open project: 3vr/Nancy

Public Methods

Method Description
Enable ( IPipelines pipelines, Nancy.Authentication.Forms.FormsAuthenticationConfiguration configuration ) : void

Enables forms authentication for the application

LogOutAndRedirectResponse ( NancyContext context, string redirectUrl ) : Response

Logs the user out and redirects them to a URL

LogOutResponse ( ) : Response

Logs the user out.

UserLoggedInRedirectResponse ( NancyContext context, System.Guid userIdentifier, System.DateTime cookieExpiry = null, string fallbackRedirectUrl = "/" ) : Response

Creates a response that sets the authentication cookie and redirects the user back to where they came from.

UserLoggedInResponse ( System.Guid userIdentifier, System.DateTime cookieExpiry = null ) : Response

Logs the user in.

Private Methods

Method Description
BuildCookie ( System.Guid userIdentifier, System.DateTime cookieExpiry, Nancy.Authentication.Forms.FormsAuthenticationConfiguration configuration ) : INancyCookie

Build the forms authentication cookie

BuildLogoutCookie ( Nancy.Authentication.Forms.FormsAuthenticationConfiguration configuration ) : INancyCookie

Builds a cookie for logging a user out

DecryptAndValidateAuthenticationCookie ( string cookieValue, Nancy.Authentication.Forms.FormsAuthenticationConfiguration configuration ) : string

Decrypt and validate an encrypted and signed cookie value

EncryptAndSignCookie ( string cookieValue, Nancy.Authentication.Forms.FormsAuthenticationConfiguration configuration ) : string

Encrypt and sign the cookie contents

GenerateHmac ( string encryptedCookie, Nancy.Authentication.Forms.FormsAuthenticationConfiguration configuration ) : byte[]

Generate a hmac for the encrypted cookie string

GetAuthenticatedUserFromCookie ( NancyContext context, Nancy.Authentication.Forms.FormsAuthenticationConfiguration configuration ) : System.Guid

Gets the authenticated user GUID from the incoming request cookie if it exists and is valid.

GetLoadAuthenticationHook ( Nancy.Authentication.Forms.FormsAuthenticationConfiguration configuration ) : Response>.Func

Gets the pre request hook for loading the authenticated user's details from the cookie.

GetRedirectToLoginHook ( Nancy.Authentication.Forms.FormsAuthenticationConfiguration configuration ) : Action

Gets the post request hook for redirecting to the login page

Method Details

Enable() public static method

Enables forms authentication for the application
public static Enable ( IPipelines pipelines, Nancy.Authentication.Forms.FormsAuthenticationConfiguration configuration ) : void
pipelines IPipelines Pipelines to add handlers to (usually "this")
configuration Nancy.Authentication.Forms.FormsAuthenticationConfiguration Forms authentication configuration
return void

LogOutAndRedirectResponse() public static method

Logs the user out and redirects them to a URL
public static LogOutAndRedirectResponse ( NancyContext context, string redirectUrl ) : Response
context NancyContext Current context
redirectUrl string URL to redirect to
return Response

LogOutResponse() public static method

Logs the user out.
public static LogOutResponse ( ) : Response
return Response

UserLoggedInRedirectResponse() public static method

Creates a response that sets the authentication cookie and redirects the user back to where they came from.
public static UserLoggedInRedirectResponse ( NancyContext context, System.Guid userIdentifier, System.DateTime cookieExpiry = null, string fallbackRedirectUrl = "/" ) : Response
context NancyContext Current context
userIdentifier System.Guid User identifier guid
cookieExpiry System.DateTime Optional expiry date for the cookie (for 'Remember me')
fallbackRedirectUrl string Url to redirect to if none in the querystring
return Response

UserLoggedInResponse() public static method

Logs the user in.
public static UserLoggedInResponse ( System.Guid userIdentifier, System.DateTime cookieExpiry = null ) : Response
userIdentifier System.Guid User identifier guid
cookieExpiry System.DateTime Optional expiry date for the cookie (for 'Remember me')
return Response