###############################################################################
#
# BX-bot's Spring Boot application config.
#
###############################################################################

# The Spring Boot management port.
# Setting it to -1 disables management endpoints over HTTP(S).
# Locked down to prevent remote access.
management.port=-1

# The Spring Boot management address.
# Locked down to prevent remote access - it only allows access from the local machine if the
# management.port were to be changed.
management.address=127.0.0.1

# Location of BX-bot log4j2 config file.
# Spring Boot seems to need this to initialise logging successfully.
logging.config=./config/log4j2.xml

# Enable JMX - it is needed expose the Spring Cloud RestartEndpoint since Boot 2.2.x :-/
# See: https://github.com/spring-cloud/spring-cloud-commons/issues/710
spring.jmx.enabled=true

###############################################################################
# REST API configuration
###############################################################################

# Swagger config
springdoc.api-docs.path=/api-docs
springdoc.swagger-ui.path=/swagger-ui.html
springdoc.swagger-ui.operationsSorter=alpha
springdoc.swagger-ui.tagsSorter=alpha

# Used for signing JWTs
bxbot.restapi.jwt.secret=ChangeMeUMExOBvrw40wQFPiEYs87V7MCZuseaxYFpXZHRIdWCWwyPLvM2lT9GtJD2geMwxQ9Naff8oquvg2VC5F3uqlE98UGLLQFcO6fwra7
# Token expires time (in secs)
bxbot.restapi.jwt.expiration=600
# Max allowed clock skew (in secs) when comparing token expiry time
bxbot.restapi.jwt.allowed_clock_skew=60
bxbot.restapi.jwt.issuer=bxbot
bxbot.restapi.jwt.audience=bxbot-ui

# CORS allowed origins. This MUST be locked down to specific host in Production, e.g.
# https://some-host:3000
# For dev environment, we allow any origin.
restapi.cors.allowed_origin=*

# Spring Actuator endpoints that are used by REST API.
management.endpoints.enabled-by-default=false
management.endpoint.restart.enabled=true
management.endpoint.health.enabled=true
management.endpoint.logfile.enabled=true

# We don't expose all the actuator endpoints directly - only the ones we need.
# See: https://stackoverflow.com/questions/66156282/refreshendpoint-bean-not-available-with-spring-boot-2-4-2-and-spring-cloud-2020
#      https://cloud.spring.io/spring-cloud-static/Greenwich.RELEASE/multi/multi__spring_cloud_context_application_context_services.html#refresh-scope
management.endpoints.web.exposure.include=restart,health,logfile

# Lock down management security - we don't expose the management endpoints.
management.security.enabled=true

# Must be set to location of logfile for management.endpoint.logfile to work.
# See: https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints
# See: https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.logging.file-output
logging.file.name=./logs/bxbot.log

# Max number of lines from the logfile to be returned by the REST API /runtime/logfile endpoint.
# If the number of lines in the logfile exceeds this limit, the file content will truncated.
bxbot.restapi.maxLogfileLines=1000

# Max size (in bytes) of logfile to be downloaded from the REST API /runtime/logfile/download endpoint.
# If the size of the logfile exceeds this limit, the end of the file will be truncated before download.
bxbot.restapi.maxLogfileDownloadSize=1048576

# H2 configuration. Really make sure it is off.
spring.h2.console.enabled=false

# Banner settings.
spring.main.banner-mode=log
spring.banner.location=classpath:banner.txt

###############################################################################
# TLS Configuration (for securing REST API in Production)
###############################################################################

# The port the Spring Boot container will listen on for incoming HTTP requests.
# Defaults to 8080 if not set.
# Setting it to -1 disables the REST API.
# Should be set to 8443 when TLS enabled in Production environment.
server.port=8080

# Spring Boot profile for REST API.
# Must use https profile in Production environment.
#spring.profiles.active=https

# SSL (TLS) configuration to secure the REST API.
# Must be enabled in Production environment.
#security.require-ssl=true
#server.ssl.key-store=classpath:keystore.p12
#server.ssl.key-store-password=secret
#server.ssl.key-store-type=PKCS12
