Skip to main content

Overview

Trippins uses separate configuration files for the Spring Boot backend and Angular frontend. This guide covers all configuration options and environment-specific settings.
Configuration can be overridden using environment variables in Docker deployments.

Spring Boot Configuration

The main configuration file is located at backend/src/main/resources/application.properties.

Application Settings

spring.application.name=practica1
spring.mustache.prefix=classpath:/templates/
spring.mustache.suffix=.html
spring.application.name
string
Application identifier used in logging and monitoring
spring.mustache.prefix
string
Template directory location for Mustache templates
spring.mustache.suffix
string
File extension for Mustache template files

Database Configuration

# MySQL Database Connection
spring.datasource.url=jdbc:mysql://localhost:3307/Trippins
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# JPA/Hibernate Settings
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.datasource.url
string
required
JDBC connection URL for MySQL databaseLocal: jdbc:mysql://localhost:3307/TrippinsDocker: jdbc:mysql://db:3306/Trippins
spring.datasource.username
string
required
Database usernameDefault: root
spring.datasource.password
string
required
Database passwordLocal: 1234Docker: password
spring.datasource.driver-class-name
string
required
JDBC driver classValue: com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto
string
required
Database schema generation strategyOptions:
  • update: Update schema without dropping data
  • create: Drop and recreate schema on startup
  • create-drop: Create on startup, drop on shutdown
  • validate: Validate schema matches entities
  • none: No schema management
Default: update
spring.jpa.show-sql
boolean
Enable SQL query logging in consoleDefault: true
spring.jpa.properties.hibernate.format_sql
boolean
Format SQL queries for readabilityDefault: true

SSL/HTTPS Configuration

# Auto-signed certificate
server.port=8443
server.ssl.key-store=classpath:keystore.jks
server.ssl.key-store-password=password
server.ssl.key-password=password
The application uses a self-signed certificate for HTTPS. For production deployments, replace with a valid SSL certificate from a trusted Certificate Authority.
server.port
number
required
HTTPS port for the application serverDefault: 8443
server.ssl.key-store
string
required
Path to the Java KeyStore file containing the SSL certificateDefault: classpath:keystore.jks
server.ssl.key-store-password
string
required
Password for the KeyStore file
server.ssl.key-password
string
required
Password for the private key in the KeyStore

Email Service Configuration

# Gmail SMTP Configuration
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username[email protected]
spring.mail.password=gzgymqgmeifnwoct

# SMTP Properties
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.connectiontimeout=10000
spring.mail.properties.mail.smtp.timeout=10000
spring.mail.properties.mail.smtp.writetimeout=10000
spring.mail.properties.mail.smtp.ssl.protocols=TLSv1.2
spring.mail.properties.mail.smtp.ssl.trust=*
spring.mail.properties.mail.smtp.debug=true
The application uses Gmail’s SMTP server for sending emails. An app-specific password is configured for authentication.
spring.mail.host
string
required
SMTP server hostnameDefault: smtp.gmail.com
spring.mail.port
number
required
SMTP server portDefault: 587 (TLS)
spring.mail.username
string
required
Email account username
spring.mail.password
string
required
Email account password (app-specific password for Gmail)
spring.mail.properties.mail.smtp.auth
boolean
Enable SMTP authenticationDefault: true
spring.mail.properties.mail.smtp.starttls.enable
boolean
Enable STARTTLS encryptionDefault: true
spring.mail.properties.mail.smtp.starttls.required
boolean
Require STARTTLS encryptionDefault: true
spring.mail.properties.mail.smtp.connectiontimeout
number
Connection timeout in millisecondsDefault: 10000 (10 seconds)
spring.mail.properties.mail.smtp.timeout
number
General timeout in millisecondsDefault: 10000 (10 seconds)
spring.mail.properties.mail.smtp.writetimeout
number
Write timeout in millisecondsDefault: 10000 (10 seconds)

Logging Configuration

logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
logging.level.org.springframework.security=DEBUG
logging.level.org.hibernate.SQL
string
Log level for Hibernate SQL queriesOptions: TRACE, DEBUG, INFO, WARN, ERRORDefault: DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder
string
Log level for SQL parameter bindingDefault: TRACE
logging.level.org.springframework.security
string
Log level for Spring Security operationsDefault: DEBUG
Set logging levels to INFO or WARN in production to reduce log verbosity.

SPA Configuration

# Necessary for SPA application
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
spring.mvc.pathmatch.matching-strategy
string
required
Path matching strategy for Spring MVCValue: ant_path_matcher (required for Angular SPA routing)

Security Configuration

Security settings are defined in SecurityConfiguration.java:

Authentication

@Bean
public PasswordEncoder passwordEncoder() {
    return new BCryptPasswordEncoder();
}
Passwords are hashed using BCrypt with a default strength of 10.

JWT Configuration

JWT tokens are used for stateless authentication:
.sessionManagement(session -> session
    .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
)
.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class)
The JWT secret is configured via the JWT_SECRET environment variable in Docker deployments.

CORS Configuration

Cross-Origin Resource Sharing is disabled by default:
.csrf(csrf -> csrf.disable())
CSRF protection is disabled because the application uses stateless JWT authentication. Ensure proper JWT validation is in place.

Authorization Rules

Accessible without authentication:
.requestMatchers("/", "/index", "/about", "/contact", 
                 "/register", "/error", "/v1/api/login/**", 
                 "/css/**", "/js/**", "/images/**").permitAll()
.requestMatchers("/room", "/v1/api/query").permitAll()
.requestMatchers("/new", "/new/**").permitAll()
.requestMatchers(HttpMethod.POST, "/addUser", "/v1/api/users").permitAll()
.requestMatchers(HttpMethod.POST, "/v1/api/login/forms").permitAll()
Require valid authentication:
.requestMatchers("/room/{code}", "/roomDetails").authenticated()
.requestMatchers("/newHotel", "/booking", "/profile", 
                 "/api/houses/**").authenticated()
Require USER or ADMIN role:
.requestMatchers(HttpMethod.POST, "/addHotel").hasAnyRole("USER", "ADMIN")
Require ADMIN role:
.requestMatchers("/v1/api/users/**", "/v1/api/reviews/**", 
                 "/v1/api/admin/**").hasRole("ADMIN")
.requestMatchers("/admin/**", "/admin").hasRole("ADMIN")

Angular Frontend Configuration

Frontend environment settings are in frontend/src/environments/environment.ts:
export const environment = {
    baseUrl: '/',
    baseUrlApi: '/v1/api'
};
baseUrl
string
required
Base URL for the applicationDefault: /
baseUrlApi
string
required
Base URL for API endpointsDefault: /v1/api
Angular uses relative URLs that are proxied to the Spring Boot backend on the same domain.

Environment-Specific Configuration

Development

# Local development database
spring.datasource.url=jdbc:mysql://localhost:3307/Trippins
spring.datasource.password=1234

# Enable debug logging
logging.level.org.springframework.security=DEBUG
logging.level.org.hibernate.SQL=DEBUG

Docker/Production

Environment variables override application.properties:
SPRING_DATASOURCE_URL=jdbc:mysql://db:3306/Trippins
SPRING_DATASOURCE_USERNAME=root
SPRING_DATASOURCE_PASSWORD=password
JWT_SECRET=your-secret-key
SERVER_SSL_ENABLED=true
SERVER_PORT=8443
Use different JWT secrets for each environment and store them securely using secrets management tools.

Configuration Best Practices

1

Externalize Secrets

Never commit passwords, API keys, or JWT secrets to version control. Use environment variables or secret management services.
2

Use Environment Profiles

Create separate configuration files for different environments:
  • application-dev.properties
  • application-prod.properties
3

Enable SSL in Production

Always use valid SSL certificates in production. Replace the self-signed certificate with one from a trusted CA.
4

Secure Database Credentials

Use strong passwords and restrict database access to application servers only.
5

Configure Logging

Reduce logging verbosity in production to avoid performance issues and log file bloat.

Next Steps

Docker Deployment

Deploy Trippins using Docker containers

Database Setup

Configure the MySQL database and schema

Build docs developers (and LLMs) love