oauth2-server/sql/mysql.sql

83 lines
4.0 KiB
MySQL
Raw Normal View History

2013-02-13 02:03:03 +05:30
CREATE TABLE `oauth_clients` (
2013-04-23 18:50:38 +05:30
`id` CHAR(40) NOT NULL,
`secret` CHAR(40) NOT NULL,
`name` VARCHAR(255) NOT NULL,
2013-04-03 20:20:07 +05:30
`auto_approve` TINYINT(1) NOT NULL DEFAULT '0',
2013-04-23 18:50:38 +05:30
PRIMARY KEY (`id`),
UNIQUE KEY `u_oacl_clse_clid` (`secret`,`id`)
2013-04-03 20:20:07 +05:30
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2012-07-09 21:10:03 +05:30
CREATE TABLE `oauth_client_endpoints` (
2013-04-03 20:20:07 +05:30
`endpoint_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`client_id` CHAR(40) NOT NULL,
`redirect_uri` VARCHAR(255) NOT NULL,
PRIMARY KEY (`endpoint_id`),
KEY `i_oaclen_clid` (`client_id`),
2013-04-23 18:50:38 +05:30
CONSTRAINT `f_oaclen_clid` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2013-04-03 20:20:07 +05:30
) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `oauth_session` (
2013-04-23 18:50:38 +05:30
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
2013-04-03 20:20:07 +05:30
`client_id` CHAR(40) NOT NULL,
`owner_type` ENUM('user','client') NOT NULL DEFAULT 'user',
`owner_id` VARCHAR(255) NOT NULL,
2013-04-23 18:50:38 +05:30
PRIMARY KEY (`id`),
2013-04-03 20:20:07 +05:30
KEY `i_uase_clid_owty_owid` (`client_id`,`owner_type`,`owner_id`),
2013-04-23 18:50:38 +05:30
CONSTRAINT `f_oase_clid` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2013-04-03 20:20:07 +05:30
) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `oauth_session_access_token` (
2013-04-23 18:50:38 +05:30
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
2013-04-03 20:20:07 +05:30
`session_id` INT(10) UNSIGNED NOT NULL,
`access_token` CHAR(40) CHARACTER SET utf8 NOT NULL DEFAULT '',
`access_token_expires` INT(10) UNSIGNED NOT NULL,
2013-04-23 18:50:38 +05:30
PRIMARY KEY (`id`),
2013-04-03 20:20:07 +05:30
UNIQUE KEY `u_oaseacto_acto_seid` (`access_token`,`session_id`),
KEY `f_oaseto_seid` (`session_id`),
2013-04-23 18:50:38 +05:30
CONSTRAINT `f_oaseto_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_session` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
2013-04-23 18:14:21 +05:30
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2013-04-03 20:20:07 +05:30
CREATE TABLE `oauth_session_authcode` (
`session_id` INT(10) UNSIGNED NOT NULL,
2013-04-23 18:50:38 +05:30
`session_access_token_id` INT(10) UNSIGNED DEFAULT NULL,
`auth_code` CHAR(40) CHARACTER SET utf8 NOT NULL DEFAULT '',
`auth_code_expires` INT(10) UNSIGNED NOT NULL,
2013-04-03 20:20:07 +05:30
PRIMARY KEY (`session_id`),
2013-04-23 18:50:38 +05:30
KEY `f_oaseau_setoid` (`session_access_token_id`),
CONSTRAINT `f_oaseau_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_session` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `f_oaseau_setoid` FOREIGN KEY (`session_access_token_id`) REFERENCES `oauth_session_access_token` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
2013-04-23 18:14:21 +05:30
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2013-04-03 20:20:07 +05:30
CREATE TABLE `oauth_session_redirect` (
`session_id` INT(10) UNSIGNED NOT NULL,
`redirect_uri` VARCHAR(255) CHARACTER SET utf8 NOT NULL DEFAULT '',
PRIMARY KEY (`session_id`),
2013-04-23 18:50:38 +05:30
CONSTRAINT `f_oasere_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_session` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
2013-04-23 18:14:21 +05:30
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2013-04-03 20:20:07 +05:30
CREATE TABLE `oauth_session_refresh_token` (
2013-04-23 18:50:38 +05:30
`session_access_token_id` INT(10) UNSIGNED NOT NULL,
2013-04-03 20:20:07 +05:30
`refresh_token` CHAR(40) CHARACTER SET utf8 NOT NULL DEFAULT '',
2013-04-23 18:50:38 +05:30
PRIMARY KEY (`session_access_token_id`),
CONSTRAINT `f_oasetore_setoid` FOREIGN KEY (`session_access_token_id`) REFERENCES `oauth_session_access_token` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
2013-04-23 18:14:21 +05:30
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2012-07-09 21:10:03 +05:30
2013-02-13 02:03:03 +05:30
CREATE TABLE `oauth_scopes` (
2013-04-23 18:50:38 +05:30
`id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
`key` VARCHAR(255) NOT NULL,
`name` VARCHAR(255) NOT NULL,
`description` VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `u_oasc_sc` (`key`)
2013-04-03 20:20:07 +05:30
) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `oauth_session_token_scope` (
`session_token_scope_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
2013-04-23 18:50:38 +05:30
`session_access_token_id` INT(10) UNSIGNED NOT NULL,
2013-04-03 20:20:07 +05:30
`scope_id` SMALLINT(5) UNSIGNED NOT NULL,
PRIMARY KEY (`session_token_scope_id`),
2013-04-23 18:50:38 +05:30
UNIQUE KEY `u_setosc_setoid_scid` (`session_access_token_id`,`scope_id`),
2013-04-03 20:20:07 +05:30
KEY `f_oasetosc_scid` (`scope_id`),
2013-04-23 18:50:38 +05:30
CONSTRAINT `f_oasetosc_setoid` FOREIGN KEY (`session_access_token_id`) REFERENCES `oauth_session_access_token` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `f_oasetosc_scid` FOREIGN KEY (`scope_id`) REFERENCES `oauth_scopes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
2013-04-03 20:20:07 +05:30
) ENGINE=INNODB DEFAULT CHARSET=utf8;