Git Product home page Git Product logo

castle-php's People

Contributors

afterdesign avatar bartes avatar brissmyr avatar brunov25 avatar dawlib avatar jncr avatar joladev avatar lluft avatar marysieek avatar wallin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

castle-php's Issues

Use an autoloader instead of manually including each file.

You could use an autoloader on lib/Castle.php this is very easy todo.

lib/Castle/autoloader.php

<?php
/**
 * Get all files from the lib directory and require them.
 */
function getFiles() 
{
    $files = array_diff(scandir(dirname(__FILE__)), array('..', '.'));
    foreach($files as $file)
    {
        require($file);
    }
}
spl_autload_register('getFiles');

lib/Castle/Castle.php

// Everything above requires remain the same
require(dirname(__FILE__) . '/autoloader.php');
// All other requires can be removed.

This should greatly reduce the amount of effort needed to maintain this lib.

Another valid way of doing this (even easier) would be to use the following code in place of all the requires

require(dirname(dirname(__FILE__)) . "/vendor/autoload.php");

Thus using composer.

Add support for /approve and /report APIs

Our new APIs allow Admins to directly approve and report a device with a device token, not need to collect the request context. However, these APIs, included the Device fetching API, are not available via our SDK.

Can we add methods to the SDK that can handle these three APIs:
GET https://api.castle.io/v1/users/{user-id}/devices
PUT https://api.castle.io/v1/devices/{device_token}/approve
PUT https://api.castle.io/v1/devices/{device_token}/report

See more on each API here: https://castle.io/docs/device_management_tool

get_session cookie does not exist

Currently in get_session there is a check, if (!$_COOKIE['_ubt']), since there is a possibility this key may not exist, php will throw an undefined index error. I believe this should be:

if ( !isset($_COOKIE['_ubt']) )

Composer doesn't load in classes.

I have composer setup and working correctly. I am using the dev-master version simply for testing purposes and every single time I get the following error.

Class 'Castle' not found

Looking through the composer auto-load files I have come to the conclusion that the composer.json is not set correctly.

getenv(CONSTANTS) undefined

As per php manual, getenv takes a string argument:

Currently verify_settings() is taking constants, getenv(USERBIN_APP_ID), I believe these should be wrapped with single quotes.

Help on Castle::track

Hi guys, I need your help. I'm using this castle-php library for my project and I have a problem. I already followed the documentation here https://castle.io/docs/events for PHP but still I can't log events in my castle. I tried creating a file just to isolate and just run castle and here's my code. The problem here is that I have an error which asks for headers but its said in the documentation that headers are set automatically for server side SDK's like PHP.

Here's the error message:

[01-Jun-2017 06:31:51 Europe/Athens] PHP Fatal error: Uncaught exception 'Castle_BadRequest' with message 'One or more HTTP headers are missing: header 'X-Castle-Cookie-Id' is missing' in /home/stgngstm/public_html/stm-libraries/castle-php/lib/Castle/Request.php:81 Stack trace: #0 /home/stgngstm/public_html/stm-libraries/castle-php/lib/Castle/Request.php(116): Castle_Request->handleApiError(Array, 400) #1 /home/stgngstm/public_html/stm-libraries/castle-php/lib/Castle/Request.php(162): Castle_Request->handleResponse(Object(Castle_RequestTransport)) #2 /home/stgngstm/public_html/stm-libraries/castle-php/lib/Castle/Castle.php(101): Castle_Request->send('post', '/track', Array) #3 /home/stgngstm/public_html/info.php(25): Castle::track(Array) #4 {main} thrown in /home/stgngstm/public_html/stm-libraries/castle-php/lib/Castle/Request.php on line 81

Here's my Code:

`<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/stm-libraries/castle-php/lib/Castle.php';

Castle::setApiKey('myapikeyhere');

$verdict = Castle::authenticate(array(
  'name' => '$login.succeeded',
  'user_id' => '20007a'
));

if ($verdict->action == 'allow') {
	echo 'Allowed';
  
	Castle::identify('20007a', array(
      'traits' => array(
      	'name' => 'Rey Philip Regis',
      	'_region' => 'NCR',
      	'email' => '[email protected]'
      )
    ));

    Castle::track(array(
	  'name' => 'My important event',
	  'user_id' => '20007a'
	));

} else if ($verdict->action == 'challenge') {
  // Additional authentication required
	echo 'Challenge';
} else if ($verdict->action == 'deny') {
	echo 'Denied';
  // Failed authentication. Lock account
}

?>`

Hope you guys can help me. Thanks.

SSL Cert Problem

After trying to login Castle will though a CURL error related to the SSL Chain having a Self Signed Cert in it. To be specific it troughs this error:
60: SSL certificate problem: self signed certificate in certificate chain

javascript_config undefined variable

Is $html .= "ubin(" legal when $html is not defined in the scope yet?

Curiosity was sparked when I received this error when trying to include:

Message: Undefined variable: html
Filename: userbin/Userbin.php
Line Number: 118

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.