Ruby
Getting started
You can add it to your Gemfile:
gem 'tcell_hooks'
Then run:
bundle install
Call it from your application code:
1class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController2def facebook3oauth_data = request.env["omniauth.auth"]4@user = User.find_or_create_for_facebook_oauth(oauth_data)5@user.save67TCellAgent::Hooks::V1::Frameworks::Rails::Login.register_login_event(8TCellAgent::Hooks::V1::Login::LOGIN_SUCCESS, request, @user.email, nil9)1011# OR12# 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# )2223sign_in_and_redirect @user24end25end
API
1module TCellAgent::Hooks::V1::Frameworks::Rails::Login2def register_login_event(status, rails_request, user_id, user_valid=nil); end3end
- 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.
1module TCellAgent::Hooks::V1::Frameworks::Rails::Login2def self.register_login_event(3status,4session_id,5user_agent,6referrer,7remote_addr,8header_keys,9user_id,10document_uri,11user_valid=nil)12end13end
- 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.
Did this page help you?