PHP SDK for user monitoring¶ Sqreen protects your application users against major threats, such as account takeover, password bruteforce, suspicious activities coming from TOR or unusual VPN. Advanced User Context allows you to set up user monitoring in your application with flexibility and powerful additional features. You will need to integrate Sqreen SDK in your application (< 10 minutes). User monitoring SDK¶ The Sqreen SDK integration is very simple. It relies on 3 methods: authTrack, signupTrack and identify. Here's a full implementation example: <?php // in the signup method, when the user account is created for the first time: $user = signup($email, $password); sqreen\signup_track(['email' => $email]) // ... // in the signin method, when a user creates a new session: $user = login($email, $password); sqreen\auth_track($user !== NULL, ['email' => $email]) // ... // On every request to map the authenticated user to the request $user = login($email, $password); sqreen\identify(['email' => $email]) ?> Login tracking¶ sqreen\auth_track is the SDK method to call on user login activity. <?php sqreen\auth_track(is_login_successful, ['email' => $email]) ?> The auth_track function accepts two positional arguments: <?php sqreen\auth_track(success, user_identifiers) ?> The first argument is a boolean indicating if the login/signup attempt was successful or not (True or False). The second argument is an array with your user identification information. They will be used on Sqreen's user interface to help you identify which users are at risk, or which are attacking your application. The hash keys and values should only be strings. Sqreen integration at signup and login You should not call sqreen\auth_track each time you check a user session in your application. Signup tracking¶ sqreen\signup_track is the SDK method to call when creating a new user account, basically at signup. <?php sqreen\signup_track(['email' => $email]) ?> The signup_track function accepts a single argument: <?php sqreen\signup_track(user_identifiers) ?> user_identifiers an array with your user identification information. They will be used on Sqreen's user interface to help you identify which users are at risk, or which are attacking your application. The hash keys and values should only be strings. Session tracking¶ sqreen\identify is the SDK method to map a user to the current HTTP request. Block users with security automation Implementing identify method is required to block users thanks to Security Automation When the request is not identified using this method, Sqreen fallbacks to login tracking information to map a user. It's a best effort approach based on the recent activity of users on the requests IPs. <?php sqreen\identify(['email' => $email], ['nickname' => 'foobar']) ?> The identify function accepts two positional arguments: <?php sqreen\identify(user_identifiers, traits) ?> The first argument is an associative array representing the identification information. It will be used on Sqreen's user interface to help you identify which users are attacking your application. The hash keys and values should only be strings. The second argument is an optional associative array of traits about the user. The hash keys and values should only be strings. User traits At the moment, we do not display nor process the traits. In the near future, we'll display them to faciliate attack investigation and allow you to build custom workflows. Interested in this feature? Contact us. Block users (Security Automation)¶ When using Security Automation built-in block user security response, you should implement identify and auth_track methods to block users at login or during their session. Otherwise, Sqreen won't be able to map a user context to requests performed on your application. Learn more about login and session tracking. User identification¶ If your users can be identified with a single value (email, nickname...), you can send proceed that way: <?php sqreen\auth_track(true, ['email' => $email]) ?> User monitoring and PII If you're concerned about sending sensitive data to us and not leaking any Personally Identifying Information (PII), visit this blogpost to learn some best practices around user tracking (Ruby but easy to translate in PHP). If your users are identified with a composite primary key (multiple values), all of them should be sent in order to identify them accurately on Sqreen's user interface. For example, if you are are operating a whitelabel platform and your users are identified by their email and the shop id, you can send these identifiers like this: <?php sqreen\auth_track(true, ['email' => $email, 'platform_id' => $platform_id]) ?> This also apply to the signup_track and identify functions. Please note that the 3 calls rely on the same identity format in order for Sqreen to map the activities to a single user. Sqreen SDK only accepts user identifiers Don't send any other information (like the auth failure reason). Sqreen will consider them as part of the user identifier, and will not be able to merge successful and failed authentications. Primary key¶ Sqreen will try to determine a primary key amongst the keys you provided. The following keywords will be used to determine the user primary identification key: email, mail, e-mail, username, login. If none of those key are found, we will use the first in alphabetic order. If multiple keys are found, we'll use the first in the sequence mentioned above.