.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:

  1. Instantiate the LoginHooks class and store the login hooks as a member variable.

  2. 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
1
public void LoginSuccess(string userName);
2
public 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
1
public void LoginFailed(string userName);
2
public void LoginFailed(string userName, string password);
3
public void LoginFailed(string userName, bool userValid);
4
public 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

1
using Tcell.Agent.Hooks;
2
3
public class LoginController : Controller
4
{
5
private readonly ILoginHooks _loginHooks = new LoginHooks();
6
7
public ActionResult Login(User user)
8
{
9
// your login logic
10
var success = [check if users is authenticated];
11
var validUser = [is it a valid user]
12
if(success)
13
{
14
_loginHooks.LoginSuccess(user.Name, validUser);
15
}
16
else
17
{
18
_loginHooks.LoginFailed(user.Name, validUser);
19
}
20
}
21
}