Skip to content

Commit

Permalink
NET-382: enable persistent SolarUser HTTP sessions using JDBC.
Browse files Browse the repository at this point in the history
  • Loading branch information
msqr committed Jun 21, 2024
1 parent 3f40ec3 commit 279c784
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions solarnet-db-setup/postgres/updates/NET-382-http-sessions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* HTTP session state information.
*/
CREATE TABLE solaruser.http_session (
PRIMARY_ID CHAR(36) NOT NULL,
SESSION_ID CHAR(36) NOT NULL,
CREATION_TIME BIGINT NOT NULL,
LAST_ACCESS_TIME BIGINT NOT NULL,
MAX_INACTIVE_INTERVAL INT NOT NULL,
EXPIRY_TIME BIGINT NOT NULL,
PRINCIPAL_NAME VARCHAR(100),
CONSTRAINT http_session_pk PRIMARY KEY (PRIMARY_ID),
CONSTRAINT http_session_session_unq UNIQUE (SESSION_ID)
);

CREATE INDEX http_session_exp_idx ON solaruser.http_session (EXPIRY_TIME);
CREATE INDEX http_session_principal_idx ON solaruser.http_session (PRINCIPAL_NAME);

/**
* HTTP session state attribute information.
*/
CREATE TABLE solaruser.http_session_attributes (
SESSION_PRIMARY_ID CHAR(36) NOT NULL,
ATTRIBUTE_NAME VARCHAR(200) NOT NULL,
ATTRIBUTE_BYTES BYTEA NOT NULL,
CONSTRAINT http_session_attributes_pk PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME),
CONSTRAINT http_session_attributes_http_session_fk FOREIGN KEY (SESSION_PRIMARY_ID)
REFERENCES solaruser.http_session(PRIMARY_ID) ON DELETE CASCADE
);
1 change: 1 addition & 0 deletions solarnet/solaruser/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.session:spring-session-jdbc'
implementation 'org.springframework.webflow:spring-webflow:3.0.0'
implementation "org.mybatis.spring.boot:mybatis-spring-boot-starter:${myBatisStarterVersion}"

Expand Down
3 changes: 3 additions & 0 deletions solarnet/solaruser/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ spring:
max-request-size: "256MB"
location: ""
file-size-threshold: "1MB"
session.jdbc:
initialize-schema: "never"
table-name: "solaruser.http_session"

---
spring:
Expand Down

0 comments on commit 279c784

Please sign in to comment.