getting ready for production

This commit is contained in:
2016-07-17 01:14:34 +02:00
parent b423467074
commit 01bde31297
6 changed files with 61 additions and 64 deletions
+6
View File
@@ -5,6 +5,11 @@
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name> <name>org.eclipse.jdt.core.javabuilder</name>
<arguments> <arguments>
@@ -19,5 +24,6 @@
<natures> <natures>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures> </natures>
</projectDescription> </projectDescription>
+3 -3
View File
@@ -19,9 +19,9 @@ https://letsencrypt.org/getting-started/
# TODO # TODO
- umschalten von Ausgabe auf Entnahme möglich? Ansonsten Pseudo-Kategorie aus Edit-Fenster entfernen - Server: SSL und logs konfigurieren
- Auslagen in Modal anzeigen und zurücksetzen - Benutzer-Passwörter ändern und Hashing einführen
- verschiedene Hintergrundfarben für Auslagen, je nach User
- Export als CSV - Export als CSV
- Import von comdirect mit Mustererkennung und Muster-Editor - Import von comdirect mit Mustererkennung und Muster-Editor
+1 -2
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.tilman</groupId> <groupId>de.tilman</groupId>
<artifactId>next-transactions</artifactId> <artifactId>next-transactions</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.0.0</version>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@@ -34,7 +34,6 @@
<java.version>1.8</java.version> <java.version>1.8</java.version>
</properties> </properties>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@@ -1,23 +1,7 @@
package de.tilman.transactions; package de.tilman.transactions;
import javax.annotation.PostConstruct;
import org.h2.server.web.WebServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.context.SecurityContextHolder;
import de.tilman.transactions.domain.Account;
import de.tilman.transactions.domain.User;
import de.tilman.transactions.repository.AccountRepository;
import de.tilman.transactions.repository.UserRepository;
@SpringBootApplication @SpringBootApplication
public class Application { public class Application {
@@ -26,42 +10,42 @@ public class Application {
SpringApplication.run(Application.class); SpringApplication.run(Application.class);
} }
private static final Logger log = LoggerFactory.getLogger(Application.class); // private static final Logger log = LoggerFactory.getLogger(Application.class);
//
// @Autowired UserRepository userRepository;
// @Autowired AccountRepository accountRepository;
//
//
// // XXX for dev
// @PostConstruct
// public void init() {
//
// /**
// * Due to method-level protections the security context must be loaded
// * with an authentication token containing the necessary privileges.
// */
// SecurityContextHolder.getContext().setAuthentication(
// new UsernamePasswordAuthenticationToken("system", "system", AuthorityUtils.createAuthorityList("ROLE_ADMIN", "ROLE_USER")));
//
// log.info("Users:");
// for (User user : userRepository.findAll()) {
// log.info(user.getId() + ", " + user.getName());
// }
//
// log.info("Accounts:");
// for (Account account : accountRepository.findAll()) {
// log.info(account.getId() + ", " + account.getName() /* + ", " + account.getOwner().getName() */);
// }
//
// SecurityContextHolder.clearContext();
// }
@Autowired UserRepository userRepository; // // XXX for dev - make H2 database available as jdbc:h2:mem:testdb at /console (https://springframework.guru/using-the-h2-database-console-in-spring-boot-with-spring-security/)
@Autowired AccountRepository accountRepository; // @Bean
// public ServletRegistrationBean h2servletRegistration() {
// ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet());
// XXX for dev // registration.addUrlMappings("/console/*");
@PostConstruct // return registration;
public void init() { // }
/**
* Due to method-level protections the security context must be loaded
* with an authentication token containing the necessary privileges.
*/
SecurityContextHolder.getContext().setAuthentication(
new UsernamePasswordAuthenticationToken("system", "system", AuthorityUtils.createAuthorityList("ROLE_ADMIN", "ROLE_USER")));
log.info("Users:");
for (User user : userRepository.findAll()) {
log.info(user.getId() + ", " + user.getName());
}
log.info("Accounts:");
for (Account account : accountRepository.findAll()) {
log.info(account.getId() + ", " + account.getName() /* + ", " + account.getOwner().getName() */);
}
SecurityContextHolder.clearContext();
}
// XXX for dev - make H2 database available as jdbc:h2:mem:testdb at /console (https://springframework.guru/using-the-h2-database-console-in-spring-boot-with-spring-security/)
@Bean
public ServletRegistrationBean h2servletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet());
registration.addUrlMappings("/console/*");
return registration;
}
} }
@@ -26,13 +26,13 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
// Basis-Schutz: Nur autorisierte Zugriffe (feingranulare Steuerung über Assertions) // Basis-Schutz: Nur autorisierte Zugriffe (feingranulare Steuerung über Assertions)
http.authorizeRequests() http.authorizeRequests()
.antMatchers(HttpMethod.GET, "/public/**").permitAll() .antMatchers(HttpMethod.GET, "/public/**").permitAll()
.antMatchers("/console/**").permitAll() // .antMatchers("/console/**").permitAll() // H2 console
.anyRequest().authenticated(); .anyRequest().authenticated();
http.httpBasic(); // XXX mit HTTP Basic Auth funktioniert der Logout nicht richtig http.httpBasic(); // XXX mit HTTP Basic Auth funktioniert der Logout nicht richtig
// http.formLogin(); // http.formLogin();
http.csrf().disable(); // XXX später wieder aktivieren http.csrf().disable(); // XXX später wieder aktivieren
http.headers().frameOptions().disable(); // http.headers().frameOptions().disable(); // for H2 console
} }
} }
+11 -3
View File
@@ -1,5 +1,13 @@
spring.datasource.platform=h2 spring.datasource.platform=h2
security.user.name=sa server.port=8084
security.user.password=
# for production
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:h2:tcp://localhost/transactions
spring.datasource.username=sa
spring.datasource.password=PASSWORD
server.port=8080