diff --git a/.gitignore b/.gitignore
index 19d810e3..3722e264 100644
--- a/.gitignore
+++ b/.gitignore
@@ -116,3 +116,9 @@ Desktop.ini
*.*~
*~
.merge_file*
+
+######################
+# Gradle Wrapper
+######################
+!gradle/wrapper/gradle-wrapper.jar
+
diff --git a/Gruntfile.js b/Gruntfile.js
index dae8110e..bd25e115 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,4 +1,4 @@
-// Generated on 2015-03-10 using generator-jhipster 2.6.0
+// Generated on 2015-04-03 using generator-jhipster 2.7.0
'use strict';
var fs = require('fs');
@@ -372,7 +372,7 @@ module.exports = function (grunt) {
},
dev: {
options: {
- dest: 'src/main/webapp/scripts/app/app.constants.js',
+ dest: 'src/main/webapp/scripts/app/app.constants.js'
},
constants: {
ENV: 'dev',
@@ -381,7 +381,7 @@ module.exports = function (grunt) {
},
prod: {
options: {
- dest: '.tmp/scripts/app/app.constants.js',
+ dest: '.tmp/scripts/app/app.constants.js'
},
constants: {
ENV: 'prod',
diff --git a/package.json b/package.json
index 4d248239..efff37c0 100644
--- a/package.json
+++ b/package.json
@@ -41,7 +41,7 @@
"karma-requirejs": "0.2.2",
"karma-phantomjs-launcher": "0.1.4",
"karma": "0.12.32",
- "generator-jhipster": "2.6.0",
+ "generator-jhipster": "2.7.0",
"lodash": "3.3.1",
"xml2js": "0.4.5",
"zeparser": "0.0.7",
diff --git a/pom.xml b/pom.xml
index e89c8e64..2907be77 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
spring-boot-starter-parent
org.springframework.boot
- 1.2.2.RELEASE
+ 1.2.3.RELEASE
@@ -30,6 +30,8 @@
2.1.2
4.3.6.Final
1.8
+ ${java.version}
+ ${java.version}
1
1.3
0.9.1
@@ -43,6 +45,7 @@
3.0.3
false
2.3
+ 4.0.0.RELEASE
0.9.5
3.2.0.GA
@@ -331,6 +334,18 @@
org.springframework.cloud
spring-cloud-localconfig-connector
+
+
+ org.springframework.security
+ spring-security-data
+ ${spring-security.version}
+
+
+ org.springframework.security
+ spring-security-messaging
+ ${spring-security.version}
+
+
fr.ippon.spark.metrics
metrics-spark-reporter
diff --git a/src/main/java/com/mycompany/myapp/ApplicationWebXml.java b/src/main/java/com/mycompany/myapp/ApplicationWebXml.java
index 6934e80c..2d238db9 100644
--- a/src/main/java/com/mycompany/myapp/ApplicationWebXml.java
+++ b/src/main/java/com/mycompany/myapp/ApplicationWebXml.java
@@ -7,7 +7,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
/**
- * This is an helper Java class that provides an alternative to creating a web.xml.
+ * This is a helper Java class that provides an alternative to creating a web.xml.
*/
public class ApplicationWebXml extends SpringBootServletInitializer {
diff --git a/src/main/java/com/mycompany/myapp/config/SecurityConfiguration.java b/src/main/java/com/mycompany/myapp/config/SecurityConfiguration.java
index 477cda44..5cb51759 100644
--- a/src/main/java/com/mycompany/myapp/config/SecurityConfiguration.java
+++ b/src/main/java/com/mycompany/myapp/config/SecurityConfiguration.java
@@ -20,6 +20,8 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.data.repository.query.SecurityEvaluationContextExtension;
+
import org.springframework.security.web.authentication.RememberMeServices;
import org.springframework.security.web.csrf.CsrfFilter;
@@ -27,6 +29,7 @@ import javax.inject.Inject;
@Configuration
@EnableWebSecurity
+@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Inject
@@ -77,6 +80,9 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
+ .csrf()
+ .ignoringAntMatchers("/websocket/**")
+ .and()
.addFilterAfter(new CsrfCookieGeneratorFilter(), CsrfFilter.class)
.exceptionHandling()
.authenticationEntryPoint(authenticationEntryPoint)
@@ -102,50 +108,31 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.headers()
.frameOptions()
.disable()
+ .and()
.authorizeRequests()
- .antMatchers("/api/register").permitAll()
- .antMatchers("/api/activate").permitAll()
- .antMatchers("/api/authenticate").permitAll()
- .antMatchers("/api/logs/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/api/**").authenticated()
- .antMatchers("/metrics/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/health/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/trace/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/dump/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/shutdown/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/beans/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/configprops/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/info/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/autoconfig/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/env/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/trace/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/api-docs/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .antMatchers("/protected/**").authenticated();
+ .antMatchers("/api/register").permitAll()
+ .antMatchers("/api/activate").permitAll()
+ .antMatchers("/api/authenticate").permitAll()
+ .antMatchers("/api/logs/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/api/**").authenticated()
+ .antMatchers("/metrics/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/health/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/trace/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/dump/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/shutdown/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/beans/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/configprops/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/info/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/autoconfig/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/env/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/trace/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/api-docs/**").hasAuthority(AuthoritiesConstants.ADMIN)
+ .antMatchers("/protected/**").authenticated();
}
- @EnableGlobalMethodSecurity(prePostEnabled = true, jsr250Enabled = true)
- private static class GlobalSecurityConfiguration extends GlobalMethodSecurityConfiguration {
- }
-
- /**
- * This allows SpEL support in Spring Data JPA @Query definitions.
- *
- * See https://spring.io/blog/2014/07/15/spel-support-in-spring-data-jpa-query-definitions
- */
@Bean
- EvaluationContextExtension securityExtension() {
- return new EvaluationContextExtensionSupport() {
- @Override
- public String getExtensionId() {
- return "security";
- }
-
- @Override
- public SecurityExpressionRoot getRootObject() {
- return new SecurityExpressionRoot(SecurityContextHolder.getContext().getAuthentication()) {};
- }
- };
+ public SecurityEvaluationContextExtension securityEvaluationContextExtension() {
+ return new SecurityEvaluationContextExtension();
}
-
}
diff --git a/src/main/java/com/mycompany/myapp/web/rest/UserResource.java b/src/main/java/com/mycompany/myapp/web/rest/UserResource.java
index 2cd702e7..a351dcad 100644
--- a/src/main/java/com/mycompany/myapp/web/rest/UserResource.java
+++ b/src/main/java/com/mycompany/myapp/web/rest/UserResource.java
@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
-import javax.annotation.security.RolesAllowed;
import javax.inject.Inject;
import java.util.List;
@@ -49,7 +48,6 @@ public class UserResource {
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
- @RolesAllowed(AuthoritiesConstants.ADMIN)
ResponseEntity getUser(@PathVariable String login) {
log.debug("REST request to get User : {}", login);
return userRepository.findOneByLogin(login)
diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html
index 782fea43..5149da73 100644
--- a/src/main/webapp/index.html
+++ b/src/main/webapp/index.html
@@ -70,11 +70,14 @@
+
+
+
diff --git a/src/main/webapp/scripts/components/auth/auth.service.js b/src/main/webapp/scripts/components/auth/auth.service.js
index 50ed504d..62642e15 100644
--- a/src/main/webapp/scripts/components/auth/auth.service.js
+++ b/src/main/webapp/scripts/components/auth/auth.service.js
@@ -13,9 +13,8 @@ angular.module('jhipsterApp')
// After the login the language will be changed to
// the language selected by the user during his registration
$translate.use(account.langKey);
+ deferred.resolve(data);
});
- deferred.resolve(data);
-
return cb();
}).catch(function (err) {
this.logout();
diff --git a/src/main/webapp/scripts/components/auth/authority.directive.js b/src/main/webapp/scripts/components/auth/authority.directive.js
new file mode 100644
index 00000000..67127ebb
--- /dev/null
+++ b/src/main/webapp/scripts/components/auth/authority.directive.js
@@ -0,0 +1,65 @@
+'use strict';
+
+angular.module('jhipsterApp')
+ .directive('hasAnyRole', ['Principal', function (Principal) {
+ return {
+ restrict: 'A',
+ link: function (scope, element, attrs) {
+ var setVisible = function () {
+ element.removeClass('hidden');
+ },
+ setHidden = function () {
+ element.addClass('hidden');
+ },
+ defineVisibility = function (reset) {
+ var result;
+ if (reset) {
+ setVisible();
+ }
+
+ result = Principal.isInAnyRole(roles);
+ if (result) {
+ setVisible();
+ } else {
+ setHidden();
+ }
+ },
+ roles = attrs.hasAnyRole.replace(/\s+/g, '').split(',');
+
+ if (roles.length > 0) {
+ defineVisibility(true);
+ }
+ }
+ };
+ }])
+ .directive('hasRole', ['Principal', function (Principal) {
+ return {
+ restrict: 'A',
+ link: function (scope, element, attrs) {
+ var setVisible = function () {
+ element.removeClass('hidden');
+ },
+ setHidden = function () {
+ element.addClass('hidden');
+ },
+ defineVisibility = function (reset) {
+ var result;
+ if (reset) {
+ setVisible();
+ }
+
+ result = Principal.isInRole(role);
+ if (result) {
+ setVisible();
+ } else {
+ setHidden();
+ }
+ },
+ role = attrs.hasRole.replace(/\s+/g, '');
+
+ if (role.length > 0) {
+ defineVisibility(true);
+ }
+ }
+ };
+ }]);
diff --git a/src/main/webapp/scripts/components/form/pager.directive.js b/src/main/webapp/scripts/components/form/pager.directive.js
new file mode 100644
index 00000000..5b620334
--- /dev/null
+++ b/src/main/webapp/scripts/components/form/pager.directive.js
@@ -0,0 +1,9 @@
+/* globals $ */
+'use strict';
+
+angular.module('jhipsterApp')
+ .directive('jhipsterAppPager', function() {
+ return {
+ templateUrl: 'scripts/components/form/pager.html'
+ };
+ });
diff --git a/src/main/webapp/scripts/components/form/pager.html b/src/main/webapp/scripts/components/form/pager.html
new file mode 100644
index 00000000..7a28a29d
--- /dev/null
+++ b/src/main/webapp/scripts/components/form/pager.html
@@ -0,0 +1,8 @@
+
diff --git a/src/main/webapp/scripts/components/form/pagination.directive.js b/src/main/webapp/scripts/components/form/pagination.directive.js
new file mode 100644
index 00000000..0e0804c7
--- /dev/null
+++ b/src/main/webapp/scripts/components/form/pagination.directive.js
@@ -0,0 +1,9 @@
+/* globals $ */
+'use strict';
+
+angular.module('jhipsterApp')
+ .directive('jhipsterAppPagination', function() {
+ return {
+ templateUrl: 'scripts/components/form/pagination.html'
+ };
+ });
diff --git a/src/main/webapp/scripts/components/form/pagination.html b/src/main/webapp/scripts/components/form/pagination.html
new file mode 100644
index 00000000..b6e47ad3
--- /dev/null
+++ b/src/main/webapp/scripts/components/form/pagination.html
@@ -0,0 +1,13 @@
+
diff --git a/src/main/webapp/scripts/components/navbar/navbar.controller.js b/src/main/webapp/scripts/components/navbar/navbar.controller.js
index c5eee451..1c545140 100644
--- a/src/main/webapp/scripts/components/navbar/navbar.controller.js
+++ b/src/main/webapp/scripts/components/navbar/navbar.controller.js
@@ -3,7 +3,6 @@
angular.module('jhipsterApp')
.controller('NavbarController', function ($scope, $location, $state, Auth, Principal) {
$scope.isAuthenticated = Principal.isAuthenticated;
- $scope.isInRole = Principal.isInRole;
$scope.$state = $state;
$scope.logout = function () {
diff --git a/src/main/webapp/scripts/components/navbar/navbar.html b/src/main/webapp/scripts/components/navbar/navbar.html
index 1c788cba..d4ea76cb 100644
--- a/src/main/webapp/scripts/components/navbar/navbar.html
+++ b/src/main/webapp/scripts/components/navbar/navbar.html
@@ -7,7 +7,7 @@
- jhipster v{{VERSION}}
+ jhipster v{{VERSION}}
@@ -57,7 +57,7 @@
Register
-
+
diff --git a/src/test/javascript/karma.conf.js b/src/test/javascript/karma.conf.js
index 396d2e06..97021204 100644
--- a/src/test/javascript/karma.conf.js
+++ b/src/test/javascript/karma.conf.js
@@ -32,7 +32,7 @@ module.exports = function (config) {
// endbower
'main/webapp/scripts/app/app.js',
'main/webapp/scripts/app/**/*.js',
- 'main/webapp/scripts/components/**/*.js',
+ 'main/webapp/scripts/components/**/*.{js,html}',
'test/javascript/**/!(karma.conf).js'
],