Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of JDBC session on separate DB #840

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

DonaldChung-HK
Copy link

Description

This change allows the use of JDBC for saving HTTPSession data in a separate database. This is to support our use of Galera DB as our HA backend option. The change will allow use to reduce administrative burden and attack surface via not needing to run a cross data centre Redis. setup.

The code should only activate if jdbc spring session is used.

Fixes #809

@DonaldChung-HK DonaldChung-HK force-pushed the 809_jdbc-session-separate-db branch 2 times, most recently from 94a51a2 to 61cae4b Compare September 13, 2024 17:33
@rmiccoli rmiccoli changed the base branch from master to develop September 24, 2024 10:37
@DonaldChung-HK DonaldChung-HK force-pushed the 809_jdbc-session-separate-db branch from 61cae4b to e7c4bac Compare September 24, 2024 10:50
@DonaldChung-HK
Copy link
Author

I have added the missing new line at iam-login-service/src/main/resources/application-jdbc-session.yml so the licence check should pass now

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
54.5% Coverage on New Code (required ≥ 85%)

See analysis details on SonarCloud

@rmiccoli
Copy link
Contributor

rmiccoli commented Sep 25, 2024

I think we don't need @Primary and @Qualifier annotations since Spring will manage the different data sources based on the condition set. So,

  • when spring.session.store-type=jdbc is enabled, both primaryDataSource and sessionDataSource are created, and Spring Session uses session database for storage persistence;
  • when spring.session.store-type=jdbc is not set, only primaryDataSource is created and used for general database operations including session management.

@Bean
@ConfigurationProperties("session.datasource")
@Qualifier("sessionDataSourceProperties")
@ConditionalOnProperty(name = "spring.session.store-type", havingValue = "jdbc")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this annotation should be unnecessary here

@DonaldChung-HK
Copy link
Author

Hi, I think it does need to @Qualifier since otherwise there will be 2x non unique beans for datasource, one is the autoconfigured one and another one is this customer one?

@DonaldChung-HK
Copy link
Author

DonaldChung-HK commented Dec 9, 2024

Hi,
The test I have above is failing due to MySQL too many connections at the OidcExternalAuthenticationTests. It is strange cause in local development environment, all tests pass but it seems that in local environment, it uses h2 instead of MySQL. Could you please investigate?

Edit: I have made changes so that the Hikari object is a singleton and don't create too many connection below

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
54.5% Coverage on New Code (required ≥ 85%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JDBC for caching/session storage
3 participants