- Neue Tabelle auth_tokens (tools/migration_remember_tokens.sql, idempotent, zusätzlich in tools/schema.sql): Cookie "selector.validator", in der DB nur der SHA-256-Hash des Validators. - Auth: Häkchen im Login, Token-Rotation beim Wiederherstellen (altes Token löschen, neues ausstellen), HttpOnly/SameSite=Lax/Secure-Cookie, session_regenerate_id gegen Session-Fixation. - Auth::forgetRememberTokens() entwertet alle Geräte eines Spielers; wird bei Passwortänderung durch die Administration und beim Löschen des Kontos aufgerufen. Logout löscht das Token dieses Geräts (auch ein im selben Request rotiertes). - Login-View: Checkbox "Angemeldet bleiben"; README-Abschnitt zur Einrichtung und zu den Sicherheitseigenschaften. - Geprüft in der lokalen Docker-Umgebung: Login mit/ohne Häkchen, Wiederanmeldung nur mit Remember-Cookie, Token-Rotation, Logout (0 Tokens), manipuliertes Cookie (kein Login, Token entfernt), forgetRememberTokens().
218 lines
7.4 KiB
SQL
218 lines
7.4 KiB
SQL
DROP TABLE IF EXISTS `users`;
|
|
CREATE TABLE `users` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(201) NOT NULL,
|
|
`firstname` varchar(100) DEFAULT NULL,
|
|
`lastname` varchar(100) DEFAULT NULL,
|
|
`email` varchar(150) NOT NULL,
|
|
`password` varchar(100) NOT NULL,
|
|
`iban` varchar(255) DEFAULT NULL,
|
|
`paypal` varchar(255) DEFAULT NULL,
|
|
`mobile` varchar(255) DEFAULT NULL,
|
|
`deleted` timestamp NULL DEFAULT NULL,
|
|
`admin` tinyint(1) NOT NULL DEFAULT '0',
|
|
`gets_reminders` tinyint(1) NOT NULL DEFAULT '1',
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `users_email_unique` (`email`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `tipps`;
|
|
CREATE TABLE `tipps` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`user_id` int(11) NOT NULL,
|
|
`game_id` int(11) NOT NULL,
|
|
`score1` int(11) NOT NULL,
|
|
`score2` int(11) NOT NULL,
|
|
`joker` tinyint(1) NOT NULL DEFAULT '0',
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `tipps_user_game_unique` (`user_id`, `game_id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `games`;
|
|
CREATE TABLE `games` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`round_id` int(11) NOT NULL,
|
|
`team1` varchar(100) NOT NULL,
|
|
`team1_id` int(11) DEFAULT NULL,
|
|
`team2` varchar(100) NOT NULL,
|
|
`team2_id` int(11) DEFAULT NULL,
|
|
`score1` int(11) NOT NULL DEFAULT '-1',
|
|
`score2` int(11) NOT NULL DEFAULT '-1',
|
|
`kickoff` datetime NOT NULL,
|
|
`fetcher_matched` tinyint(1) NOT NULL DEFAULT '0',
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `teams`;
|
|
CREATE TABLE `teams` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`key` varchar(64) NOT NULL,
|
|
`type` enum('club','national') NOT NULL DEFAULT 'club',
|
|
`name` varchar(100) NOT NULL,
|
|
`country` varchar(8) DEFAULT NULL,
|
|
`logo` varchar(255) DEFAULT NULL,
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `teams_key_unique` (`key`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `team_aliases`;
|
|
CREATE TABLE `team_aliases` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`team_id` int(11) NOT NULL,
|
|
`alias` varchar(128) NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `team_aliases_alias_unique` (`alias`),
|
|
KEY `team_aliases_team_id_index` (`team_id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `rounds`;
|
|
CREATE TABLE `rounds` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(64) NOT NULL,
|
|
`season_id` int(11) NOT NULL,
|
|
`report` text,
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `seasons`;
|
|
CREATE TABLE `seasons` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(100) NOT NULL,
|
|
`rounds` int(11) NOT NULL DEFAULT '36',
|
|
`max_identical_jokertipps` int(11) NOT NULL DEFAULT '6',
|
|
`jackpot` decimal(10,2) NOT NULL DEFAULT '0.00',
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `settings`;
|
|
CREATE TABLE `settings` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`current_season_id` int(11) NOT NULL,
|
|
`registration_open` tinyint(1) NOT NULL DEFAULT '1',
|
|
`message` text DEFAULT NULL,
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `payments`;
|
|
CREATE TABLE `payments` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`season_id` int(11) NOT NULL,
|
|
`user_id` int(11) NOT NULL,
|
|
`paid_date` datetime DEFAULT NULL,
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `quotas`;
|
|
CREATE TABLE `quotas` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`season_id` int(11) NOT NULL DEFAULT '0',
|
|
`name` varchar(100) NOT NULL,
|
|
`order` int(11) NOT NULL DEFAULT '0',
|
|
`prc` double NOT NULL DEFAULT '0',
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `roundmails`;
|
|
CREATE TABLE `roundmails` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`user_id` int(11) NOT NULL,
|
|
`season_id` int(11) NOT NULL DEFAULT '0',
|
|
`send_date` date NOT NULL,
|
|
`recipients` text NOT NULL,
|
|
`topic` varchar(200) NOT NULL,
|
|
`message` text NOT NULL,
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `questions`;
|
|
CREATE TABLE `questions` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`user_id` int(11) NOT NULL,
|
|
`question` text NOT NULL,
|
|
`question_date` datetime NOT NULL,
|
|
`answer` text DEFAULT NULL,
|
|
`answer_date` datetime DEFAULT NULL,
|
|
`answered_by` int(11) DEFAULT NULL,
|
|
`answer_seen` tinyint(1) NOT NULL DEFAULT '0',
|
|
`question_seen` tinyint(1) NOT NULL DEFAULT '0',
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`),
|
|
KEY `questions_user_id_index` (`user_id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `manual_payouts`;
|
|
CREATE TABLE `manual_payouts` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`season_id` int(11) NOT NULL,
|
|
`user_id` int(11) NOT NULL,
|
|
`quota_name` varchar(255) NOT NULL DEFAULT '',
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `fetcher_log`;
|
|
CREATE TABLE `fetcher_log` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`created_at` datetime NOT NULL,
|
|
`action` varchar(20) NOT NULL,
|
|
`message` varchar(255) NOT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `password_resets`;
|
|
CREATE TABLE `password_resets` (
|
|
`email` varchar(150) NOT NULL,
|
|
`token` varchar(100) NOT NULL,
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
KEY `password_resets_email_index` (`email`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `auth_tokens`;
|
|
CREATE TABLE `auth_tokens` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`user_id` int(10) unsigned NOT NULL,
|
|
`selector` char(24) NOT NULL,
|
|
`validator_hash` char(64) NOT NULL,
|
|
`created_at` datetime NOT NULL,
|
|
`expires_at` datetime NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `auth_tokens_selector_unique` (`selector`),
|
|
KEY `auth_tokens_user_id_index` (`user_id`),
|
|
KEY `auth_tokens_expires_at_index` (`expires_at`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `push_subscriptions`;
|
|
CREATE TABLE `push_subscriptions` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`user_id` int(10) unsigned NOT NULL,
|
|
`endpoint` varchar(1000) NOT NULL,
|
|
`endpoint_hash` char(64) NOT NULL,
|
|
`p256dh` varchar(120) NOT NULL,
|
|
`auth` varchar(40) NOT NULL,
|
|
`created_at` timestamp NULL DEFAULT NULL,
|
|
`updated_at` timestamp NULL DEFAULT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `push_subscriptions_endpoint_hash_unique` (`endpoint_hash`),
|
|
KEY `push_subscriptions_user_id_index` (`user_id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|