From 3b711d47c5299721b86590d01f0ef14a5f95529e Mon Sep 17 00:00:00 2001 From: Tilman Liero Date: Sat, 16 Jul 2016 23:10:04 +0200 Subject: [PATCH] make H2 database console available --- .../java/de/tilman/transactions/SecurityConfiguration.java | 5 ++++- src/main/resources/data-h2.sql | 2 +- src/main/resources/static/js/controllers.js | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/tilman/transactions/SecurityConfiguration.java b/src/main/java/de/tilman/transactions/SecurityConfiguration.java index cf1fd44..67fcc7f 100644 --- a/src/main/java/de/tilman/transactions/SecurityConfiguration.java +++ b/src/main/java/de/tilman/transactions/SecurityConfiguration.java @@ -17,7 +17,8 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication() .withUser("adam@mail.com").password("test").roles("USER", "ADMIN").and() - .withUser("betty@mail.com").password("test").roles("USER"); + .withUser("tilman").password("test").roles("USER", "ADMIN").and() + .withUser("anica").password("test").roles("USER"); } @Override @@ -25,11 +26,13 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { // Basis-Schutz: Nur autorisierte Zugriffe (feingranulare Steuerung über Assertions) http.authorizeRequests() .antMatchers(HttpMethod.GET, "/public/**").permitAll() + .antMatchers("/console/**").permitAll() .anyRequest().authenticated(); http.httpBasic(); // XXX mit HTTP Basic Auth funktioniert der Logout nicht richtig // http.formLogin(); http.csrf().disable(); // XXX später wieder aktivieren + http.headers().frameOptions().disable(); } } diff --git a/src/main/resources/data-h2.sql b/src/main/resources/data-h2.sql index aa36cfa..f6d7d92 100644 --- a/src/main/resources/data-h2.sql +++ b/src/main/resources/data-h2.sql @@ -19,7 +19,6 @@ INSERT INTO Transaction (id, amount, account_id, category_id, date, description, (NULL, -4.81, 1, 3, '2016-04-18', 'Currywurst (Auslage Adam)', 1), (NULL, -4.50, 1, 3, '2016-04-19', 'Currywurst', null), (NULL, -4.50, 1, 3, '2016-04-20', 'Currywurst', null), - (NULL, -4.50, 2, 3, '2016-04-20', 'Currywurst', null), (NULL, -4.09, 1, 3, '2016-04-18', 'Currywurst-Frühstück', null), (NULL, -4.90, 1, 3, '2016-04-18', 'Currywurst (Auslage Betty)', 2), (NULL, -8.90, 1, 3, '2016-04-18', 'Curry beim Inder (Auslage Adam)', 1), @@ -28,6 +27,7 @@ INSERT INTO Transaction (id, amount, account_id, category_id, date, description, (NULL, -10, 1, 4, '2016-04-14 10:03:00', 'Entnahme Adam', 1), (NULL, 1340.22, 2, 5, '2016-04-02', 'Gehalt Adam', null), + (NULL, -4.50, 2, 6, '2016-04-20', 'WebPack', null), (NULL, -12.90, 2, 6, '2016-04-16', 'Host Europe', null); diff --git a/src/main/resources/static/js/controllers.js b/src/main/resources/static/js/controllers.js index 70b8d10..e94c256 100644 --- a/src/main/resources/static/js/controllers.js +++ b/src/main/resources/static/js/controllers.js @@ -80,7 +80,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location' } // get recent transactions - var transactions = $resource('http://localhost:8080/transactions/search/forAccount', { accountId: $scope.account.id, size: $scope.pageSize, sort: 'date,desc' }).get(); + var transactions = $resource('/transactions/search/forAccount', { accountId: $scope.account.id, size: $scope.pageSize, sort: 'date,desc' }).get(); transactions.$promise.then(function(data) { $scope.transactions = transactions._embedded.transactions; $scope.nextPageAvailable = (transactions.page.totalPages !== transactions.page.number + 1); @@ -172,7 +172,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location' $scope.moreTransactions = function() { if ($scope.nextPageAvailable) { $scope.pageNumber++; - var transactions = $resource('http://localhost:8080/transactions/search/forAccount', { accountId: $scope.account.id, size: $scope.pageSize, sort: 'date,desc', page: $scope.pageNumber }).get(); + var transactions = $resource('/transactions/search/forAccount', { accountId: $scope.account.id, size: $scope.pageSize, sort: 'date,desc', page: $scope.pageNumber }).get(); transactions.$promise.then(function(data) { for (i = 0; i < transactions._embedded.transactions.length; i++) { transactions._embedded.transactions[i].amount = numberToAmount(transactions._embedded.transactions[i].amount); @@ -187,7 +187,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location' }; $scope.updateSuggestions = function(val) { - var suggestions = $resource('http://localhost:8080/transactions/search/descriptions', { accountId: $scope.account.id, prefix: val.toLowerCase() }).get(); + var suggestions = $resource('/transactions/search/descriptions', { accountId: $scope.account.id, prefix: val.toLowerCase() }).get(); return suggestions.$promise.then(function(data) { var newSuggestions = new Array(suggestions._embedded.transactions.length); for (i = 0; i < suggestions._embedded.transactions.length; i++) {