-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05_OAuth_Authentication.sql
More file actions
38 lines (34 loc) · 1.36 KB
/
05_OAuth_Authentication.sql
File metadata and controls
38 lines (34 loc) · 1.36 KB
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
CREATE TABLE oidc_issuer
(
oidc_issuer_id BIGINT NOT NULL AUTO_INCREMENT,
issuer_name VARCHAR(255) NOT NULL, /* I.e. "google" */
oidc_well_known_url VARCHAR(255) NOT NULL,
oauth_client_id VARCHAR(255) NOT NULL,
oauth_client_secret VARCHAR(255) NOT NULL,
metadata JSON NULL,
PRIMARY KEY (oidc_issuer_id),
UNIQUE (issuer_name)
);
CREATE TABLE oauth_challenge_storage
(
oauth_challenge_storage_id BIGINT NOT NULL AUTO_INCREMENT,
code_parameter VARCHAR(255) NOT NULL,
code_verifier VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL,
oidc_issuer_id BIGINT NOT NULL,
PRIMARY KEY (oauth_challenge_storage_id),
FOREIGN KEY (oidc_issuer_id) REFERENCES oidc_issuer (oidc_issuer_id)
);
CREATE TABLE oidc_connection
(
oidc_connection_id BIGINT NOT NULL AUTO_INCREMENT,
oidc_issuer_id BIGINT NOT NULL,
oidc_subject VARCHAR(255) NOT NULL, /* Stored in the "sub" claim of the JWT */
library_user_id INT NOT NULL,
FOREIGN KEY (library_user_id) REFERENCES library_user (id),
FOREIGN KEY (oidc_issuer_id) REFERENCES oidc_issuer (oidc_issuer_id),
PRIMARY KEY (oidc_connection_id)
);
/* Drop the NOT NULL */
ALTER TABLE library_user
MODIFY COLUMN passw VARCHAR(150);