mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-20 23:23:35 +00:00
Add support for launcher login via tokens and file verification
Added code to LoginActor to handle client authentication via login token Added code to LoginActor to generate the password used by the launcher to authenticate with the API Changed code in LoginActor to replace deprecated bcrypt functions Changed code in Account to add the field password, token and tokenCreated Added database migration V009 containing table changes on account, new tables launcher and filehash and a trigger/function combo to update the tokenCreated column.
This commit is contained in:
parent
663cfdc90a
commit
7f792d63d4
3 changed files with 264 additions and 9 deletions
35
server/src/main/resources/db/migration/V009__TokenLogin.sql
Normal file
35
server/src/main/resources/db/migration/V009__TokenLogin.sql
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
ALTER TABLE "account"
|
||||
ADD COLUMN IF NOT EXISTS "password" VARCHAR(60) NOT NULL DEFAULT '',
|
||||
ADD COLUMN IF NOT EXISTS "token" VARCHAR(31) NULL UNIQUE,
|
||||
ADD COLUMN IF NOT EXISTS "token_created" TIMESTAMP NULL;
|
||||
|
||||
CREATE OR REPLACE FUNCTION fn_set_token_created_timestamp()
|
||||
RETURNS trigger
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
NEW."token_created" = NOW();
|
||||
RETURN NEW;
|
||||
END;
|
||||
$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE TRIGGER trigger_accounts_set_token_created
|
||||
BEFORE UPDATE
|
||||
OF "token" ON "account"
|
||||
FOR EACH ROW EXECUTE FUNCTION fn_set_token_created_timestamp();
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "launcher" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"version" TEXT NOT NULL UNIQUE,
|
||||
"released_at" TIMESTAMPTZ NOT NULL,
|
||||
"hash" TEXT NOT NULL,
|
||||
"active" BOOL NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "filehash" (
|
||||
"mode" INT NOT NULL DEFAULT 0,
|
||||
"file" TEXT NOT NULL,
|
||||
"hash" TEXT NOT NULL,
|
||||
CONSTRAINT "filehash_mode_file_key" UNIQUE ("mode", "file")
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue