You are here

function oauth_common_schema in OAuth 1.0 7.3

Same name and namespace in other branches
  1. 6.3 oauth_common.install \oauth_common_schema()
  2. 7.4 oauth_common.install \oauth_common_schema()

Implements hook_schema().

File

./oauth_common.install, line 34
Installation and schema related functions for the OAuth module

Code

function oauth_common_schema() {
  $schema = array();
  $schema['oauth_common_context'] = array(
    'description' => 'Stores contexts for OAuth common',
    'export' => array(
      'identifier' => 'context',
      'export callback' => 'oauth_common_context_export',
      'list callback' => 'oauth_common_context_list',
      'key' => 'name',
      'api' => array(
        'owner' => 'oauth_common',
        'api' => 'oauth',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
    'fields' => array(
      'cid' => array(
        'type' => 'serial',
        'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
        'not null' => TRUE,
        'no export' => TRUE,
      ),
      'name' => array(
        'description' => 'The computer-readable name of the context.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'The localizable title of the authorization context.',
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
      ),
      'authorization_options' => array(
        'description' => 'Authorization options.',
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
        'serialize' => TRUE,
        'object default' => array(),
      ),
      'authorization_levels' => array(
        'description' => 'Authorization levels for the context.',
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
        'serialize' => TRUE,
        'object default' => array(),
      ),
    ),
    'primary key' => array(
      'cid',
    ),
    'unique keys' => array(
      'context' => array(
        'name',
      ),
    ),
  );
  $schema['oauth_common_consumer'] = _oauth_common_consumer_schema();
  $schema['oauth_common_provider_consumer'] = _oauth_common_provider_consumer_schema();
  $schema['oauth_common_token'] = _oauth_common_token_schema();
  $schema['oauth_common_provider_token'] = _oauth_common_provider_token_schema();
  $schema['oauth_common_nonce'] = array(
    'description' => 'Stores timestamp against nonce for repeat attacks.',
    'fields' => array(
      'nonce' => array(
        'description' => 'The random string used on each request.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'timestamp' => array(
        'description' => 'The timestamp of the request.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'token_key' => array(
        'description' => 'Token key.',
        // This is our own internal key - it's 0 or 32 characters long
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'nonce',
    ),
    'indexes' => array(
      'timekey' => array(
        'timestamp',
        'token_key',
      ),
    ),
  );
  return $schema;
}