/
queries.go
60 lines (56 loc) · 3.01 KB
/
queries.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package sqlite
const (
clientCreateTableQuery = `CREATE TABLE IF NOT EXISTS "client" (
"id" INTEGER NOT NULL UNIQUE,
"client_id" TEXT NOT NULL UNIQUE,
"client_secret" TEXT NOT NULL,
"confidential" NUMERIC NOT NULL DEFAULT 0,
"app_name" TEXT NOT NULL,
"redirect_urls" TEXT NOT NULL,
PRIMARY KEY("id" AUTOINCREMENT)
)`
clientSelectQuery = `SELECT client_id, client_secret, confidential, app_name, redirect_urls FROM client WHERE client_id = ?`
clientInsertQuery = `INSERT INTO client (client_id, client_secret, confidential, app_name, redirect_urls) VALUES(?, ?, ?, ?, ?)`
clientUpdateQuery = `UPDATE client SET client_secret = ?, confidential = ?, app_name = ?, redirect_urls = ? WHERE client_id = ?`
clientDeleteQuery = `DELETE FROM client WHERE client_id = ?`
sessionCreateTableQuery = `CREATE TABLE IF NOT EXISTS "session" (
"id" INTEGER NOT NULL UNIQUE,
"session_id" TEXT NOT NULL UNIQUE,
"user_id" NUMERIC NOT NULL,
"expires" TEXT NOT NULL,
PRIMARY KEY("id" AUTOINCREMENT)
)`
sessionSelectQuery = `SELECT session_id, user_id, expires FROM session WHERE session_id = ?`
sessionInsertQuery = `INSERT INTO session (session_id, user_id, expires) VALUES(?, ?, ?)`
sessionDeleteQuery = `DELETE FROM session WHERE session_id = ?`
tokenCreateTableQuery = `CREATE TABLE IF NOT EXISTS "token" (
"id" INTEGER NOT NULL UNIQUE,
"client_id" TEXT NOT NULL UNIQUE,
"access_token" TEXT NOT NULL,
"token_type" TEXT NOT NULL,
"expires_in" numeric NOT NULL,
"refresh_token" TEXT NOT NULL,
"scope" TEXT NOT NULL,
"state" TEXT NOT NULL,
"code_challenge" TEXT NOT NULL,
"authorization_code" TEXT NOT NULL,
PRIMARY KEY("id" AUTOINCREMENT)
)`
tokenSelectByAccessTokenQuery = `SELECT client_id, access_token, token_type, expires_in, refresh_token, scope, state, code_challenge, authorization_code FROM token WHERE access_token = ?`
tokenSelectByCodeChallengeQuery = `SELECT client_id, access_token, token_type, expires_in, refresh_token, scope, state, code_challenge, authorization_code FROM token WHERE code_challenge = ?`
tokenInsertQuery = `INSERT INTO token (client_id, access_token, token_type, expires_in, refresh_token, scope, state, code_challenge, authorization_code) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)`
tokenDeleteQuery = `DELETE FROM token WHERE access_token = ?`
userCreateTableQuery = `CREATE TABLE IF NOT EXISTS "user" (
"id" INTEGER NOT NULL,
"username" TEXT NOT NULL UNIQUE,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"disabled" NUMERIC NOT NULL,
PRIMARY KEY("id" AUTOINCREMENT)
);`
userSelectQuery = `SELECT id, username, email, password, disabled FROM user WHERE id = ?`
userSelectByUsernameQuery = `SELECT id, username, email, password, disabled FROM user WHERE username = ?`
userInsertQuery = `INSERT INTO user (username, email, password, disabled) VALUES(?, ?, ?, ?)`
userUpdateQuery = `UPDATE user SET username = ?, email = ?, password = ?, disabled = ? WHERE id = ?`
userDeleteQuery = `DELETE FROM user WHERE id = ?`
)