mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-01 16:33:07 +05:30
Updated SQL structure
This commit is contained in:
parent
645d412c02
commit
d75d266376
122
sql/mysql.sql
122
sql/mysql.sql
@ -1,53 +1,83 @@
|
||||
CREATE TABLE `oauth_clients` (
|
||||
`id` varchar(40) NOT NULL DEFAULT '',
|
||||
`secret` varchar(40) NOT NULL DEFAULT '',
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`auto_approve` tinyint(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
`client_id` CHAR(40) NOT NULL,
|
||||
`client_secret` CHAR(40) NOT NULL,
|
||||
`client_name` VARCHAR(255) NOT NULL,
|
||||
`auto_approve` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`client_id`),
|
||||
UNIQUE KEY `u_oacl_clse_clid` (`client_secret`,`client_id`)
|
||||
) ENGINE=INNODB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `oauth_client_endpoints` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`client_id` varchar(40) NOT NULL DEFAULT '',
|
||||
`redirect_uri` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `client_id` (`client_id`),
|
||||
CONSTRAINT `oauth_client_endpoints_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
`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`),
|
||||
CONSTRAINT `f_oaclen_clid` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`client_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=INNODB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `oauth_sessions` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`client_id` varchar(40) NOT NULL DEFAULT '',
|
||||
`redirect_uri` varchar(250) DEFAULT '',
|
||||
`owner_type` enum('user','client') NOT NULL DEFAULT 'user',
|
||||
`owner_id` varchar(255) DEFAULT '',
|
||||
`auth_code` varchar(40) DEFAULT '',
|
||||
`access_token` varchar(40) DEFAULT '',
|
||||
`refresh_token` varchar(40) DEFAULT '',
|
||||
`access_token_expires` int(10) DEFAULT NULL,
|
||||
`stage` enum('requested','granted') NOT NULL DEFAULT 'requested',
|
||||
`first_requested` int(10) unsigned NOT NULL,
|
||||
`last_updated` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `client_id` (`client_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE `oauth_session` (
|
||||
`session_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`client_id` CHAR(40) NOT NULL,
|
||||
`owner_type` ENUM('user','client') NOT NULL DEFAULT 'user',
|
||||
`owner_id` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`session_id`),
|
||||
KEY `i_uase_clid_owty_owid` (`client_id`,`owner_type`,`owner_id`),
|
||||
CONSTRAINT `f_oase_clid` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`client_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=INNODB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `oauth_session_access_token` (
|
||||
`session_token_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`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,
|
||||
PRIMARY KEY (`session_token_id`),
|
||||
UNIQUE KEY `u_oaseacto_acto_seid` (`access_token`,`session_id`),
|
||||
KEY `f_oaseto_seid` (`session_id`),
|
||||
CONSTRAINT `f_oaseto_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_session` (`session_id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) ENGINE=INNODB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `oauth_session_authcode` (
|
||||
`session_id` INT(10) UNSIGNED NOT NULL,
|
||||
`session_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,
|
||||
PRIMARY KEY (`session_id`),
|
||||
KEY `f_oaseau_setoid` (`session_token_id`),
|
||||
CONSTRAINT `f_oaseau_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_session` (`session_id`) ON DELETE CASCADE ON UPDATE NO ACTION,
|
||||
CONSTRAINT `f_oaseau_setoid` FOREIGN KEY (`session_token_id`) REFERENCES `oauth_session_access_token` (`session_token_id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) ENGINE=INNODB DEFAULT CHARSET=latin1;
|
||||
|
||||
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`),
|
||||
CONSTRAINT `f_oasere_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_session` (`session_id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) ENGINE=INNODB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `oauth_session_refresh_token` (
|
||||
`session_token_id` INT(10) UNSIGNED NOT NULL,
|
||||
`refresh_token` CHAR(40) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`session_token_id`),
|
||||
CONSTRAINT `f_oasetore_setoid` FOREIGN KEY (`session_token_id`) REFERENCES `oauth_session_access_token` (`session_token_id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) ENGINE=INNODB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `oauth_scopes` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`scope` varchar(255) NOT NULL DEFAULT '',
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`description` varchar(255) DEFAULT '',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `scope` (`scope`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
`scope_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`scope_key` VARCHAR(255) NOT NULL,
|
||||
`scope_name` VARCHAR(255) NOT NULL,
|
||||
`scope_description` VARCHAR(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`scope_id`),
|
||||
UNIQUE KEY `u_oasc_sc` (`scope_key`)
|
||||
) ENGINE=INNODB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `oauth_session_scopes` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`session_id` int(11) unsigned NOT NULL,
|
||||
`scope_id` int(11) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `session_id` (`session_id`),
|
||||
KEY `scope_id` (`scope_id`),
|
||||
CONSTRAINT `oauth_session_scopes_ibfk_5` FOREIGN KEY (`scope_id`) REFERENCES `oauth_scopes` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `oauth_session_scopes_ibfk_4` FOREIGN KEY (`session_id`) REFERENCES `oauth_sessions` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE `oauth_session_token_scope` (
|
||||
`session_token_scope_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`session_token_id` INT(10) UNSIGNED NOT NULL,
|
||||
`scope_id` SMALLINT(5) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`session_token_scope_id`),
|
||||
UNIQUE KEY `u_setosc_setoid_scid` (`session_token_id`,`scope_id`),
|
||||
KEY `f_oasetosc_scid` (`scope_id`),
|
||||
CONSTRAINT `f_oasetosc_setoid` FOREIGN KEY (`session_token_id`) REFERENCES `oauth_session_access_token` (`session_token_id`) ON DELETE CASCADE ON UPDATE NO ACTION,
|
||||
CONSTRAINT `f_oasetosc_scid` FOREIGN KEY (`scope_id`) REFERENCES `oauth_scopes` (`scope_id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) ENGINE=INNODB DEFAULT CHARSET=utf8;
|
Loading…
Reference in New Issue
Block a user