From bd2aa557b41ce634638c744e09ed172a52be534f Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Wed, 10 Oct 2018 10:09:28 +0100 Subject: [PATCH] Moved password required for submissions to external configuration file. --- .../main/kotlin/uk/co/neviyn/observationdatabase/Security.kt | 5 ++++- backend/src/main/resources/application.properties | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Security.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Security.kt index a5a207c..389b125 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Security.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Security.kt @@ -3,6 +3,7 @@ package uk.co.neviyn.observationdatabase import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.core.env.Environment import org.springframework.http.HttpMethod import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder import org.springframework.security.config.annotation.web.builders.HttpSecurity @@ -25,12 +26,14 @@ class CustomWebSecurityConfigurerAdapter : WebSecurityConfigurerAdapter() { @Autowired lateinit var authenticationEntryPoint: MyBasicAuthenticationEntryPoint + @Autowired + lateinit var environment: Environment @Autowired @Throws(Exception::class) fun configureGlobal(auth: AuthenticationManagerBuilder) { auth.inMemoryAuthentication() - .withUser("admin").password(passwordEncoder().encode("admin")) + .withUser("admin").password(passwordEncoder().encode(environment.getProperty("obsdb.password"))) .authorities("ROLE_USER") } diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 5917ade..fe8bbb9 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -1,3 +1,4 @@ spring.jpa.properties.jadira.usertype.autoRegisterUserTypes = true spring.datasource.url=jdbc:h2:file:./database spring.jpa.hibernate.ddl-auto=update +obsdb.password=observation \ No newline at end of file