2017 © Pedro Peláez
 

library castle-php

PHP bindings for Castle

image

castle/castle-php

PHP bindings for Castle

  • Wednesday, June 27, 2018
  • by castle
  • Repository
  • 13 Watchers
  • 4 Stars
  • 35,893 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 25 Versions
  • 12 % Grown

The README.md

Latest Stable Version Total Downloads License, (*1)

Code Climate Coverage Status, (*2)

PHP SDK for Castle

Castle analyzes user behavior in web and mobile apps to stop fraud before it happens., (*3)

Usage

See the documentation for how to use this SDK with the Castle APIs, (*4)

Getting started

Obtain the latest version of the Castle PHP bindings with:, (*5)

git clone --single-branch --branch master https://github.com/castle/castle-php

To get started, add the following to your PHP script:, (*6)

require_once("/path/to/castle-php/lib/Castle.php");

Configure the library with your Castle API secret., (*7)

Castle::setApiKey('YOUR_API_SECRET');

Optional Configurations

Set preferred connection and request timeouts: valid options for setting are: - CURLOPT_CONNECTTIMEOUT - CURLOPT_CONNECTTIMEOUT_MS - CURLOPT_TIMEOUT - CURLOPT_TIMEOUT_MS, (*8)

Castle::setCurlOpts($curlOpts)

Set a specified list of request headers to include with event context (optional, not recommended):, (*9)

Castle::setUseAllowlist($headers)

Request context

By default, Castle extracts all the necessary information, such as IP and request headers, from the PHP globals in order to build and send the requests to the Castle API. However in some cases you want to track data to Castle from a context where these globals are not available, eg. when tracking async in a background worker. In this case you can build the request context manually., (*10)

Origin IP Address

By default, the SDK extracts the contextual client IP address from headers in the following priority: 1. X-Forwarded-For 2. X-Real-Ip 3. REMOTE_ADDR, (*11)

If the true client IP address is not specified in the above headers, you can manually set the IP address like so:, (*12)

Castle_RequestContext['ip'] = '1.1.1.1'
$context = Castle_RequestContext::extractJson();

Errors

Whenever something unexpected happens, an exception is thrown to indicate what went wrong., (*13)

Name Description
Castle_Error A generic error
Castle_RequestError A request failed. Probably due to a network error
Castle_ApiError An unexpected error for the Castle API
Castle_ConfigurationError The Castle secret API key has not been set
Castle_UnauthorizedError Wrong Castle API secret key
Castle_BadRequest The request was invalid. For example if a challenge is created without the user having MFA enabled.
Castle_ForbiddenError The user has entered the wrong code too many times and a new challenge has to be requested.
Castle_NotFoundError The resource requestd was not found. For example if a session has been revoked.
Castle_InvalidParametersError One or more of the supplied parameters are incorrect. Check the response for more information.
Castle_InvalidRequestTokenError The request token parameter is missing or invalid

Running test suite

Execute vendor/bin/phpunit test to run the full test suite, (*14)

The Versions

27/06 2018

dev-master

9999999-dev https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

27/06 2018

1.7.0

1.7.0.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

15/02 2018

dev-chore/remove-unused-errors

dev-chore/remove-unused-errors https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

15/01 2018

dev-created_at

dev-created_at https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

25/10 2017

1.6.0

1.6.0.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

18/07 2017

1.5.0

1.5.0.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

18/07 2017

dev-revert-20-revert-19-feat/client-id

dev-revert-20-revert-19-feat/client-id https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

12/07 2017

dev-revert-19-feat/client-id

dev-revert-19-feat/client-id https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

07/07 2017

dev-feat/client-id

dev-feat/client-id https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

22/06 2017

1.4.4

1.4.4.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

15/06 2017

1.4.3

1.4.3.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

15/06 2017

dev-fix/odd-cookie-id

dev-fix/odd-cookie-id https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

14/06 2017

1.4.2

1.4.2.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

13/06 2017

1.4.1

1.4.1.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

13/02 2017

1.4.0

1.4.0.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

13/02 2017

dev-feat/review-api

dev-feat/review-api https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

real-time user account monitoring

08/03 2016

1.3.0

1.3.0.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

real-time user account monitoring

09/01 2016

1.2.3

1.2.3.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

real-time user account monitoring

07/07 2015

dev-namespaces

dev-namespaces https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

real-time user account monitoring

23/06 2015

1.2.2

1.2.2.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

real-time user account monitoring

22/05 2015

1.2.1

1.2.1.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

real-time user account monitoring

29/04 2015

1.2.0

1.2.0.0 https://github.com/castle/castle-php

PHP bindings for Castle

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

real-time user account monitoring

19/11 2014

1.1.0

1.1.0.0 https://github.com/userbin/userbin-php

PHP bindings for Userbin

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

authorization two factor authentication account monitoring

01/07 2014

1.0.1

1.0.1.0 https://github.com/userbin/userbin-php

PHP bindings for Userbin

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

authorization two factor authentication account monitoring

27/06 2014

1.0.0

1.0.0.0 https://github.com/userbin/userbin-php

PHP bindings for Userbin

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

authorization two factor authentication account monitoring