Skip to content

Commit

Permalink
Added spring-session-jdbc
Browse files Browse the repository at this point in the history
  • Loading branch information
straumat committed Jan 14, 2024
1 parent 90579ad commit 4d36c42
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#org.springframework.boot.diagnostics.FailureAnalyzer=tech.cassandre.trading.bot.util.exception.ConfigurationFailureAnalyzer
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.royllo.explorer.core.configuration.DatabaseConfiguration,\
org.royllo.explorer.core.configuration.ParametersConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ royllo.explorer.content.base-url=https://content.royllo.org
# ======================================================================================================================
# Database access configuration.
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:mem:cassandre-database;DB_CLOSE_DELAY=-1
spring.datasource.url=jdbc:hsqldb:mem:explorer-royllo-database
spring.datasource.username=sa
spring.datasource.password=
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# ======================================================================================================================
# Database access configuration.
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:mem:cassandre-database;DB_CLOSE_DELAY=-1
spring.datasource.url=jdbc:hsqldb:mem:explorer-royllo-database
spring.datasource.username=sa
spring.datasource.password=
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# ======================================================================================================================
# Database access configuration.
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:mem:cassandre-database;DB_CLOSE_DELAY=-1
spring.datasource.url=jdbc:hsqldb:mem:explorer-royllo-database
spring.datasource.username=sa
spring.datasource.password=
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# ======================================================================================================================
# Database access configuration.
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:mem:cassandre-database;DB_CLOSE_DELAY=-1
spring.datasource.url=jdbc:hsqldb:mem:explorer-royllo-database
spring.datasource.username=sa
spring.datasource.password=
#
Expand Down
4 changes: 4 additions & 0 deletions backend/servers/explorer-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,30 @@ public class SecurityConfiguration {

@Bean
public UserDetailsService userDetailsService() {
// The primary purpose of the UserDetailsService is to load user-specific data.
// It is used by the AuthenticationManager to authenticate a user during the login process.
// When a username and password are submitted (e.g., via a login form), Spring Security's AuthenticationManager
// uses the UserDetailsService to load the user details.
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
manager.createUser(User.withDefaultPasswordEncoder()
.username("user")
.password("password")
manager.createUser(User.withUsername("user")
.password("{bcrypt}$2a$10$dXJ3SW6G7P50lGmMkkmwe.20cQQubK3.HZWzG3YB1tlRy.fqvM/BG")
.roles("USER")
.build());
return manager;
}

@Bean
public SecurityFilterChain filterChain(final HttpSecurity http) throws Exception {
// Each request that comes in passes through this chain of filters before reaching your application.
http.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests((authorize) -> authorize
.anyRequest().permitAll()
);
.cors(AbstractHttpConfigurer::disable)
// No authentication required for the public website.
.authorizeHttpRequests((authorize) -> authorize.anyRequest().permitAll());
return http.build();
}

/**
* K1 manager.
* K1 manager. "k1" refers to a one-time, randomly generated key or token.
*
* @return k1 manager
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@ royllo.explorer.content.base-url=http://localhost:9093
royllo.explorer.analytics.piwik.trackingId=
#
# ======================================================================================================================
# Session configuration
spring.session.store-type=jdbc
spring.session.jdbc.initialize-schema=always
#
# ======================================================================================================================
# Using Liquibase to import test data
spring.liquibase.enabled=true
spring.liquibase.change-log=db/dev/db.dev-data.yaml
#
# ======================================================================================================================
# Disable cache during local dev
spring.thymeleaf.cache=false
spring.web.resources.chain.cache=false
spring.web.resources.chain.cache=false
#
# Enable SQL logging
#spring.jpa.show-sql=true
# Set logging level for Spring Session JDBC
#logging.level.org.springframework.session.jdbc=DEBUG
# If you want to see the SQL statements in the console
#logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG
#logging.level.org.hibernate.SQL=DEBUG
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ royllo.explorer.analytics.piwik.trackingId=00000000-0000-0000-0000-000000000000
# ======================================================================================================================
# Database access configuration.
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:mem:cassandre-database;DB_CLOSE_DELAY=-1
spring.datasource.url=jdbc:hsqldb:mem:explorer-royllo-database
spring.datasource.username=sa
spring.datasource.password=
#
Expand All @@ -27,6 +27,11 @@ s3.bucket-name=royllo-explorer-s3-asset-bucket
s3.endpoint-url=https://s3.amazonaws.com
#
# ======================================================================================================================
# Session configuration
spring.session.store-type=jdbc
spring.session.jdbc.initialize-schema=always
#
# ======================================================================================================================
# Cache configuration.
spring.cache.type=caffeine
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ royllo.explorer.analytics.piwik.trackingId=
# ======================================================================================================================
# Database access configuration.
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:mem:cassandre-database;DB_CLOSE_DELAY=-1
spring.datasource.url=jdbc:hsqldb:mem:explorer-royllo-database
spring.datasource.username=sa
spring.datasource.password=
#
Expand Down

0 comments on commit 4d36c42

Please sign in to comment.