diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 000000000000..27ad37a22cfc
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,2 @@
+open_collective: generator-jhipster
+custom: https://www.jhipster.tech/sponsors/
diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md
index 3cd3ebb4fd4e..6611162f20c4 100644
--- a/.github/ISSUE_TEMPLATE/BUG_REPORT.md
+++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md
@@ -44,8 +44,17 @@ To provide all information we need, you should run `jhipster info` in the projec
copy/paste the result here.
The `.yo-rc.json` file generated in the root folder is mandatory for bug reports. This will help us to replicate the scenario.
You should remove any sensitive information like the rememberMe key or the jwtSecretKey key.
+---
+If you have a JDL please wrap it in below structure
+ JDL definitions
+
+ JDL content here
+
+
-
+
- |
-
- |
-
- |
-
- |
-
---|---|---|---|
+ |
+
+ |
+
+ |
+
+ |
+
- |
-
- |
- ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{property['prefix']} | -
- {Object.keys(property['properties']).map((propKey, index) => (
-
+
+
+
+ |
+ |
+
+ |
+
---|---|
{property['prefix']} | +
+ {Object.keys(property['properties']).map((propKey, index) => (
+ |
+
Property | +Value | +
---|---|
{propKey} | ++ {envKey.properties[propKey].value} + | +
Property | -Value | -
---|---|
{propKey} | -- {envKey.properties[propKey].value} - | -
- -
-Service Name | -Status | -Details | -
---|
Service Name | +Status | +Details | +
---|---|---|
{configPropKey} |
- |
{data[configPropKey].details ? (
-
- |
{logger.name} | -- - - - - - - | -
+
+
+ |
+
+
+ |
+
---|---|
+ {logger.name} + | ++ + + + + + + | +
- -
-+ +
+Loading...
- :Loading...
+ :
-
-
+
+
className="hand" onClick={this.sort('id')} <%_ } _%>> |
- <%_ for (idx in fields) { _%>
- className="hand" onClick={this.sort('<%=fields[idx].fieldName%>')} <%_ } _%>> |
- <%_ } _%>
- <%_ for (idx in relationships) { _%>
- <%_ if (relationships[idx].relationshipType === 'many-to-one'
- || (relationships[idx].relationshipType === 'one-to-one' && relationships[idx].ownerSide === true)
- || (relationships[idx].relationshipType === 'many-to-many' && relationships[idx].ownerSide === true && pagination === 'no')) {
- const fieldName = dto === 'no' ? "." + relationships[idx].otherEntityField : relationships[idx].otherEntityFieldCapitalized;_%>
- <% } %>> |
+ {
+ <%= entityInstance %>List && <%= entityInstance %>List.length > 0 ?(
+
---|
className="hand" onClick={this.sort('id')} <%_ } _%>> |
+ <%_ for (idx in fields) { _%>
+ className="hand" onClick={this.sort('<%=fields[idx].fieldName%>')} <%_ } _%>> |
<%_ } _%>
- <%_ } _%>
- - | ||
---|---|---|---|---|
- |
- <%_ for (idx in fields) {
- const fieldType = fields[idx].fieldType;
- const fieldName = fields[idx].fieldName;
- const fieldIsEnum = fields[idx].fieldIsEnum;
- _%>
-
- <%_ if (fieldType === 'Boolean') { _%>
- {<%= entityInstance %>.<%=fields[idx].fieldName%> ? 'true' : 'false'}
- <%_ } else if (fieldType === 'Instant' || fieldType === 'ZonedDateTime') { _%>
-
- .<%= fieldName %>ContentType, <%= entityInstance %>.<%= fieldName %>)}>
- <%_ if (fieldBlobType === 'image') { _%>
- .<%= fieldName %>ContentType};base64,${<%= entityInstance %>.<%= fieldName %>}`} style={{ maxHeight: '30px' }} />
- <%_ } else { _%>
-
- ) : null}
- <%_ } else { _%>
- {<%= entityInstance %>.<%= fieldName %>}
+ <%_ for (idx in relationships) { _%>
+ <%_ if (relationships[idx].relationshipType === 'many-to-one'
+ || (relationships[idx].relationshipType === 'one-to-one' && relationships[idx].ownerSide === true)
+ || (relationships[idx].relationshipType === 'many-to-many' && relationships[idx].ownerSide === true && pagination === 'no')) {
+ const fieldName = dto === 'no' ? "." + relationships[idx].otherEntityField : relationships[idx].otherEntityFieldCapitalized;_%>
+ <% } %>> |
+ <%_ } _%>
<%_ } _%>
- <%_ } else { _%>
- {<%= entityInstance %>.<%= fieldName %>}
- <%_ } _%>
- |
- <%_ } _%>
- <%_ for (idx in relationships) {
- const relationshipType = relationships[idx].relationshipType;
- const ownerSide = relationships[idx].ownerSide;
- const relationshipFieldName = relationships[idx].relationshipFieldName;
- const relationshipFieldNamePlural = relationships[idx].relationshipFieldNamePlural;
- const otherEntityName = relationships[idx].otherEntityName;
- const otherEntityStateName = relationships[idx].otherEntityStateName;
- const otherEntityField = relationships[idx].otherEntityField;
- const otherEntityFieldCapitalized = relationships[idx].otherEntityFieldCapitalized; _%>
- <%_ if (relationshipType === 'many-to-one'
- || (relationshipType === 'one-to-one' && ownerSide === true)
- || (relationshipType === 'many-to-many' && ownerSide === true && pagination === 'no')) { _%>
- - <%_ if (otherEntityName === 'user') { _%> - <%_ if (relationshipType === 'many-to-many') { _%> - { - (<%= entityInstance %>.<%= relationshipFieldNamePlural %>) ? - (<%= entityInstance %>.<%= relationshipFieldNamePlural %>.map((val, j) => - {val.<%= otherEntityField %>}{(j === <%= entityInstance %>.<%= relationshipFieldNamePlural %>.length - 1) ? '' : ', '} - ) - ) : null - } - <%_ } else { _%> - <%_ if (dto === 'no') { _%> - {<%= entityInstance + "." + relationshipFieldName %> ? <%= entityInstance + "." + relationshipFieldName + "." + otherEntityField %> : ''} + | + |
+ |
+ <%_ for (idx in fields) {
+ const fieldType = fields[idx].fieldType;
+ const fieldName = fields[idx].fieldName;
+ const fieldIsEnum = fields[idx].fieldIsEnum;
+ _%>
+
+ <%_ if (fieldType === 'Boolean') { _%>
+ {<%= entityInstance %>.<%=fields[idx].fieldName%> ? 'true' : 'false'}
+ <%_ } else if (fieldType === 'Instant' || fieldType === 'ZonedDateTime') { _%>
+
+ .<%= fieldName %>ContentType, <%= entityInstance %>.<%= fieldName %>)}>
+ <%_ if (fieldBlobType === 'image') { _%>
+ .<%= fieldName %>ContentType};base64,${<%= entityInstance %>.<%= fieldName %>}`} style={{ maxHeight: '30px' }} />
+ <%_ } else { _%>
+
+ ) : null}
<%_ } else { _%>
- {<%= entityInstance + "." + relationshipFieldName + otherEntityFieldCapitalized %> ? <%= entityInstance + "." + relationshipFieldName + otherEntityFieldCapitalized %> : ''}
- <%_ } _%>
- <%_ } _%>
+ {<%= entityInstance %>.<%= fieldName %>}
+ <%_ } _%>
<%_ } else { _%>
- <%_ if (relationshipType === 'many-to-many') { _%>
- {
- (<%= entityInstance %>.<%= relationshipFieldNamePlural %>) ?
- (<%= entityInstance %>.<%= relationshipFieldNamePlural %>.map((val, j) =>
- /${val.id}`}>{val.<%= otherEntityField %>}{(j === <%= entityInstance %>.<%= relationshipFieldNamePlural %>.length - 1) ? '' : ', '}
- )
- ) : null
- }
- <%_ } else { _%>
+ {<%= entityInstance %>.<%= fieldName %>}
+ <%_ } _%>
+ |
+ <%_ } _%>
+ <%_ for (idx in relationships) {
+ const relationshipType = relationships[idx].relationshipType;
+ const ownerSide = relationships[idx].ownerSide;
+ const relationshipFieldName = relationships[idx].relationshipFieldName;
+ const relationshipFieldNamePlural = relationships[idx].relationshipFieldNamePlural;
+ const otherEntityName = relationships[idx].otherEntityName;
+ const otherEntityStateName = relationships[idx].otherEntityStateName;
+ const otherEntityField = relationships[idx].otherEntityField;
+ const otherEntityFieldCapitalized = relationships[idx].otherEntityFieldCapitalized; _%>
+ <%_ if (relationshipType === 'many-to-one'
+ || (relationshipType === 'one-to-one' && ownerSide === true)
+ || (relationshipType === 'many-to-many' && ownerSide === true && pagination === 'no')) { _%>
+ + <%_ if (otherEntityName === 'user') { _%> + <%_ if (relationshipType === 'many-to-many') { _%> + { + (<%= entityInstance %>.<%= relationshipFieldNamePlural %>) ? + (<%= entityInstance %>.<%= relationshipFieldNamePlural %>.map((val, j) => + {val.<%= otherEntityField %>}{(j === <%= entityInstance %>.<%= relationshipFieldNamePlural %>.length - 1) ? '' : ', '} + ) + ) : null + } + <%_ } else { _%> <%_ if (dto === 'no') { _%> - {<%= entityInstance + "." + relationshipFieldName %> ? - /${<%= entityInstance + "." + relationshipFieldName + ".id}" %>`}> - {<%= entityInstance + "." + relationshipFieldName + "." + otherEntityField %>} - : ''} + {<%= entityInstance + "." + relationshipFieldName %> ? <%= entityInstance + "." + relationshipFieldName + "." + otherEntityField %> : ''} <%_ } else { _%> - {<%= entityInstance + "." + relationshipFieldName + otherEntityFieldCapitalized %> ? - /${<%= entityInstance + "." + relationshipFieldName + "Id}" %>`}> - {<%= entityInstance + "." + relationshipFieldName + otherEntityFieldCapitalized %>} - : ''} + {<%= entityInstance + "." + relationshipFieldName + otherEntityFieldCapitalized %> ? <%= entityInstance + "." + relationshipFieldName + otherEntityFieldCapitalized %> : ''} + <%_ } _%> + <%_ } _%> + <%_ } else { _%> + <%_ if (relationshipType === 'many-to-many') { _%> + { + (<%= entityInstance %>.<%= relationshipFieldNamePlural %>) ? + (<%= entityInstance %>.<%= relationshipFieldNamePlural %>.map((val, j) => + /${val.id}`}>{val.<%= otherEntityField %>}{(j === <%= entityInstance %>.<%= relationshipFieldNamePlural %>.length - 1) ? '' : ', '} + ) + ) : null + } + <%_ } else { _%> + <%_ if (dto === 'no') { _%> + {<%= entityInstance + "." + relationshipFieldName %> ? + /${<%= entityInstance + "." + relationshipFieldName + ".id}" %>`}> + {<%= entityInstance + "." + relationshipFieldName + "." + otherEntityField %>} + : ''} + <%_ } else { _%> + {<%= entityInstance + "." + relationshipFieldName + otherEntityFieldCapitalized %> ? + /${<%= entityInstance + "." + relationshipFieldName + "Id}" %>`}> + {<%= entityInstance + "." + relationshipFieldName + otherEntityFieldCapitalized %>} + : ''} + <%_ } _%> <%_ } _%> + <%_ } _%> + | <%_ } _%> - <%_ } _%> - - <%_ } _%> - <%_ } _%> -
-
-
- |
-
@@ -64,10 +66,10 @@ public class GatewayConfiguration {
public RateLimitingConfiguration(JHipsterProperties jHipsterProperties) {
this.jHipsterProperties = jHipsterProperties;
}
-
@Bean
public RateLimitingFilter rateLimitingFilter() {
return new RateLimitingFilter(jHipsterProperties);
}
}
+ <%_ } _%>
}
diff --git a/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs
index 48ca959db3c1..a3fee471a3ce 100644
--- a/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs
+++ b/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs
@@ -20,77 +20,79 @@ package <%= packageName %>.config;
<%_ if (authenticationType === 'session' || authenticationType === 'jwt' || authenticationType === 'oauth2') { _%>
import <%= packageName %>.security.*;
-<%_ if (authenticationType === 'jwt') { _%>
+ <%_ if (authenticationType === 'jwt') { _%>
import <%= packageName %>.security.jwt.*;
-<%_ } _%>
-<%_ if (authenticationType === 'session') { _%>
+ <%_ } _%>
+ <%_ if (authenticationType === 'session') { _%>
- <%_ if (!skipUserManagement) { _%>
+ <%_ if (!skipUserManagement) { _%>
import io.github.jhipster.config.JHipsterProperties;
- <%_ } _%>
+ <%_ } _%>
import io.github.jhipster.security.*;
-<%_ } _%>
+ <%_ } _%>
-<%_ if (authenticationType !== 'oauth2' && !skipUserManagement) { _%>
+ <%_ if (authenticationType !== 'oauth2' && !skipUserManagement) { _%>
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.InitializingBean;
-<%_ } _%>
+ <%_ } _%>
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
-<%_ if (authenticationType !== 'uaa' && !(applicationType === 'microservice' && authenticationType === 'oauth2')) { _%>
+ <%_ if (authenticationType !== 'uaa' && !(applicationType === 'microservice' && authenticationType === 'oauth2')) { _%>
import org.springframework.http.HttpMethod;
-<%_ } _%>
+ <%_ } _%>
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-<%_ if (authenticationType !== 'uaa' && !(applicationType === 'microservice' && authenticationType === 'oauth2')) { _%>
+ <%_ if (authenticationType !== 'uaa' && !(applicationType === 'microservice' && authenticationType === 'oauth2')) { _%>
import org.springframework.security.config.annotation.web.builders.WebSecurity;
-<%_ } _%>
+ <%_ } _%>
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-<%_ if (authenticationType === 'jwt' || (authenticationType === 'oauth2' && applicationType === 'microservice')) { _%>
+ <%_ if (authenticationType === 'jwt' || (authenticationType === 'oauth2' && applicationType === 'microservice')) { _%>
import org.springframework.security.config.http.SessionCreationPolicy;
-<%_ } _%>
-<%_ if (authenticationType !== 'oauth2' && !skipUserManagement) { _%>
+ <%_ } _%>
+ <%_ if (authenticationType !== 'oauth2' && !skipUserManagement) { _%>
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
-<%_ } _%>
-<%_ if (authenticationType === 'oauth2') { _%>
+ <%_ } _%>
+ <%_ if (authenticationType === 'oauth2') { _%>
import <%= packageName %>.security.oauth2.AudienceValidator;
+import <%=packageName%>.security.SecurityUtils;
import org.springframework.security.oauth2.core.DelegatingOAuth2TokenValidator;
import org.springframework.security.oauth2.core.OAuth2TokenValidator;
import org.springframework.security.oauth2.jwt.*;
- <%_ if (applicationType === 'gateway') { _%>
+ <%_ if (applicationType === 'gateway') { _%>
import <%=packageName%>.security.oauth2.AuthorizationHeaderFilter;
import <%=packageName%>.security.oauth2.AuthorizationHeaderUtil;
- <%_ } _%>
+ <%_ } _%>
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
+ <%_ if (applicationType !== 'microservice') { _%>
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
-import org.springframework.security.oauth2.core.oidc.OidcUserInfo;
import org.springframework.security.oauth2.core.oidc.user.OidcUserAuthority;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.stream.Collectors;
-<%_ } _%>
-<%_ if (authenticationType === 'session') { _%>
- <%_ if (!skipUserManagement) { _%>
-import org.springframework.security.web.authentication.RememberMeServices;
+ <%_ } _%>
+import java.util.*;
<%_ } _%>
+ <%_ if (authenticationType === 'session') { _%>
+ <%_ if (!skipUserManagement) { _%>
+import org.springframework.security.web.authentication.RememberMeServices;
+ <%_ } _%>
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
import org.springframework.security.web.csrf.CsrfFilter;
-<%_ } _%>
-<%_ if (authenticationType === 'oauth2' && applicationType !== 'microservice') { _%>
+ <%_ } _%>
+ <%_ if (authenticationType === 'oauth2' && applicationType !== 'microservice') { _%>
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
import org.springframework.security.web.csrf.CsrfFilter;
-<%_ } _%>
-<%_ if (authenticationType === 'jwt' && applicationType !== 'microservice') { _%>
+ <%_ } _%>
+ <%_ if (authenticationType === 'oauth2') { _%>
+import <%=packageName%>.security.oauth2.JwtAuthorityExtractor;
+ <%_ } _%>
+ <%_ if (authenticationType === 'jwt' && applicationType !== 'microservice') { _%>
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
-<%_ } _%>
-<%_ if (applicationType !== 'microservice') { _%>
+ <%_ } _%>
+import org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter;
+ <%_ if (applicationType !== 'microservice') { _%>
import org.springframework.web.filter.CorsFilter;
-<%_ } _%>
+ <%_ } _%>
import org.zalando.problem.spring.web.advice.security.SecurityProblemSupport;
@EnableWebSecurity
@@ -115,21 +117,26 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Value("${spring.security.oauth2.client.provider.oidc.issuer-uri}")
private String issuerUri;
+
+ private final JwtAuthorityExtractor jwtAuthorityExtractor;
<%_ } _%>
private final SecurityProblemSupport problemSupport;
- public SecurityConfiguration(<% if (authenticationType === 'session' && !skipUserManagement) { %>JHipsterProperties jHipsterProperties, RememberMeServices rememberMeServices, <% } if (authenticationType === 'jwt') { %>TokenProvider tokenProvider, <% } %><% if (applicationType !== 'microservice') { %>CorsFilter corsFilter, <% } %>SecurityProblemSupport problemSupport) {
- <%_ if (authenticationType === 'session' && !skipUserManagement) { _%>
+ public SecurityConfiguration(<% if (authenticationType === 'session' && !skipUserManagement) { %>JHipsterProperties jHipsterProperties, RememberMeServices rememberMeServices, <% } if (authenticationType === 'jwt') { %>TokenProvider tokenProvider, <% } %><% if (applicationType !== 'microservice') { %>CorsFilter corsFilter, <% } %><% if (authenticationType === 'oauth2') { %>JwtAuthorityExtractor jwtAuthorityExtractor, <% } %>SecurityProblemSupport problemSupport) {
+ <%_ if (authenticationType === 'session' && !skipUserManagement) { _%>
this.jHipsterProperties = jHipsterProperties;
this.rememberMeServices = rememberMeServices;
- <%_ } _%>
- <%_ if (authenticationType === 'jwt') { _%>
+ <%_ } _%>
+ <%_ if (authenticationType === 'jwt') { _%>
this.tokenProvider = tokenProvider;
- <%_ } _%>
- <%_ if (applicationType !== 'microservice') { _%>
+ <%_ } _%>
+ <%_ if (applicationType !== 'microservice') { _%>
this.corsFilter = corsFilter;
- <%_ } _%>
+ <%_ } _%>
this.problemSupport = problemSupport;
+ <%_ if (authenticationType === 'oauth2') { _%>
+ this.jwtAuthorityExtractor = jwtAuthorityExtractor;
+ <%_ } _%>
}
<%_ if (authenticationType === 'session') { _%>
@@ -142,8 +149,6 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
public AjaxAuthenticationFailureHandler ajaxAuthenticationFailureHandler() {
return new AjaxAuthenticationFailureHandler();
}
- <%_ } _%>
- <%_ if (authenticationType === 'session') { _%>
@Bean
public AjaxLogoutSuccessHandler ajaxLogoutSuccessHandler() {
@@ -157,20 +162,20 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
return new BCryptPasswordEncoder();
}
<%_ } _%>
- <%_ if (authenticationType !== 'uaa' && !(applicationType === 'microservice' && authenticationType === 'oauth2')) { _%>
+ <%_ if (authenticationType !== 'uaa' && applicationType !== 'microservice') { _%>
@Override
- public void configure(WebSecurity web) throws Exception {
+ public void configure(WebSecurity web) {
web.ignoring()
.antMatchers(HttpMethod.OPTIONS, "/**")
- <%_ if (!skipClient) { _%>
+ <%_ if (!skipClient) { _%>
.antMatchers("/app/**/*.{js,html}")
.antMatchers("/i18n/**")
.antMatchers("/content/**")
- <%_ } _%>
- <%_ if (devDatabaseType === 'h2Disk' || devDatabaseType === 'h2Memory') { _%>
+ <%_ } _%>
+ <%_ if (devDatabaseType === 'h2Disk' || devDatabaseType === 'h2Memory') { _%>
.antMatchers("/h2-console/**")
- <%_ } _%>
+ <%_ } _%>
.antMatchers("/swagger-ui/index.html")
.antMatchers("/test/**");
}
@@ -181,93 +186,102 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
// @formatter:off
http
.csrf()
- <%_ if (['session','oauth2'].includes(authenticationType) && applicationType !== 'microservice') { _%>
+ <%_ if (['session','oauth2'].includes(authenticationType) && applicationType !== 'microservice') { _%>
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.and()
- <%_ } else{ _%>
+ <%_ } else { _%>
.disable()
- <%_ } _%>
- <%_ if (applicationType !== 'microservice') { _%>
- <%_ if (authenticationType === 'jwt') { _%>
+ <%_ } _%>
+ <%_ if (applicationType !== 'microservice') { _%>
+ <%_ if (authenticationType === 'jwt') { _%>
.addFilterBefore(corsFilter, UsernamePasswordAuthenticationFilter.class)
- <%_ } else if (authenticationType === 'session' || authenticationType === 'oauth2') { _%>
+ <%_ } else if (authenticationType === 'session' || authenticationType === 'oauth2') { _%>
.addFilterBefore(corsFilter, CsrfFilter.class)
- <%_ } _%>
- <%_ } _%>
+ <%_ } _%>
+ <%_ } _%>
.exceptionHandling()
- <%_ if (authenticationType !== 'oauth2') { _%>
+ <%_ if (authenticationType !== 'oauth2') { _%>
.authenticationEntryPoint(problemSupport)
- <%_ } _%>
+ <%_ } _%>
.accessDeniedHandler(problemSupport)
- <%_ if (authenticationType === 'session') { _%>
- <%_ if (!skipUserManagement) { _%>
+ <%_ if (authenticationType === 'session') { _%>
+ <%_ if (!skipUserManagement) { _%>
.and()
.rememberMe()
.rememberMeServices(rememberMeServices)
.rememberMeParameter("remember-me")
.key(jHipsterProperties.getSecurity().getRememberMe().getKey())
- <%_ } _%>
+ <%_ } _%>
.and()
.formLogin()
.loginProcessingUrl("/api/authentication")
.successHandler(ajaxAuthenticationSuccessHandler())
.failureHandler(ajaxAuthenticationFailureHandler())
.permitAll()
- <%_ } _%>
- <%_ if (authenticationType === 'session') { _%>
.and()
.logout()
.logoutUrl("/api/logout")
.logoutSuccessHandler(ajaxLogoutSuccessHandler())
.permitAll()
- <%_ } _%>
+ <%_ } _%>
.and()
.headers()
+ .contentSecurityPolicy("default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:")
+ .and()
+ .referrerPolicy(ReferrerPolicyHeaderWriter.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN)
+ .and()
+ .featurePolicy("geolocation 'none'; midi 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; speaker 'none'; fullscreen 'self'; payment 'none'")
+ .and()
.frameOptions()
- .disable()
+ .deny()
.and()
- <%_ if (authenticationType === 'jwt' || (authenticationType === 'oauth2' && applicationType === 'microservice')) { _%>
+ <%_ if (authenticationType === 'jwt' || (authenticationType === 'oauth2' && applicationType === 'microservice')) { _%>
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
- <%_ } _%>
+ <%_ } _%>
.authorizeRequests()
- <%_ if (authenticationType !== 'oauth2') { _%>
+ <%_ if (authenticationType !== 'oauth2') { _%>
.antMatchers("/api/authenticate").permitAll()
- <%_ } _%>
- <%_ if (authenticationType !== 'oauth2' && !skipUserManagement) { _%>
+ <%_ } _%>
+ <%_ if (authenticationType !== 'oauth2' && !skipUserManagement) { _%>
.antMatchers("/api/register").permitAll()
.antMatchers("/api/activate").permitAll()
.antMatchers("/api/account/reset-password/init").permitAll()
.antMatchers("/api/account/reset-password/finish").permitAll()
- <%_ } _%>
- .antMatchers("/api/**").authenticated()
- <%_ if (authenticationType === 'oauth2') { _%>
+ <%_ } _%>
+ <%_ if (authenticationType === 'oauth2') { _%>
.antMatchers("/api/auth-info").permitAll()
- <%_ } _%>
- <%_ if (websocket === 'spring-websocket') { _%>
+ <%_ } _%>
+ .antMatchers("/api/**").authenticated()
+ <%_ if (websocket === 'spring-websocket') { _%>
.antMatchers("/websocket/tracker").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/websocket/**").permitAll()
- <%_ } _%>
+ <%_ } _%>
.antMatchers("/management/health").permitAll()
.antMatchers("/management/info").permitAll()
.antMatchers("/management/prometheus").permitAll()
.antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)<%_ if (authenticationType === 'session') { %>;<% } %>
- <%_ if (authenticationType === 'jwt') { _%>
- <%_ if (applicationType === 'monolith') { _%>
+ <%_ if (authenticationType === 'jwt') { _%>
+ <%_ if (applicationType === 'monolith') { _%>
.and()
.httpBasic()
- <%_ } _%>
+ <%_ } _%>
.and()
.apply(securityConfigurerAdapter());
- <%_ } else if (authenticationType === 'oauth2') { _%>
- <%_ if (['monolith', 'gateway'].includes(applicationType)) { _%>
+ <%_ } else if (authenticationType === 'oauth2') { _%>
+ <%_ if (['monolith', 'gateway'].includes(applicationType)) { _%>
.and()
.oauth2Login()
- <%_ } _%>
- .and()
- .oauth2ResourceServer().jwt();
<%_ } _%>
+ .and()
+ .oauth2ResourceServer()
+ .jwt()
+ .jwtAuthenticationConverter(jwtAuthorityExtractor)
+ .and()
+ .and()
+ .oauth2Client();
+ <%_ } _%>
// @formatter:on
}
<%_ if (authenticationType === 'jwt') { _%>
@@ -278,6 +292,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
<%_ } _%>
<%_ if (authenticationType === 'oauth2') { _%>
+ <%_ if (applicationType !== 'microservice') { _%>
/**
* Map authorities from "groups" or "roles" claim in ID Token.
*
@@ -285,26 +300,18 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
* the IdP to Spring Security Authorities.
*/
@Bean
- @SuppressWarnings("unchecked")
public GrantedAuthoritiesMapper userAuthoritiesMapper() {
return (authorities) -> {
Set> getAll(@RequestParam MultiValueMap
> getAll(<% if (reactive) { %>ServerHttpRequest request, <% } %>Pageable pageable) {
Page
> getByDates(
@RequestParam(value = "fromDate") LocalDate fromDate,
@RequestParam(value = "toDate") LocalDate toDate,
- @RequestParam MultiValueMap
>> getAllUsers(@RequestParam MultiValueMap
>> getAllUsers(Pageable pageable) {
final Page<<%= asDto('User') %>> page = userService.getAllManagedUsers(pageable);
- HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(uriBuilder.queryParams(queryParams), page);
+ HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
<%_ } else { _%>
- public Mono