[MM-37984] Allow Desktop App to authenticate via external providers outside of the app on supported servers (#24140)

* [MM-37984] Allow Desktop App to authenticate via external providers outside of the app on supported servers

* PR feedback

* Add support for mattermost-dev protocol for development use

* Update server/channels/db/migrations/postgres/000110_create_desktop_tokens.up.sql

* Fix silly typo

* Update server/channels/db/migrations/postgres/000110_create_desktop_tokens.up.sql

* Remove storage of client token, only validate it on the client

* Update migrations

* Add concurrently create index

* Remove CONCURRENTLY for now

* Fix issue with changing history

* Remove old migration

* Use idempotent statement to drop old index

* Remove reference to old table
Этот коммит содержится в:
Devin Binnie
2023-08-30 11:21:43 -04:00
коммит произвёл GitHub
родитель 105fa4a195
Коммит a3b194581f
41 изменённых файлов: 1569 добавлений и 24 удалений

Просмотреть файл

@@ -220,6 +220,8 @@ channels/db/migrations/mysql/000109_create_persistent_notifications.down.sql
channels/db/migrations/mysql/000109_create_persistent_notifications.up.sql
channels/db/migrations/mysql/000111_update_vacuuming.down.sql
channels/db/migrations/mysql/000111_update_vacuuming.up.sql
channels/db/migrations/mysql/000112_rework_desktop_tokens.down.sql
channels/db/migrations/mysql/000112_rework_desktop_tokens.up.sql
channels/db/migrations/postgres/000001_create_teams.down.sql
channels/db/migrations/postgres/000001_create_teams.up.sql
channels/db/migrations/postgres/000002_create_team_members.down.sql
@@ -440,3 +442,5 @@ channels/db/migrations/postgres/000109_create_persistent_notifications.down.sql
channels/db/migrations/postgres/000109_create_persistent_notifications.up.sql
channels/db/migrations/postgres/000111_update_vacuuming.down.sql
channels/db/migrations/postgres/000111_update_vacuuming.up.sql
channels/db/migrations/postgres/000112_rework_desktop_tokens.down.sql
channels/db/migrations/postgres/000112_rework_desktop_tokens.up.sql

Просмотреть файл

@@ -0,0 +1,16 @@
SET @preparedStatement = (SELECT IF(
(
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_name = 'DesktopTokens'
AND table_schema = DATABASE()
AND index_name = 'idx_desktoptokens_createat'
) > 0,
'DROP INDEX idx_desktoptokens_createat ON DesktopTokens;',
'SELECT 1'
));
PREPARE removeIndexIfExists FROM @preparedStatement;
EXECUTE removeIndexIfExists;
DEALLOCATE PREPARE removeIndexIfExists;
DROP TABLE IF EXISTS DesktopTokens;

Просмотреть файл

@@ -0,0 +1,38 @@
SET @preparedStatement = (SELECT IF(
(
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_name = 'DesktopTokens'
AND table_schema = DATABASE()
AND index_name = 'idx_desktoptokens_createat'
) > 0,
'DROP INDEX idx_desktoptokens_createat ON DesktopTokens;',
'SELECT 1'
));
PREPARE removeIndexIfExists FROM @preparedStatement;
EXECUTE removeIndexIfExists;
DEALLOCATE PREPARE removeIndexIfExists;
DROP TABLE IF EXISTS DesktopTokens;
CREATE TABLE IF NOT EXISTS DesktopTokens (
Token varchar(64) NOT NULL,
CreateAt bigint NOT NULL,
UserId varchar(26) NOT NULL,
PRIMARY KEY (Token)
);
SET @preparedStatement = (SELECT IF(
(
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_name = 'DesktopTokens'
AND table_schema = DATABASE()
AND index_name = 'idx_desktoptokens_token_createat'
) > 0,
'SELECT 1',
'CREATE INDEX idx_desktoptokens_token_createat ON DesktopTokens(Token, CreateAt);'
));
PREPARE createIndexIfNotExists FROM @preparedStatement;
EXECUTE createIndexIfNotExists;
DEALLOCATE PREPARE createIndexIfNotExists;

Просмотреть файл

@@ -0,0 +1,2 @@
DROP INDEX IF EXISTS idx_desktoptokens_token_createat;
DROP TABLE IF EXISTS desktoptokens;

Просмотреть файл

@@ -0,0 +1,11 @@
DROP INDEX IF EXISTS idx_desktoptokens_createat;
DROP TABLE IF EXISTS desktoptokens;
CREATE TABLE IF NOT EXISTS desktoptokens (
token VARCHAR(64) NOT NULL,
createat BIGINT NOT NULL,
userid VARCHAR(26) NOT NULL,
PRIMARY KEY (token)
);
CREATE INDEX IF NOT EXISTS idx_desktoptokens_token_createat ON desktoptokens(token, createat)