Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mysql] Add OAuth2 framework tables #5807

Merged
merged 5 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,113 @@ CREATE TABLE IF NOT EXISTS {{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{
{{/x-mysqlSchema}}
{{/vendorExtensions}}

{{/isArrayModel}}{{/hasVars}}{{/model}}{{/models}}
{{/isArrayModel}}{{/hasVars}}{{/model}}{{/models}}
{{#hasOAuthMethods}}
--
-- OAuth2 framework tables
-- Thanks to https://github.com/dsquier/oauth2-server-php-mysql repo
--

--
-- Table structure for table `oauth_clients`
--
CREATE TABLE IF NOT EXISTS `oauth_clients` (
`client_id` VARCHAR(80) NOT NULL,
`client_secret` VARCHAR(80) DEFAULT NULL,
`redirect_uri` VARCHAR(2000) DEFAULT NULL,
`grant_types` VARCHAR(80) DEFAULT NULL,
`scope` VARCHAR(4000) DEFAULT NULL,
`user_id` VARCHAR(80) DEFAULT NULL,
PRIMARY KEY (`client_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_access_tokens`
--
CREATE TABLE IF NOT EXISTS `oauth_access_tokens` (
`access_token` VARCHAR(40) NOT NULL,
`client_id` VARCHAR(80) DEFAULT NULL,
`user_id` VARCHAR(80) DEFAULT NULL,
`expires` TIMESTAMP NOT NULL,
`scope` VARCHAR(4000) DEFAULT NULL,
PRIMARY KEY (`access_token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_authorization_codes`
--
CREATE TABLE IF NOT EXISTS `oauth_authorization_codes` (
`authorization_code` VARCHAR(40) NOT NULL,
`client_id` VARCHAR(80) DEFAULT NULL,
`user_id` VARCHAR(80) DEFAULT NULL,
`redirect_uri` VARCHAR(2000) NOT NULL,
`expires` TIMESTAMP NOT NULL,
`scope` VARCHAR(4000) DEFAULT NULL,
`id_token` VARCHAR(1000) DEFAULT NULL,
PRIMARY KEY (`authorization_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_refresh_tokens`
--
CREATE TABLE IF NOT EXISTS `oauth_refresh_tokens` (
`refresh_token` VARCHAR(40) NOT NULL,
`client_id` VARCHAR(80) DEFAULT NULL,
`user_id` VARCHAR(80) DEFAULT NULL,
`expires` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`scope` VARCHAR(4000) DEFAULT NULL,
PRIMARY KEY (`refresh_token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_users`
--
CREATE TABLE IF NOT EXISTS `oauth_users` (
`username` VARCHAR(80) DEFAULT NULL,
`password` VARCHAR(255) DEFAULT NULL,
`first_name` VARCHAR(80) DEFAULT NULL,
`last_name` VARCHAR(80) DEFAULT NULL,
`email` VARCHAR(2000) DEFAULT NULL,
`email_verified` TINYINT(1) DEFAULT NULL,
`scope` VARCHAR(4000) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_scopes`
--
CREATE TABLE IF NOT EXISTS `oauth_scopes` (
`scope` VARCHAR(80) NOT NULL,
`is_default` TINYINT(1) DEFAULT NULL,
PRIMARY KEY (`scope`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_jwt`
--
CREATE TABLE IF NOT EXISTS `oauth_jwt` (
`client_id` VARCHAR(80) NOT NULL,
`subject` VARCHAR(80) DEFAULT NULL,
`public_key` VARCHAR(2000) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_jti`
--
CREATE TABLE IF NOT EXISTS `oauth_jti` (
`issuer` VARCHAR(80) NOT NULL,
`subject` VARCHAR(80) DEFAULT NULL,
`audiance` VARCHAR(80) DEFAULT NULL,
`expires` TIMESTAMP NOT NULL,
`jti` VARCHAR(2000) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_public_keys`
--
CREATE TABLE IF NOT EXISTS `oauth_public_keys` (
`client_id` VARCHAR(80) DEFAULT NULL,
`public_key` VARCHAR(2000) DEFAULT NULL,
`private_key` VARCHAR(2000) DEFAULT NULL,
`encryption_algorithm` VARCHAR(100) DEFAULT 'RS256'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
{{/hasOAuthMethods}}
108 changes: 108 additions & 0 deletions samples/schema/petstore/mysql/mysql_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,111 @@ CREATE TABLE IF NOT EXISTS `XmlItem` (
`prefix_ns_wrapped_array` JSON DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


--
-- OAuth2 framework tables
-- Thanks to https://github.com/dsquier/oauth2-server-php-mysql repo
--

--
-- Table structure for table `oauth_clients`
--
CREATE TABLE IF NOT EXISTS `oauth_clients` (
`client_id` VARCHAR(80) NOT NULL,
`client_secret` VARCHAR(80) DEFAULT NULL,
`redirect_uri` VARCHAR(2000) DEFAULT NULL,
`grant_types` VARCHAR(80) DEFAULT NULL,
`scope` VARCHAR(4000) DEFAULT NULL,
`user_id` VARCHAR(80) DEFAULT NULL,
PRIMARY KEY (`client_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_access_tokens`
--
CREATE TABLE IF NOT EXISTS `oauth_access_tokens` (
`access_token` VARCHAR(40) NOT NULL,
`client_id` VARCHAR(80) DEFAULT NULL,
`user_id` VARCHAR(80) DEFAULT NULL,
`expires` TIMESTAMP NOT NULL,
`scope` VARCHAR(4000) DEFAULT NULL,
PRIMARY KEY (`access_token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_authorization_codes`
--
CREATE TABLE IF NOT EXISTS `oauth_authorization_codes` (
`authorization_code` VARCHAR(40) NOT NULL,
`client_id` VARCHAR(80) DEFAULT NULL,
`user_id` VARCHAR(80) DEFAULT NULL,
`redirect_uri` VARCHAR(2000) NOT NULL,
`expires` TIMESTAMP NOT NULL,
`scope` VARCHAR(4000) DEFAULT NULL,
`id_token` VARCHAR(1000) DEFAULT NULL,
PRIMARY KEY (`authorization_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_refresh_tokens`
--
CREATE TABLE IF NOT EXISTS `oauth_refresh_tokens` (
`refresh_token` VARCHAR(40) NOT NULL,
`client_id` VARCHAR(80) DEFAULT NULL,
`user_id` VARCHAR(80) DEFAULT NULL,
`expires` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`scope` VARCHAR(4000) DEFAULT NULL,
PRIMARY KEY (`refresh_token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_users`
--
CREATE TABLE IF NOT EXISTS `oauth_users` (
`username` VARCHAR(80) DEFAULT NULL,
`password` VARCHAR(255) DEFAULT NULL,
`first_name` VARCHAR(80) DEFAULT NULL,
`last_name` VARCHAR(80) DEFAULT NULL,
`email` VARCHAR(2000) DEFAULT NULL,
`email_verified` TINYINT(1) DEFAULT NULL,
`scope` VARCHAR(4000) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_scopes`
--
CREATE TABLE IF NOT EXISTS `oauth_scopes` (
`scope` VARCHAR(80) NOT NULL,
`is_default` TINYINT(1) DEFAULT NULL,
PRIMARY KEY (`scope`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_jwt`
--
CREATE TABLE IF NOT EXISTS `oauth_jwt` (
`client_id` VARCHAR(80) NOT NULL,
`subject` VARCHAR(80) DEFAULT NULL,
`public_key` VARCHAR(2000) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_jti`
--
CREATE TABLE IF NOT EXISTS `oauth_jti` (
`issuer` VARCHAR(80) NOT NULL,
`subject` VARCHAR(80) DEFAULT NULL,
`audiance` VARCHAR(80) DEFAULT NULL,
`expires` TIMESTAMP NOT NULL,
`jti` VARCHAR(2000) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `oauth_public_keys`
--
CREATE TABLE IF NOT EXISTS `oauth_public_keys` (
`client_id` VARCHAR(80) DEFAULT NULL,
`public_key` VARCHAR(2000) DEFAULT NULL,
`private_key` VARCHAR(2000) DEFAULT NULL,
`encryption_algorithm` VARCHAR(100) DEFAULT 'RS256'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;