Permalink
Browse files

Updating field and model names

  • Loading branch information...
1 parent c5ac65a commit d0ddbee21bbabc983f053a4e912c9f4db26aeb33 @burzum burzum committed Jan 11, 2012
@@ -19,34 +19,34 @@ class OauthMigration001 extends CakeMigration {
'up' => array(
'create_table' => array(
'oauth2_auth_codes' => array(
- 'id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 40),
- 'oauth2_client_id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 20),
+ 'code' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 40),
+ 'client_id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 20),
'redirect_uri' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 200),
'expires' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 11),
'scope' => array('type'=>'string', 'null' => true, 'default' => NULL, 'lenght' => 200),
- 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
+ 'indexes' => array('PRIMARY' => array('column' => 'code', 'unique' => 1)),
),
'oauth2_clients' => array(
- 'id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 20),
+ 'client_id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 20),
'secret' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 20),
'redirect_uri' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 200),
- 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
+ 'indexes' => array('PRIMARY' => array('column' => 'client_id', 'unique' => 1)),
),
'oauth2_access_tokens' => array(
- 'id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 40),
- 'oauth2_client_id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 20),
+ 'oauth_token' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 40),
+ 'client_id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 20),
'user_id' => array('type'=>'string', 'null' => true, 'default' => NULL, 'length' => 36),
'expires' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 11),
'scope' => array('type'=>'string', 'null' => true, 'default' => NULL, 'lenght' => 200),
- 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
+ 'indexes' => array('PRIMARY' => array('column' => 'oauth_token', 'unique' => 1)),
),
'oauth2_refresh_tokens' => array(
- 'id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 40),
- 'oauth2_client_id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 20),
+ 'refresh_token' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 40),
+ 'client_id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'lenght' => 20),
'user_id' => array('type'=>'string', 'null' => true, 'default' => NULL, 'length' => 36),
'expires' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 11),
'scope' => array('type'=>'string', 'null' => true, 'default' => NULL, 'lenght' => 200),
- 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
+ 'indexes' => array('PRIMARY' => array('column' => 'refresh_token', 'unique' => 1)),
),
)
),
View
@@ -1,25 +1,36 @@
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-CREATE TABLE `auth_codes` (
+CREATE TABLE `oauth2_auth_codes` (
`code` varchar(40) NOT NULL,
- `client_id` varchar(20) NOT NULL,
- `redirect_uri` varchar(200) NOT NULL,
+ `client_id` varchar(32) NOT NULL,
+ `user_id` varchar(255) NOT NULL,
+ `redirect_uri` varchar(255) NOT NULL,
`expires` int(11) NOT NULL,
- `scope` varchar(250) DEFAULT NULL,
+ `scope` varchar(255) DEFAULT NULL,
PRIMARY KEY (`code`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-CREATE TABLE `clients` (
- `client_id` varchar(20) NOT NULL,
- `client_secret` varchar(20) NOT NULL,
- `redirect_uri` varchar(200) NOT NULL,
+CREATE TABLE `oauth2_clients` (
+ `client_id` varchar(32) NOT NULL,
+ `client_secret` varchar(255) NOT NULL,
+ `redirect_uri` varchar(255) NOT NULL,
PRIMARY KEY (`client_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-CREATE TABLE `tokens` (
+CREATE TABLE `oauth2_access_tokens` (
`oauth_token` varchar(40) NOT NULL,
- `client_id` varchar(20) NOT NULL,
+ `client_id` varchar(32) NOT NULL,
+ `user_id` varchar(255) NOT NULL,
`expires` int(11) NOT NULL,
- `scope` varchar(200) DEFAULT NULL,
+ `scope` varchar(255) DEFAULT NULL,
PRIMARY KEY (`oauth_token`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+CREATE TABLE `oauth2_refresh_tokens` (
+ `refresh_token` varchar(40) NOT NULL,
+ `client_id` varchar(32) NOT NULL,
+ `user_id` varchar(255) NOT NULL,
+ `expires` int(11) NOT NULL,
+ `scope` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`refresh_token`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@@ -0,0 +1,6 @@
+<?php
+App::uses('AppController', 'Controller');
+
+class Oauth2AppController extends AppController {
+
+}
@@ -16,10 +16,10 @@ class OAuth2StorageCake implements IOAuth2GrantCode, IOAuth2RefreshTokens {
public function __construct($options = array()) {
$defaults = array(
'models' => array(
- 'AuthCode' => 'Oauth2.Oauth2RequestToken',
+ 'AuthCode' => 'Oauth2.Oauth2AuthToken',
'Client' => 'Oauth2.Oauth2Client',
'Token' => 'Oauth2.Oauth2AccessToken',
- 'RefreshToken' => 'Oauth2.RefreshToken'));
+ 'RefreshToken' => 'Oauth2.Oauth2RefreshToken'));
$this->options = Set::merge($defaults, $options);
@@ -1,5 +1,7 @@
<?php
-class OauthToken extends AppModel {
+App::uses('Oauth2AppModel', 'Oauth2.Model');
+
+class Oauth2AccessToken extends Oauth2AppModel {
/**
* Name
*
View
@@ -0,0 +1,12 @@
+<?php
+App::uses('AppModel', 'Model');
+
+class Oauth2AppModel extends AppModel {
+/**
+ * Behaviors
+ *
+ * @var array
+ */
+ public $actsAs = array('Containable');
+
+}
View
@@ -1,5 +1,7 @@
<?php
-class Oauth2AuthCode extends AppModel {
+App::uses('Oauth2AppModel', 'Oauth2.Model');
+
+class Oauth2AuthCode extends Oauth2AppModel {
/**
* Name
*
View
@@ -1,5 +1,7 @@
<?php
-class OauthClient extends AppModel {
+App::uses('Oauth2AppModel', 'Oauth2.Model');
+
+class OauthClient extends Oauth2AppModel {
/**
* Name
*
@@ -0,0 +1,12 @@
+<?php
+App::uses('Oauth2AppModel', 'Oauth2.Model');
+
+class OauthToken extends Oauth2AppModel {
+/**
+ * Name
+ *
+ * @var string
+ */
+ public $name = 'OauthToken';
+
+}
@@ -1,10 +0,0 @@
-<?php
-class OauthToken extends AppModel {
-/**
- * Name
- *
- * @var string
- */
- public $name = 'OauthToken';
-
-}

0 comments on commit d0ddbee

Please sign in to comment.