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 1 commit
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
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ cache:
directories:
- $HOME/.composer/cache
- vendor
- $HOME/cphalcon
php:
- 5.3
- 5.4
- 5.5
- 5.6
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove php 7 and hhvm!! Just add an if statement around your before_install:

  - composer install --prefer-source --no-interaction
  - if [[ ${TRAVIS_PHP_VERSION:0:1} == "5" ]]; then vendor/bin/install-phalcon.sh 2.0.x; fi;
  - phpenv config-rm xdebug.ini || return 0

.. Or something similar

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad... I'm kinda new to Travis and I've really only used a couple times, let alone with Phalcon. I'll fix it up right away.

- 7
- hhvm
env:
global:
- SKIP_MONGO_TESTS=1
Expand All @@ -20,11 +19,16 @@ services:
- mongodb
- redis-server
- cassandra
- mysql
- memcached
before_install:
- phpenv config-rm xdebug.ini || return 0
- composer install --prefer-source --no-interaction
- vendor/bin/install-phalcon.sh 2.0.x
- phpenv config-rm xdebug.ini || return 0
install:
- composer install --no-interaction
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is composer install also in install? How about you move the phalcon installation to install instead?

before_script:
- php -m
- psql -c 'create database oauth2_server_php;' -U postgres
after_script:
- 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"
}
}
6 changes: 4 additions & 2 deletions src/OAuth2/Storage/Phalcon/Models/OauthAccessTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthAccessTokens extends \Phalcon\Mvc\Model
{
/**
Expand Down Expand Up @@ -61,7 +63,7 @@ public static function findFirst($parameters = null)
*/
public function initialize()
{
$this->setSource("'oauth__access_tokens'");
$this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getAccessTokenTable() . "'");
$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"));
}
Expand All @@ -73,7 +75,7 @@ public function initialize()
*/
public function getSource()
{
return 'oauth__access_tokens';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getAccessTokenTable();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthAuthorizationCodes extends \Phalcon\Mvc\Model
{

Expand Down Expand Up @@ -54,7 +56,7 @@ class OauthAuthorizationCodes extends \Phalcon\Mvc\Model
*/
public function getSource()
{
return 'oauth__authorization_codes';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getCodeTable();
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/OAuth2/Storage/Phalcon/Models/OauthClients.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthClients extends \Phalcon\Mvc\Model
{

Expand Down Expand Up @@ -68,7 +70,7 @@ public static function findFirst($parameters = null)
*/
public function initialize()
{
$this->setSource("'oauth__clients'");
$this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getClientTable() . "'");
$this->belongsTo('user_id', 'OAuth2\Storage\Phalcon\Models\OauthUsers', 'username', array("alias" => "User"));
}

Expand All @@ -79,7 +81,7 @@ public function initialize()
*/
public function getSource()
{
return 'oauth__clients';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getClientTable();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/OAuth2/Storage/Phalcon/Models/OauthJti.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthJti extends \Phalcon\Mvc\Model
{

Expand Down Expand Up @@ -42,7 +44,7 @@ class OauthJti extends \Phalcon\Mvc\Model
*/
public function getSource()
{
return 'oauth__jti';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getJtiTable();
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/OAuth2/Storage/Phalcon/Models/OauthJwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthJwt extends \Phalcon\Mvc\Model
{

Expand Down Expand Up @@ -50,7 +52,7 @@ public static function findFirst($parameters = null)
*/
public function initialize()
{
$this->setSource("'oauth__jwt'");
$this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getJwtTable() . "'");
$this->belongsTo('client_id', 'OAuth2\Storage\Phalcon\Models\OauthClients', 'client_id', array("alias" => "Client"));
}

Expand All @@ -61,9 +63,9 @@ public function initialize()
*/
public function getSource()
{
return 'oauth__jwt';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getJwtTable();
}

public function getClient($parameters = null)
{
return $this->getRelated('Client', $parameters);
Expand Down
7 changes: 5 additions & 2 deletions src/OAuth2/Storage/Phalcon/Models/OauthPublicKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthPublicKeys extends \Phalcon\Mvc\Model
{

Expand Down Expand Up @@ -56,7 +58,7 @@ public static function findFirst($parameters = null)
*/
public function initialize()
{
$this->setSource("'oauth__public_keys'");
$this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getPublicKeyTable() . "'");
$this->belongsTo('client_id', 'OAuth2\Storage\Phalcon\Models\OauthClients', 'client_id', array("alias" => "Client"));
}

Expand All @@ -67,9 +69,10 @@ public function initialize()
*/
public function getSource()
{
return 'oauth__public_keys';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getPublicKeyTable();
}


public function getClient($parameters = null)
{
return $this->getRelated('Client', $parameters);
Expand Down
7 changes: 4 additions & 3 deletions src/OAuth2/Storage/Phalcon/Models/OauthRefreshTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthRefreshTokens extends \Phalcon\Mvc\Model
{
/**
Expand Down Expand Up @@ -61,7 +63,7 @@ public static function findFirst($parameters = null)
*/
public function initialize()
{
$this->setSource("'oauth__refresh_tokens'");
$this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getRefreshTokenTable() . "'");
$this->belongsTo('user_id', 'OAuth2\Storage\Phalcon\Models\OauthUsers', 'username');
$this->belongsTo('client_id', 'OAuth2\Storage\Phalcon\Models\OauthClients', 'client_id');
}
Expand All @@ -73,7 +75,6 @@ public function initialize()
*/
public function getSource()
{
return 'oauth__refresh_tokens';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getRefreshTokenTable();
}

}
4 changes: 3 additions & 1 deletion src/OAuth2/Storage/Phalcon/Models/OauthScopes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthScopes extends \Phalcon\Mvc\Model
{

Expand All @@ -24,7 +26,7 @@ class OauthScopes extends \Phalcon\Mvc\Model
*/
public function getSource()
{
return 'oauth__scopes';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getScopeTable();
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/OAuth2/Storage/Phalcon/Models/OauthUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;
use Phalcon\Mvc\Model\Validator\Email as Email;

class OauthUsers extends \Phalcon\Mvc\Model
Expand Down Expand Up @@ -77,7 +78,7 @@ public static function findFirst($parameters = null)
public function initialize()
{
$this->keepSnapshots(true);
$this->setSource("'oauth__users'");
$this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getUserTable() . "'");
$this->hasMany('username', 'OAuth2\Storage\Phalcon\Models\OauthAccessTokens', 'user_id', array("alias" => "AccessTokens"));
$this->hasMany('username', 'OAuth2\Storage\Phalcon\Models\OauthRefreshTokens', 'user_id', array("alias" => "RefreshTokens"));
}
Expand Down Expand Up @@ -112,7 +113,7 @@ public function validation()
*/
public function getSource()
{
return 'oauth__users';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getUserTable();
}

/**
Expand All @@ -132,5 +133,5 @@ public function getRefreshTokens($parameters = null)
{
return $this->getRelated('RefreshTokens', $parameters);
}

}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add newline :P

Copy link
Author

@lucasantarella lucasantarella Jun 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it. Thanks for pointing them out. I'll clean it up ASAP. What do you
think about all the model files though? Too much for the style of the repo?

Loading