install.sql 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. CREATE TABLE IF NOT EXISTS `bx_oauth_access_tokens` (
  2. `access_token` varchar(40) NOT NULL,
  3. `client_id` varchar(80) NOT NULL,
  4. `user_id` int(10) unsigned DEFAULT NULL,
  5. `expires` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  6. `scope` varchar(255) DEFAULT NULL,
  7. PRIMARY KEY (`access_token`)
  8. );
  9. CREATE TABLE IF NOT EXISTS `bx_oauth_authorization_codes` (
  10. `authorization_code` varchar(40) NOT NULL,
  11. `client_id` varchar(80) NOT NULL,
  12. `user_id` int(10) unsigned DEFAULT NULL,
  13. `redirect_uri` varchar(255) DEFAULT NULL,
  14. `expires` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  15. `scope` varchar(255) DEFAULT NULL,
  16. PRIMARY KEY (`authorization_code`),
  17. KEY `user_id` (`user_id`)
  18. );
  19. CREATE TABLE IF NOT EXISTS `bx_oauth_clients` (
  20. `id` int(11) NOT NULL AUTO_INCREMENT,
  21. `title` varchar(255) NOT NULL,
  22. `client_id` varchar(80) NOT NULL,
  23. `client_secret` varchar(80) DEFAULT NULL,
  24. `redirect_uri` varchar(255) NOT NULL,
  25. `grant_types` varchar(80) DEFAULT NULL,
  26. `scope` varchar(255) DEFAULT NULL,
  27. `parent_id` int(10) unsigned DEFAULT 0,
  28. `user_id` int(10) unsigned DEFAULT 0,
  29. PRIMARY KEY (`id`),
  30. UNIQUE KEY `client_id` (`client_id`)
  31. );
  32. CREATE TABLE IF NOT EXISTS `bx_oauth_allowed_origins` (
  33. `id` int(11) NOT NULL AUTO_INCREMENT,
  34. `client_id` int(11) NOT NULL,
  35. `url` varchar(255) NOT NULL,
  36. PRIMARY KEY (`id`),
  37. KEY `url` (`url`(191))
  38. );
  39. CREATE TABLE IF NOT EXISTS `bx_oauth_refresh_tokens` (
  40. `refresh_token` varchar(40) NOT NULL,
  41. `client_id` varchar(80) NOT NULL,
  42. `user_id` int(10) unsigned DEFAULT NULL,
  43. `expires` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  44. `scope` varchar(255) DEFAULT NULL,
  45. PRIMARY KEY (`refresh_token`),
  46. KEY `user_id` (`user_id`)
  47. );
  48. CREATE TABLE IF NOT EXISTS `bx_oauth_scopes` (
  49. `scope` varchar(255) DEFAULT NULL,
  50. `is_default` tinyint(1) DEFAULT NULL
  51. );
  52. INSERT INTO `bx_oauth_scopes` (`scope`, `is_default`) VALUES
  53. ('basic', 1),
  54. ('service', 0),
  55. ('market', 0);
  56. -- Studio page and widget
  57. INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
  58. (3, 'bx_oauth', '_bx_oauth', '_bx_oauth', 'bx_oauth@modules/boonex/oauth2/|std-icon.svg');
  59. SET @iPageId = LAST_INSERT_ID();
  60. SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name` = 'home');
  61. SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id` = @iParentPageId);
  62. INSERT INTO `sys_std_widgets` (`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
  63. (@iPageId, 'bx_oauth', '{url_studio}module.php?name=bx_oauth&page=settings', '', 'bx_oauth@modules/boonex/oauth2/|std-icon.svg', '_bx_oauth', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioModules";}');
  64. INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
  65. (@iParentPageId, LAST_INSERT_ID(), IF(ISNULL(@iParentPageOrder), 1, @iParentPageOrder + 1));