Ruby

Getting started

You can add it to your Gemfile:

gem 'tcell_hooks'

Then run: bundle install

Call it from your application code:

1
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
2
def facebook
3
oauth_data = request.env["omniauth.auth"]
4
@user = User.find_or_create_for_facebook_oauth(oauth_data)
5
@user.save
6
7
TCellAgent::Hooks::V1::Frameworks::Rails::Login.register_login_event(
8
TCellAgent::Hooks::V1::Login::LOGIN_SUCCESS, request, @user.email, nil
9
)
10
11
# OR
12
# TCellAgent::Hooks::V1::Login.register_login_event(
13
# TCellAgent::Hooks::V1::Login::LOGIN_SUCCESS,
14
# "session_id",
15
# request.env["HTTP_USER_AGENT"],
16
# request.referrer,
17
# "192.168.99.1",
18
# ["HOST", "USER_AGENT", "ACCEPT", "REFERER", "ACCEPT_ENCODING", "ACCEPT_LANGUAGE", "COOKIE"],
19
# @user.email,
20
# request.env['PATH_INFO']
21
# )
22
23
sign_in_and_redirect @user
24
end
25
end

API

1
module TCellAgent::Hooks::V1::Frameworks::Rails::Login
2
def register_login_event(status, rails_request, user_id, user_valid=nil); end
3
end
  • status (string) : TCellAgentHooksV1LoginLOGIN_SUCCESS or TCellAgentHooksV1LoginLOGIN_FAILURE
  • rails_request (object) : Request object provided by rails
  • user_id (string) : (Optional) Identification used for the user (i.e. email, username)
  • user_valid (boolean) : (Optional) Set as true if exists, other false. Defaults to nil.
1
module TCellAgent::Hooks::V1::Frameworks::Rails::Login
2
def self.register_login_event(
3
status,
4
session_id,
5
user_agent,
6
referrer,
7
remote_addr,
8
header_keys,
9
user_id,
10
document_uri,
11
user_valid=nil)
12
end
13
end
  • status (string) : TCellAgentHooksV1LoginLOGIN_SUCCESS or TCellAgentHooksV1LoginLOGIN_FAILURE
  • session (string) : Session ID for user logging in. This will be hmaced by the Agent before being sent
  • user_agent (string) : (Optional) User agent taken from header
  • referrer (string) : (Optional) Referrer taken from header
  • remote_addr (string) : (Optional) IP of the Request
  • header_keys (string) : Optional) An array of the header keys. The order is important (do not sort the array)
  • user_id (string) : (Optional) Identification used for the user (i.e. email, username)
  • document_uri (string) : (Optional) Document URI taken from request
  • user_valid (boolean) : (Optional) Set as true if exists, other false. Defaults to nil.

Important

If the tcell_agent is not installed or if it's disabled, this code will do nothing and should have no performance effect on your app.

Password Hash

When you send a secured hashed password to the tCell cloud, you create a more robust Account Takeover response. See Password Hash for more information.