Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phalcon storage #743

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cache:
directories:
- $HOME/.composer/cache
- vendor
- $HOME/cphalcon
php:
- 5.3
- 5.4
Expand All @@ -20,11 +21,18 @@ services:
- mongodb
- redis-server
- cassandra
- mysql
- memcached
before_install:
- phpenv config-rm xdebug.ini || return 0
- phpenv config-rm xdebug.ini || return 0
install:
- composer install --no-interaction
- composer install --prefer-source --no-interaction
- if [[ ${TRAVIS_PHP_VERSION:0} == "5.4" ]]; then vendor/bin/install-phalcon.sh 2.0.x; fi;
- if [[ ${TRAVIS_PHP_VERSION:0} == "5.5" ]]; then vendor/bin/install-phalcon.sh 2.0.x; fi;
- if [[ ${TRAVIS_PHP_VERSION:0} == "5.6" ]]; then vendor/bin/install-phalcon.sh 2.0.x; fi;
before_script:
- psql -c 'create database oauth2_server_php;' -U postgres
script:
phpunit -v
after_script:
- php test/cleanup.php
- php test/cleanup.php
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"aws/aws-sdk-php": "~2.8",
"firebase/php-jwt": "~2.2",
"predis/predis": "dev-master",
"thobbs/phpcassa": "dev-master"
"thobbs/phpcassa": "dev-master",
"techpivot/phalcon-ci-installer": "~1.0"
}
}
99 changes: 99 additions & 0 deletions src/OAuth2/Storage/Phalcon/Models/OauthAccessTokens.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthAccessTokens extends \Phalcon\Mvc\Model
{
/**
*
* @var string
*/
public $access_token;

/**
*
* @var string
*/
public $client_id;

/**
*
* @var string
*/
public $user_id;

/**
*
* @var string
*/
public $expires;

/**
*
* @var string
*/
public $scope;

/**
* Allows to query a set of records that match the specified conditions
*
* @param mixed $parameters
* @return OauthAccessTokens[]
*/
public static function find($parameters = null)
{
return parent::find($parameters);
}

/**
* Allows to query the first record that match the specified conditions
*
* @param mixed $parameters
* @return OauthAccessTokens
*/
public static function findFirst($parameters = null)
{
return parent::findFirst($parameters);
}

/**
* Initialize method for model.
*/
public function initialize()
{
$this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)['access_token_table'] . "'");
$this->belongsTo('user_id', 'OAuth2\Storage\Phalcon\Models\OauthUsers', 'username', array("alias" => "User"));
$this->belongsTo('client_id', 'OAuth2\Storage\Phalcon\Models\OauthClients', 'client_id', array("alias" => "Client"));
}

/**
* Returns table name mapped in the model.
*
* @return string
*/
public function getSource()
{
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)['access_token_table'];
}

/**
* @param mixed $parameters
* @return \OAuth2\Storage\Phalcon\Models\OauthUsers
*/
public function getUser($parameters = null)
{
return $this->getRelated('User', $parameters);
}

/**
* @param mixed $parameters
* @return \OAuth2\Storage\Phalcon\Models\OauthClients
*/
public function getClient($parameters = null)
{
return $this->getRelated('Client', $parameters);
}

}
84 changes: 84 additions & 0 deletions src/OAuth2/Storage/Phalcon/Models/OauthAuthorizationCodes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthAuthorizationCodes extends \Phalcon\Mvc\Model
{

/**
*
* @var string
*/
public $authorization_code;

/**
*
* @var string
*/
public $client_id;

/**
*
* @var string
*/
public $user_id;

/**
*
* @var string
*/
public $redirect_uri;

/**
*
* @var string
*/
public $expires;

/**
*
* @var string
*/
public $scope;

/**
*
* @var string
*/
public $id_token;

/**
* Returns table name mapped in the model.
*
* @return string
*/
public function getSource()
{
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)['code_table'];
}

/**
* Allows to query a set of records that match the specified conditions
*
* @param mixed $parameters
* @return OauthAuthorizationCodes[]
*/
public static function find($parameters = null)
{
return parent::find($parameters);
}

/**
* Allows to query the first record that match the specified conditions
*
* @param mixed $parameters
* @return OauthAuthorizationCodes
*/
public static function findFirst($parameters = null)
{
return parent::findFirst($parameters);
}

}
96 changes: 96 additions & 0 deletions src/OAuth2/Storage/Phalcon/Models/OauthClients.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthClients extends \Phalcon\Mvc\Model
{

/**
*
* @var string
*/
public $client_id;

/**
*
* @var string
*/
public $client_secret;

/**
*
* @var string
*/
public $redirect_uri;

/**
*
* @var string
*/
public $grant_types;

/**
*
* @var string
*/
public $scope;

/**
*
* @var string
*/
public $user_id;

/**
* Allows to query a set of records that match the specified conditions
*
* @param mixed $parameters
* @return OauthClients[]
*/
public static function find($parameters = null)
{
return parent::find($parameters);
}

/**
* Allows to query the first record that match the specified conditions
*
* @param mixed $parameters
* @return OauthClients
*/
public static function findFirst($parameters = null)
{
return parent::findFirst($parameters);
}

/**
* Initialize method for model.
*/
public function initialize()
{
$this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)['client_table'] . "'");
$this->belongsTo('user_id', 'OAuth2\Storage\Phalcon\Models\OauthUsers', 'username', array("alias" => "User"));
}

/**
* Returns table name mapped in the model.
*
* @return string
*/
public function getSource()
{
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)['client_table'];
}

/**
* @param mixed $parameters
* @return OauthUsers
*/
public function getUser($parameters = null)
{
return $this->getRelated('User', $parameters);
}

}
72 changes: 72 additions & 0 deletions src/OAuth2/Storage/Phalcon/Models/OauthJti.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthJti extends \Phalcon\Mvc\Model
{

/**
*
* @var string
*/
public $issuer;

/**
*
* @var string
*/
public $subject;

/**
*
* @var string
*/
public $audience;

/**
*
* @var string
*/
public $expires;

/**
*
* @var string
*/
public $jti;

/**
* Returns table name mapped in the model.
*
* @return string
*/
public function getSource()
{
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)['jti_table'];
}

/**
* Allows to query a set of records that match the specified conditions
*
* @param mixed $parameters
* @return OauthJti[]
*/
public static function find($parameters = null)
{
return parent::find($parameters);
}

/**
* Allows to query the first record that match the specified conditions
*
* @param mixed $parameters
* @return OauthJti
*/
public static function findFirst($parameters = null)
{
return parent::findFirst($parameters);
}

}
Loading