Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump spring-boot to v3.3.0 #26242

Merged
merged 12 commits into from
May 23, 2024
3 changes: 1 addition & 2 deletions generators/server/templates/build.gradle.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ dependencies {
testRuntimeOnly("com.tngtech.archunit:archunit-junit5-engine:${archunitJunit5Version}") {
exclude group: "org.slf4j", module: "slf4j-api"
}
implementation "io.dropwizard.metrics:metrics-core"
implementation "io.micrometer:micrometer-registry-prometheus"
implementation "io.micrometer:micrometer-registry-prometheus-simpleclient"
<%_ if (reactive) { _%>
runtimeOnly "io.netty:netty-tcnative-boringssl-static"
<%_ } _%>
Expand Down
6 changes: 1 addition & 5 deletions generators/server/templates/pom.xml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@
<version>${archunit-junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>
<%_ if (reactive) { _%>
<dependency>
<groupId>io.micrometer</groupId>
Expand All @@ -126,7 +122,7 @@
<%_ } _%>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<artifactId>micrometer-registry-prometheus-simpleclient</artifactId>
</dependency>
<%_ if (reactive) { _%>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ import static org.springframework.security.web.util.matcher.AntPathRequestMatche
<%_ } _%>
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
<%_ if (authenticationTypeOauth2) { _%>
import org.springframework.core.convert.converter.Converter;
<%_ } _%>
<%_ if (devDatabaseTypeH2Any) { _%>
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
Expand Down Expand Up @@ -70,7 +67,6 @@ import static org.springframework.security.oauth2.core.oidc.StandardClaimNames.P

import <%= packageName %>.security.oauth2.AudienceValidator;
import <%= packageName %>.security.SecurityUtils;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.oauth2.client.userinfo.OAuth2UserService;
import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest;
import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService;
Expand All @@ -79,7 +75,6 @@ import org.springframework.security.oauth2.core.OAuth2TokenValidator;
import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
import org.springframework.security.oauth2.jwt.*;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.GrantedAuthority;
<%_ if (!applicationTypeMicroservice) { _%>
Expand All @@ -103,9 +98,6 @@ import org.springframework.security.web.authentication.RememberMeServices;
<%_ if (authenticationUsesCsrf && !applicationTypeMicroservice) { _%>
import org.springframework.security.web.csrf.*;
<%_ } _%>
<%_ if (authenticationTypeOauth2) { _%>
import <%= packageName %>.security.oauth2.JwtGrantedAuthorityConverter;
<%_ } _%>
<%_ if (authenticationTypeJwt) { _%>
import org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationEntryPoint;
import org.springframework.security.oauth2.server.resource.web.access.BearerTokenAccessDeniedHandler;
Expand Down Expand Up @@ -292,9 +284,7 @@ public class SecurityConfiguration {
<%_ } else { _%>
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
<%_ } _%>
.oauth2ResourceServer(oauth2 -> oauth2
.jwt(jwt -> jwt
.jwtAuthenticationConverter(authenticationConverter())))
.oauth2ResourceServer(oauth2 -> oauth2.jwt(withDefaults()))
.oauth2Client(withDefaults());
<%_ } _%>
<%_ if (devDatabaseTypeH2Any) { _%>
Expand All @@ -315,13 +305,6 @@ public class SecurityConfiguration {
}
<%_ if (authenticationTypeOauth2) { _%>

Converter<Jwt, AbstractAuthenticationToken> authenticationConverter() {
JwtAuthenticationConverter jwtAuthenticationConverter = new JwtAuthenticationConverter();
jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter(new JwtGrantedAuthorityConverter());
jwtAuthenticationConverter.setPrincipalClaimName(PREFERRED_USERNAME);
return jwtAuthenticationConverter;
}

OAuth2UserService<OidcUserRequest, OidcUser> oidcUserService() {
final OidcUserService delegate = new OidcUserService();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import static org.springframework.security.oauth2.core.oidc.StandardClaimNames.P

import <%= packageName %>.security.SecurityUtils;
import <%= packageName %>.security.oauth2.AudienceValidator;
import <%= packageName %>.security.oauth2.JwtGrantedAuthorityConverter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
import org.springframework.beans.factory.annotation.Value;
<%_ } _%>
<%_ if (authenticationUsesCsrf) { _%>
Expand All @@ -42,7 +39,6 @@ import <%= packageName %>.web.filter.SpaWebFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
<%_ if (authenticationTypeOauth2) { _%>
import org.springframework.core.convert.converter.Converter;
<%_ if (!applicationTypeMicroservice) { _%>
import org.springframework.core.ParameterizedTypeReference;
<%_ } _%>
Expand Down Expand Up @@ -81,7 +77,6 @@ import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
import org.springframework.security.oauth2.core.oidc.user.OidcUserAuthority;
import org.springframework.security.oauth2.jwt.*;
import org.springframework.security.oauth2.server.resource.authentication.ReactiveJwtAuthenticationConverterAdapter;
<%_ } _%>
<%_ if (!authenticationTypeOauth2) { _%>
import org.springframework.security.authentication.ReactiveAuthenticationManager;
Expand Down Expand Up @@ -308,9 +303,7 @@ public class SecurityConfiguration {
.oauth2Login(oauth2 -> oauth2.authorizationRequestResolver(authorizationRequestResolver(this.clientRegistrationRepository)))
<%_ } _%>
.oauth2Client(withDefaults())
.oauth2ResourceServer(oauth2 -> oauth2
.jwt(jwt -> jwt
.jwtAuthenticationConverter(jwtAuthenticationConverter())));
.oauth2ResourceServer(oauth2 -> oauth2.jwt(withDefaults()));
<%_ } else if (authenticationTypeJwt) { _%>
.httpBasic(basic -> basic.disable())
.oauth2ResourceServer(oauth2 -> oauth2.jwt(withDefaults()));
Expand Down Expand Up @@ -338,13 +331,6 @@ public class SecurityConfiguration {
}
<%_ } _%>

Converter<Jwt, Mono<AbstractAuthenticationToken>> jwtAuthenticationConverter() {
JwtAuthenticationConverter jwtAuthenticationConverter = new JwtAuthenticationConverter();
jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter(new JwtGrantedAuthorityConverter());
jwtAuthenticationConverter.setPrincipalClaimName(PREFERRED_USERNAME);
return new ReactiveJwtAuthenticationConverterAdapter(jwtAuthenticationConverter);
}

/**
* Map authorities from "groups" or "roles" claim in ID Token.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ import org.springframework.security.oauth2.jwt.<%= reactive ? 'Reactive' : '' %>
import org.springframework.security.oauth2.jwt.JwtEncoder;
import org.springframework.security.oauth2.jwt.Nimbus<%= reactive ? 'Reactive' : '' %>JwtDecoder;
import org.springframework.security.oauth2.jwt.NimbusJwtEncoder;
import org.springframework.security.oauth2.server.resource.authentication.<%= reactive ? 'Reactive' : '' %>JwtAuthenticationConverter;
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
<%_ if (reactive) { _%>
import org.springframework.security.oauth2.server.resource.authentication.ReactiveJwtGrantedAuthoritiesConverterAdapter;
<%_ } _%>
<%_ if (communicationSpringWebsocket) { %>
import org.springframework.security.oauth2.server.resource.web.BearerTokenResolver;
import org.springframework.security.oauth2.server.resource.web.DefaultBearerTokenResolver;
Expand Down Expand Up @@ -113,21 +108,6 @@ public class SecurityJwtConfiguration {
return new NimbusJwtEncoder(new ImmutableSecret<>(getSecretKey()));
}

@Bean
public <%= reactive ? 'Reactive' : '' %>JwtAuthenticationConverter jwtAuthenticationConverter() {
JwtGrantedAuthoritiesConverter grantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
grantedAuthoritiesConverter.setAuthorityPrefix("");
grantedAuthoritiesConverter.setAuthoritiesClaimName(AUTHORITIES_KEY);

<%= reactive ? 'Reactive' : '' %>JwtAuthenticationConverter jwtAuthenticationConverter = new <%= reactive ? 'Reactive' : '' %>JwtAuthenticationConverter();
<%_ if (reactive) { %>
jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter(new ReactiveJwtGrantedAuthoritiesConverterAdapter(grantedAuthoritiesConverter));
<%_ } else { _%>
jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter(grantedAuthoritiesConverter);
<%_ } _%>
return jwtAuthenticationConverter;
}

<%_ if (communicationSpringWebsocket) { %>
@Bean
public BearerTokenResolver bearerTokenResolver() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,43 @@ spring:
<% if (reactive) { %>webflux<% } else { %>mvc<% } %>:
problemdetails:
enabled: true
<%_ if (generateInMemoryUserCredentials) { _%>
<%_ if (generateInMemoryUserCredentials || authenticationTypeOauth2 || authenticationTypeJwt) { _%>
security:
<%_ if (generateInMemoryUserCredentials) { _%>
user:
name: admin
password: admin
roles:
- ADMIN
- USER
<%_ } _%>
<%_ if (authenticationTypeOauth2) { _%>
oauth2:
client:
provider:
oidc:
issuer-uri: http://localhost:9080/realms/jhipster
registration:
oidc:
<%_ if (applicationTypeMicroservice) { _%>
client-id: internal
client-secret: internal
<%_ } else { _%>
client-id: web_app
client-secret: web_app
<%_ } _%>
scope: openid, profile, email, offline_access # last one for refresh tokens
resourceserver:
jwt:
principal-claim-name: preferred_username
<%_ } _%>
<%_ if (authenticationTypeJwt) { _%>
oauth2:
resourceserver:
jwt:
authority-prefix: ''
authorities-claim-name: auth
<%_ } _%>
<%_ } _%>
task:
execution:
Expand All @@ -360,24 +389,6 @@ spring:
output:
ansi:
console-available: true
<%_ if (authenticationTypeOauth2) { _%>
security:
oauth2:
client:
provider:
oidc:
issuer-uri: http://localhost:9080/realms/jhipster
registration:
oidc:
<%_ if (applicationTypeMicroservice) { _%>
client-id: internal
client-secret: internal
<%_ } else { _%>
client-id: web_app
client-secret: web_app
<%_ } _%>
scope: openid, profile, email, offline_access # last one for refresh tokens
<%_ } _%>

server:
servlet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,32 @@ spring:
allow-bean-definition-overriding: true
messages:
basename: i18n/messages
<%_ if (generateInMemoryUserCredentials) { _%>
<%_ if (generateInMemoryUserCredentials || authenticationTypeOauth2 || authenticationTypeJwt) { _%>
security:
<%_ if (generateInMemoryUserCredentials) { _%>
user:
name: test
password: test
roles:
- USER
<%_ } _%>
<%_ if (authenticationTypeOauth2) { _%>
oauth2:
client:
provider:
oidc:
issuer-uri: http://DO_NOT_CALL:9080/realms/jhipster
resourceserver:
jwt:
principal-claim-name: preferred_username
<%_ } _%>
<%_ if (authenticationTypeJwt) { _%>
oauth2:
resourceserver:
jwt:
authority-prefix: ''
authorities-claim-name: auth
<%_ } _%>
<%_ } _%>
task:
execution:
Expand All @@ -153,15 +172,6 @@ spring:
size: 20
thymeleaf:
mode: HTML
<%_ if (authenticationTypeOauth2) { _%>
# Allow SecurityConfiguration to initialize w/o specifying an empty issuer-uri is OK
security:
oauth2:
client:
provider:
oidc:
issuer-uri: http://DO_NOT_CALL:9080/realms/jhipster
<%_ } _%>

server:
port: 10344
Expand Down
Loading
Loading