Skip to content
Snippets Groups Projects
Commit cec8d3f1 authored by Gabriel Zachmann's avatar Gabriel Zachmann
Browse files

fix dbmigration issues

parent b8204f4b
No related branches found
No related tags found
No related merge requests found
/*!40101 SET @OLD_CHARACTER_SET_CLIENT = @@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS = @@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION = @@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE = @@TIME_ZONE */;
/*!40103 SET TIME_ZONE = '+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS = @@UNIQUE_CHECKS, UNIQUE_CHECKS = 0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS = @@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0 */;
/*!40101 SET @OLD_SQL_MODE = @@SQL_MODE, SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES = @@SQL_NOTES, SQL_NOTES = 0 */;
-- Table structure for table `AT_Attributes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `AT_Attributes`
(
`AT_id` bigint(20) unsigned NOT NULL,
......@@ -23,11 +12,7 @@ CREATE TABLE IF NOT EXISTS `AT_Attributes`
CONSTRAINT `AT_Attributes_FK_1` FOREIGN KEY (`attribute_id`) REFERENCES `Attributes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `AccessTokens`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `AccessTokens`
(
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
......@@ -40,13 +25,8 @@ CREATE TABLE IF NOT EXISTS `AccessTokens`
KEY `AccessTokens_FK` (`MT_id`),
CONSTRAINT `AccessTokens_FK` FOREIGN KEY (`MT_id`) REFERENCES `MTokens` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `Attributes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `Attributes`
(
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
......@@ -54,13 +34,8 @@ CREATE TABLE IF NOT EXISTS `Attributes`
PRIMARY KEY (`id`),
UNIQUE KEY `Attributes_UN` (`attribute`)
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `AuthInfo`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `AuthInfo`
(
`state_h` varchar(128) NOT NULL,
......@@ -76,11 +51,7 @@ CREATE TABLE IF NOT EXISTS `AuthInfo`
PRIMARY KEY (`state_h`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `EncryptionKeys`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `EncryptionKeys`
(
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
......@@ -88,27 +59,8 @@ CREATE TABLE IF NOT EXISTS `EncryptionKeys`
`created` datetime NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Temporary table structure for view `EventHistory`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE IF NOT EXISTS `EventHistory`
(
`time` tinyint NOT NULL,
`MT_id` tinyint NOT NULL,
`event` tinyint NOT NULL,
`comment` tinyint NOT NULL,
`ip` tinyint NOT NULL,
`user_agent` tinyint NOT NULL
) ENGINE = MyISAM */;
SET character_set_client = @saved_cs_client;
-- Table structure for table `Events`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `Events`
(
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
......@@ -116,13 +68,8 @@ CREATE TABLE IF NOT EXISTS `Events`
PRIMARY KEY (`id`),
UNIQUE KEY `Events_UN` (`event`)
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `Grants`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `Grants`
(
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
......@@ -130,13 +77,8 @@ CREATE TABLE IF NOT EXISTS `Grants`
PRIMARY KEY (`id`),
UNIQUE KEY `Grants_UN` (`grant_type`)
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `MT_Events`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `MT_Events`
(
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
......@@ -152,13 +94,8 @@ CREATE TABLE IF NOT EXISTS `MT_Events`
CONSTRAINT `MT_Events_FK_2` FOREIGN KEY (`MT_id`) REFERENCES `MTokens` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `MT_Events_FK_3` FOREIGN KEY (`event_id`) REFERENCES `Events` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `MTokens`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `MTokens`
(
`id` varchar(128) NOT NULL,
......@@ -182,44 +119,7 @@ CREATE TABLE IF NOT EXISTS `MTokens`
CONSTRAINT `Mytokens_FK_3` FOREIGN KEY (`rt_id`) REFERENCES `RefreshTokens` (`id`) ON UPDATE CASCADE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */;
/*!50003 SET @saved_cs_results = @@character_set_results */;
/*!50003 SET @saved_col_connection = @@collation_connection */;
/*!50003 SET character_set_client = utf8mb4 */;
/*!50003 SET character_set_results = utf8mb4 */;
/*!50003 SET collation_connection = utf8mb4_general_ci */;
/*!50003 SET @saved_sql_mode = @@sql_mode */;
/*!50003 SET sql_mode =
'IGNORE_SPACE,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */;
/*!50003 SET sql_mode = @saved_sql_mode */;
/*!50003 SET character_set_client = @saved_cs_client */;
/*!50003 SET character_set_results = @saved_cs_results */;
/*!50003 SET collation_connection = @saved_col_connection */;
-- Temporary table structure for view `MyTokens`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE IF NOT EXISTS `MyTokens`
(
`id` tinyint NOT NULL,
`seqno` tinyint NOT NULL,
`parent_id` tinyint NOT NULL,
`root_id` tinyint NOT NULL,
`name` tinyint NOT NULL,
`created` tinyint NOT NULL,
`ip_created` tinyint NOT NULL,
`user_id` tinyint NOT NULL,
`rt_id` tinyint NOT NULL,
`refresh_token` tinyint NOT NULL,
`rt_updated` tinyint NOT NULL,
`encryption_key` tinyint NOT NULL
) ENGINE = MyISAM */;
SET character_set_client = @saved_cs_client;
-- Table structure for table `ProxyTokens`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `ProxyTokens`
(
`id` varchar(128) NOT NULL,
......@@ -230,11 +130,7 @@ CREATE TABLE IF NOT EXISTS `ProxyTokens`
CONSTRAINT `ProxyTokens_FK` FOREIGN KEY (`MT_id`) REFERENCES `MTokens` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `RT_EncryptionKeys`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `RT_EncryptionKeys`
(
`rt_id` bigint(20) unsigned NOT NULL,
......@@ -247,11 +143,7 @@ CREATE TABLE IF NOT EXISTS `RT_EncryptionKeys`
CONSTRAINT `RT_EncryptionKeys_FK_2` FOREIGN KEY (`MT_id`) REFERENCES `MTokens` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `RefreshTokens`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `RefreshTokens`
(
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
......@@ -260,13 +152,8 @@ CREATE TABLE IF NOT EXISTS `RefreshTokens`
`updated` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `TokenUsages`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `TokenUsages`
(
`MT_id` varchar(128) NOT NULL,
......@@ -278,27 +165,7 @@ CREATE TABLE IF NOT EXISTS `TokenUsages`
CONSTRAINT `TokenUsages_FK` FOREIGN KEY (`MT_id`) REFERENCES `MTokens` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Temporary table structure for view `TransferCodes`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE IF NOT EXISTS `TransferCodes`
(
`id` tinyint NOT NULL,
`jwt` tinyint NOT NULL,
`created` tinyint NOT NULL,
`expires_in` tinyint NOT NULL,
`expires_at` tinyint NOT NULL,
`revoke_MT` tinyint NOT NULL,
`response_type` tinyint NOT NULL,
`consent_declined` tinyint NOT NULL
) ENGINE = MyISAM */;
SET character_set_client = @saved_cs_client;
-- Table structure for table `TransferCodesAttributes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `TransferCodesAttributes`
(
`id` varchar(128) NOT NULL,
......@@ -312,11 +179,7 @@ CREATE TABLE IF NOT EXISTS `TransferCodesAttributes`
CONSTRAINT `TransferCodesAttributes_FK` FOREIGN KEY (`id`) REFERENCES `ProxyTokens` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `UserGrant_Attributes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `UserGrant_Attributes`
(
`user_id` bigint(20) unsigned NOT NULL,
......@@ -331,11 +194,7 @@ CREATE TABLE IF NOT EXISTS `UserGrant_Attributes`
CONSTRAINT `UserGrant_Attributes_FK_3` FOREIGN KEY (`attribute_id`) REFERENCES `Attributes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `UserGrants`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `UserGrants`
(
`user_id` bigint(20) unsigned NOT NULL,
......@@ -347,11 +206,7 @@ CREATE TABLE IF NOT EXISTS `UserGrants`
CONSTRAINT `UserGrants_FK_1` FOREIGN KEY (`user_id`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `Users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `Users`
(
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
......@@ -362,11 +217,8 @@ CREATE TABLE IF NOT EXISTS `Users`
PRIMARY KEY (`id`),
UNIQUE KEY `Users_UN` (`sub`, `iss`)
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Table structure for table `version`;
CREATE TABLE IF NOT EXISTS `version`
(
`version` varchar(64) NOT NULL,
......@@ -376,41 +228,19 @@ CREATE TABLE IF NOT EXISTS `version`
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
-- Final view structure for view `EventHistory`;
/*!50001 DROP TABLE IF EXISTS `EventHistory`*/;;
/*!50001 DROP VIEW IF EXISTS `EventHistory`*/;;
/*!50001 SET @saved_cs_client = @@character_set_client */;;
/*!50001 SET @saved_cs_results = @@character_set_results */;;
/*!50001 SET @saved_col_connection = @@collation_connection */;;
/*!50001 SET character_set_client = utf8mb4 */;;
/*!50001 SET character_set_results = utf8mb4 */;;
/*!50001 SET collation_connection = utf8mb4_general_ci */;;
/*!50001 CREATE ALGORITHM = UNDEFINED */ /*!50001 VIEW `EventHistory` AS
select `me`.`time` AS `time`,
CREATE OR REPLACE ALGORITHM = UNDEFINED VIEW `EventHistory` AS
SELECT `me`.`time` AS `time`,
`me`.`MT_id` AS `MT_id`,
`e`.`event` AS `event`,
`me`.`comment` AS `comment`,
`me`.`ip` AS `ip`,
`me`.`user_agent` AS `user_agent`
from (`Events` `e`
join `MT_Events` `me` on (`e`.`id` = `me`.`event_id`))
order by `me`.`time`
*/;;
/*!50001 SET character_set_client = @saved_cs_client */;;
/*!50001 SET character_set_results = @saved_cs_results */;;
/*!50001 SET collation_connection = @saved_col_connection */;
FROM (`Events` `e`
JOIN `MT_Events` `me` ON (`e`.`id` = `me`.`event_id`))
ORDER BY `me`.`time`;
-- Final view structure for view `MyTokens`;
/*!50001 DROP TABLE IF EXISTS `MyTokens`*/;;
/*!50001 DROP VIEW IF EXISTS `MyTokens`*/;;
/*!50001 SET @saved_cs_client = @@character_set_client */;;
/*!50001 SET @saved_cs_results = @@character_set_results */;;
/*!50001 SET @saved_col_connection = @@collation_connection */;;
/*!50001 SET character_set_client = utf8mb4 */;;
/*!50001 SET character_set_results = utf8mb4 */;;
/*!50001 SET collation_connection = utf8mb4_general_ci */;;
/*!50001 CREATE ALGORITHM = UNDEFINED */ /*!50001 VIEW `MyTokens` AS
select `mt`.`id` AS `id`,
CREATE OR REPLACE ALGORITHM = UNDEFINED VIEW `MyTokens` AS
SELECT `mt`.`id` AS `id`,
`mt`.`seqno` AS `seqno`,
`mt`.`parent_id` AS `parent_id`,
`mt`.`root_id` AS `root_id`,
......@@ -422,24 +252,11 @@ select `mt`.`id` AS `id`,
`rts`.`rt` AS `refresh_token`,
`rts`.`updated` AS `rt_updated`,
`keys`.`encryption_key` AS `encryption_key`
from (((`MTokens` `mt` join `RefreshTokens` `rts` on (`mt`.`rt_id` = `rts`.`id`)) join `RT_EncryptionKeys` `rkeys` on (`mt`.`id` = `rkeys`.`MT_id` and `mt`.`rt_id` = `rkeys`.`rt_id`))
join `EncryptionKeys` `keys` on (`rkeys`.`key_id` = `keys`.`id`))
*/;;
/*!50001 SET character_set_client = @saved_cs_client */;;
/*!50001 SET character_set_results = @saved_cs_results */;;
/*!50001 SET collation_connection = @saved_col_connection */;
FROM (((`MTokens` `mt` JOIN `RefreshTokens` `rts` ON (`mt`.`rt_id` = `rts`.`id`)) JOIN `RT_EncryptionKeys` `rkeys` ON (`mt`.`id` = `rkeys`.`MT_id` AND `mt`.`rt_id` = `rkeys`.`rt_id`))
JOIN `EncryptionKeys` `keys` ON (`rkeys`.`key_id` = `keys`.`id`));
-- Final view structure for view `TransferCodes`;
/*!50001 DROP TABLE IF EXISTS `TransferCodes`*/;;
/*!50001 DROP VIEW IF EXISTS `TransferCodes`*/;;
/*!50001 SET @saved_cs_client = @@character_set_client */;;
/*!50001 SET @saved_cs_results = @@character_set_results */;;
/*!50001 SET @saved_col_connection = @@collation_connection */;;
/*!50001 SET character_set_client = utf8mb4 */;;
/*!50001 SET character_set_results = utf8mb4 */;;
/*!50001 SET collation_connection = utf8mb4_general_ci */;;
/*!50001 CREATE ALGORITHM = UNDEFINED */ /*!50001 VIEW `TransferCodes` AS
select `pt`.`id` AS `id`,
CREATE OR REPLACE ALGORITHM = UNDEFINED VIEW `TransferCodes` AS
SELECT `pt`.`id` AS `id`,
`pt`.`jwt` AS `jwt`,
`tca`.`created` AS `created`,
`tca`.`expires_in` AS `expires_in`,
......@@ -447,28 +264,16 @@ select `pt`.`id` AS `id`,
`tca`.`revoke_MT` AS `revoke_MT`,
`tca`.`response_type` AS `response_type`,
`tca`.`consent_declined` AS `consent_declined`
from (`ProxyTokens` `pt`
join `TransferCodesAttributes` `tca` on (`pt`.`id` = `tca`.`id`))
*/;;
/*!50001 SET character_set_client = @saved_cs_client */;;
/*!50001 SET character_set_results = @saved_cs_results */;;
/*!50001 SET collation_connection = @saved_col_connection */;;
/*!40103 SET TIME_ZONE = @OLD_TIME_ZONE */;;
/*!40101 SET SQL_MODE = @OLD_SQL_MODE */;;
/*!40014 SET FOREIGN_KEY_CHECKS = @OLD_FOREIGN_KEY_CHECKS */;;
/*!40014 SET UNIQUE_CHECKS = @OLD_UNIQUE_CHECKS */;;
/*!40101 SET CHARACTER_SET_CLIENT = @OLD_CHARACTER_SET_CLIENT */;;
/*!40101 SET CHARACTER_SET_RESULTS = @OLD_CHARACTER_SET_RESULTS */;;
/*!40101 SET COLLATION_CONNECTION = @OLD_COLLATION_CONNECTION */;;
/*!40111 SET SQL_NOTES = @OLD_SQL_NOTES */;
FROM (`ProxyTokens` `pt`
JOIN `TransferCodesAttributes` `tca` ON (`pt`.`id` = `tca`.`id`));
# Predefined Values
INSERT IGNORE INTO Attributes(attribute)
VALUES ('scope');
VALUES ('scope');
INSERT IGNORE INTO Attributes(attribute)
VALUES ('audience');
VALUES ('audience');
INSERT IGNORE INTO Attributes(attribute)
VALUES ('capability');
VALUES ('capability');
INSERT IGNORE INTO Events (event)
VALUES ('unknown');
......
......@@ -4,52 +4,51 @@
DROP VIEW IF EXISTS MyTokens;
ALTER TABLE MTokens
DROP FOREIGN KEY Mytokens_FK_1;
DROP FOREIGN KEY IF EXISTS Mytokens_FK_1;
ALTER TABLE MTokens
DROP COLUMN root_id;
DROP COLUMN IF EXISTS root_id;
ALTER TABLE MTokens
ADD expires_at DATETIME NULL;
ADD IF NOT EXISTS expires_at DATETIME NULL;
ALTER TABLE Users
DROP COLUMN token_tracing;
DROP COLUMN IF EXISTS token_tracing;
ALTER TABLE Users
DROP COLUMN jwt_pk;
DROP COLUMN IF EXISTS jwt_pk;
ALTER TABLE TransferCodesAttributes
ADD ssh_key_fp VARCHAR(128) NULL;
ADD IF NOT EXISTS ssh_key_fp VARCHAR(128) NULL;
TRUNCATE TABLE AuthInfo;
ALTER TABLE AuthInfo
ADD request_json JSON NOT NULL;
ADD IF NOT EXISTS request_json JSON NOT NULL;
ALTER TABLE AuthInfo
DROP COLUMN iss;
DROP COLUMN IF EXISTS iss;
ALTER TABLE AuthInfo
DROP COLUMN restrictions;
DROP COLUMN IF EXISTS restrictions;
ALTER TABLE AuthInfo
DROP COLUMN capabilities;
DROP COLUMN IF EXISTS capabilities;
ALTER TABLE AuthInfo
DROP COLUMN name;
DROP COLUMN IF EXISTS name;
ALTER TABLE AuthInfo
DROP COLUMN subtoken_capabilities;
DROP COLUMN IF EXISTS subtoken_capabilities;
ALTER TABLE AuthInfo
DROP COLUMN rotation;
DROP COLUMN IF EXISTS rotation;
ALTER TABLE AuthInfo
DROP COLUMN response_type;
DROP COLUMN IF EXISTS response_type;
ALTER TABLE AuthInfo
DROP COLUMN max_token_len;
DROP COLUMN IF EXISTS max_token_len;
# CryptStore
CREATE TABLE `CryptPayloadTypes`
CREATE TABLE IF NOT EXISTS `CryptPayloadTypes`
(
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`payload_type` VARCHAR(128) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `CryptPayloadTypes_UN` (`payload_type`)
) ENGINE = InnoDB
AUTO_INCREMENT = 4
DEFAULT CHARSET = utf8mb4;
RENAME TABLE RefreshTokens TO CryptStore;
RENAME TABLE IF EXISTS RefreshTokens TO CryptStore;
ALTER TABLE CryptStore
CHANGE rt crypt TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
ALTER TABLE CryptStore
......@@ -150,7 +149,7 @@ SELECT `CryptStore`.`id` AS `id`,
WHERE `CryptPayloadTypes`.`payload_type` = 'MT');
-- SSHPublicKeys definition
CREATE TABLE SSHPublicKeys
CREATE TABLE IF NOT EXISTS SSHPublicKeys
(
user BIGINT UNSIGNED NOT NULL,
ssh_key_fp VARCHAR(128) NOT NULL,
......@@ -166,16 +165,17 @@ CREATE TABLE SSHPublicKeys
UNIQUE (key_id),
CONSTRAINT ssh_pub_keys_UN_1
UNIQUE (ssh_user_hash),
CONSTRAINT SSHPublicKeys_FK
CONSTRAINT ssh_pub_keys_FK
FOREIGN KEY (MT_id) REFERENCES MTokens (id)
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT ssh_pub_keys_FK
CONSTRAINT ssh_pub_keys_FK_1
FOREIGN KEY (user) REFERENCES Users (id)
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT ssh_pub_keys_FK_1
CONSTRAINT ssh_pub_keys_FK_2
FOREIGN KEY (MT_crypt) REFERENCES CryptStore (id)
ON UPDATE CASCADE ON DELETE CASCADE
);
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
# Procedures
DELIMITER ;;
......@@ -192,10 +192,10 @@ BEGIN
SELECT LAST_INSERT_ID();
END;;
CREATE FUNCTION AddToCryptStore(CRYPT_ TEXT, PAYLOAD_T INT UNSIGNED) RETURNS BIGINT UNSIGNED
CREATE OR REPLACE PROCEDURE AddToCryptStore(CRYPT_ TEXT, PAYLOAD_T INT UNSIGNED, OUT ID BIGINT UNSIGNED)
BEGIN
INSERT INTO CryptStore (crypt, payload_type) VALUES (CRYPT_, PAYLOAD_T);
RETURN LAST_INSERT_ID();
SET ID = LAST_INSERT_ID();
END;;
CREATE OR REPLACE PROCEDURE AuthInfo_Delete(IN STATE TEXT)
......@@ -271,14 +271,14 @@ END;;
CREATE OR REPLACE PROCEDURE CryptStoreAT_Insert(IN EncryptedAT TEXT, OUT ID BIGINT UNSIGNED)
BEGIN
SET ID = (SELECT AddToCryptStore(EncryptedAT,
(SELECT cpt.id FROM CryptPayloadTypes cpt WHERE cpt.payload_type = 'AT')));
CALL AddToCryptStore(EncryptedAT,
(SELECT cpt.id FROM CryptPayloadTypes cpt WHERE cpt.payload_type = 'AT'), ID);
END;;
CREATE OR REPLACE PROCEDURE CryptStoreMT_Insert(IN EncryptedMT TEXT, OUT ID BIGINT UNSIGNED)
BEGIN
SET ID = (SELECT AddToCryptStore(EncryptedMT,
(SELECT cpt.id FROM CryptPayloadTypes cpt WHERE cpt.payload_type = 'MT')));
CALL AddToCryptStore(EncryptedMT,
(SELECT cpt.id FROM CryptPayloadTypes cpt WHERE cpt.payload_type = 'MT'), ID);
END;;
CREATE OR REPLACE PROCEDURE CryptStoreRT_Get(IN MTID VARCHAR(128))
......@@ -288,8 +288,8 @@ END;;
CREATE OR REPLACE PROCEDURE CryptStoreRT_Insert(IN EncryptedRT TEXT, OUT ID BIGINT UNSIGNED)
BEGIN
SET ID = (SELECT AddToCryptStore(EncryptedRT,
(SELECT cpt.id FROM CryptPayloadTypes cpt WHERE cpt.payload_type = 'RT')));
CALL AddToCryptStore(EncryptedRT,
(SELECT cpt.id FROM CryptPayloadTypes cpt WHERE cpt.payload_type = 'RT'), ID);
END;;
CREATE OR REPLACE PROCEDURE CryptStore_Delete(IN CRYPTID BIGINT UNSIGNED)
......@@ -709,9 +709,9 @@ INSERT IGNORE INTO CryptPayloadTypes (payload_type)
VALUES ('MT');
INSERT IGNORE INTO Events (event)
VALUES ('settings_grant_enable');
VALUES ('settings_grant_enabled');
INSERT IGNORE INTO Events (event)
VALUES ('settings_grant_disable');
VALUES ('settings_grant_disabled');
INSERT IGNORE INTO Events (event)
VALUES ('settings_grants_listed');
INSERT IGNORE INTO Events (event)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment