.NET
Getting started
The latest version of the package can be found at https://www.nuget.org/packages/Tcell.Agent.Hooks/
Run this command in the Package Manager Console to install the hooks package:
install-package Tcell.Agent.Hooks
Classes/Structures
All hook classes have a concrete class and an interface. This will make it possible to use a dependency injection framework and rely on the interface rather than the implementation.
Using the Hooks
The agent login hooks can be used in an ASP.NET MVC Controller. Follow these steps to implement:
Instantiate the LoginHooks class and store the login hooks as a member variable.
Invoke the hooks' LoginSuccess or LoginFailed in the controller method(s) that performs authentication.
LoginSuccess
There are two variants of LoginSuccess method -- one with a password, one without. As this information is fed into the Account Takeover feature, if a password is available, we recommend using that method to provide additional data to the Account Takeover algorithm.
LoginSuccess API Definition
1public void LoginSuccess(string userName);2public void LoginSuccess(string userName, string password);
Parameters:
- userName: the username of user successfully logged in
- password: the password of user successfully logged in with
LoginFailed
LoginFailed has 4 variations which all require userName. Some have optional password or userValid arguments, signifying the password of a failed login and whether the username passed is valid, respectively. All of this information is fed into the Account Takeover feature, so we recommend using the method with the most information, if available.
LoginFailed API Definition
1public void LoginFailed(string userName);2public void LoginFailed(string userName, string password);3public void LoginFailed(string userName, bool userValid);4public void LoginFailed(string userName, string password, bool userValid);
Parameters:
- userName: the username of user failed to login
- password: the password of user failed to login; see Password Hash section for additional usage details
- userValid: Whether the username of failed login is a valid username
How to use it
1using Tcell.Agent.Hooks;23public class LoginController : Controller4{5private readonly ILoginHooks _loginHooks = new LoginHooks();67public ActionResult Login(User user)8{9// your login logic10var success = [check if users is authenticated];11var validUser = [is it a valid user]12if(success)13{14_loginHooks.LoginSuccess(user.Name, validUser);15}16else17{18_loginHooks.LoginFailed(user.Name, validUser);19}20}21}