Skip to content

Commit 5de8ce0

Browse files
committed
H2 Database - Configuratio setup
1 parent 6d081e1 commit 5de8ce0

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@
121121
<scope>provided</scope>
122122
</dependency>
123123

124+
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
125+
<dependency>
126+
<groupId>com.h2database</groupId>
127+
<artifactId>h2</artifactId>
128+
<scope>runtime</scope>
129+
</dependency>
130+
124131
</dependencies>
125132

126133
<build>

src/main/java/com/appsdeveloperblog/app/ws/security/SecurityConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class SecurityConstants {
1515
"/users/password-reset-request";
1616
public static final String PASSWORD_RESET_URL =
1717
"/users/password-reset";
18+
public static final String H2_CONSOLE = "/h2-console/**";
1819

1920
public static String getTokenSecret() {
2021
AppProperties appProperties = (AppProperties) SpringApplicationContext.getBean(

src/main/java/com/appsdeveloperblog/app/ws/security/WebSecurity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ protected void configure(HttpSecurity http) throws Exception {
3737
.permitAll()
3838
.antMatchers(HttpMethod.POST, SecurityConstants.PASSWORD_RESET_URL)
3939
.permitAll()
40+
.antMatchers(SecurityConstants.H2_CONSOLE)
41+
.permitAll()
4042
.anyRequest()
4143
.authenticated()
4244
.and()
4345
.addFilter(getAuthenticationFilter())
4446
.addFilter(new AuthorizationFilter(authenticationManager()))
4547
.sessionManagement()
4648
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
49+
50+
// H2 console configuration only for development not for production
51+
http.headers().frameOptions().disable();
4752
}
4853

4954
@Override
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1+
#Spring properties
12
server.error.whitelabel.enabled=false
2-
spring.datasource.username=
3-
spring.datasource.password=
4-
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/photo_app
5-
spring.jpa.hibernate.ddl-auto=update
6-
tokenSecret=tokenSecret
73
server.error.include-stacktrace=never
84
server.servlet.context-path=/mobile-app-ws
95
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL8Dialect
6+
tokenSecret=tokenSecret
7+
8+
#spring.datasource.username=
9+
#spring.datasource.password=
10+
spring.jpa.hibernate.ddl-auto=update
11+
12+
#H2 database
13+
server.port=8888
14+
spring.h2.console.enabled=true
15+
spring.h2.console.path=/h2-console
16+
17+
#MySQL database
18+
#server.port=8080
19+
#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/photo_app
20+
21+
#AWS RDS database
22+
#spring.datasource.url=
23+
24+
#AWS SES email service
1025
aws.accessKeyId=
1126
aws.secretKey=

0 commit comments

Comments
 (0)