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

graalvm: adjusts #27763

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generators/java/generators/graalvm/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export default class GraalvmGenerator extends BaseApplicationGenerator {
nativeBuildToolsVersion: javaDependencies!.nativeBuildTools!,
databaseTypeSql,
userLanguage: nativeLanguageDefinition.languageTag,
languages: languagesDefinition.map(def => def.languageTag),
languages: languagesDefinition?.map(def => def.languageTag) ?? [nativeLanguageDefinition.languageTag],
}),
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ graalvmNative {
// vendor = JvmVendorSpec.matching("GraalVM Community")
//}
buildArgs.add("-Duser.language=<%- nativeLanguageDefinition.languageTag %>")
buildArgs.add("-H:IncludeLocales=<%- languagesDefinition.map(def => def.languageTag).join(',') %>")
buildArgs.add("-H:IncludeLocales=<%- languagesDefinition?.map(def => def.languageTag)?.join(',') ?? nativeLanguageDefinition.languageTag %>")
}
}
binaries.all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.oauth2.core.oidc.OidcIdToken;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.servlet.http.HttpServletRequest;
Expand All @@ -44,18 +44,18 @@ public class LogoutResource {
* {@code POST /api/logout} : logout the current user.
*
* @param request the {@link HttpServletRequest}.
* @param idToken the ID token.
* @param oidcUser the OIDC user.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and a body with a global logout URL.
*/
@PostMapping("/api/logout")
public ResponseEntity<?> logout(HttpServletRequest request, @AuthenticationPrincipal(expression = "idToken") OidcIdToken idToken) {
public ResponseEntity<?> logout(HttpServletRequest request, @AuthenticationPrincipal OidcUser oidcUser) {
StringBuilder logoutUrl = new StringBuilder();

logoutUrl.append(this.registration.getProviderDetails().getConfigurationMetadata().get("end_session_endpoint").toString());

String originUrl = request.getHeader(HttpHeaders.ORIGIN);

logoutUrl.append("?id_token_hint=").append(idToken.getTokenValue()).append("&post_logout_redirect_uri=").append(originUrl);
logoutUrl.append("?id_token_hint=").append(oidcUser.getIdToken().getTokenValue()).append("&post_logout_redirect_uri=").append(originUrl);

request.getSession().invalidate();
return ResponseEntity.ok().body(Map.of("logoutUrl", logoutUrl.toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository;
import org.springframework.security.oauth2.core.oidc.OidcIdToken;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.WebSession;
Expand All @@ -43,18 +44,18 @@ public class LogoutResource {
/**
* {@code POST /api/logout} : logout the current user.
*
* @param idToken the ID token.
* @param oidcUser the OIDC user.
* @param request a {@link ServerHttpRequest} request.
* @param session the current {@link WebSession}.
* @return status {@code 200 (OK)} and a body with a global logout URL.
*/
@PostMapping("/api/logout")
public Mono<Map<String, String>> logout(
@AuthenticationPrincipal(expression = "idToken") OidcIdToken idToken,
@AuthenticationPrincipal OidcUser oidcUser,
ServerHttpRequest request,
WebSession session
) {
return session.invalidate().then(this.registration.map(oidc -> prepareLogoutUri(request, oidc, idToken)));
return session.invalidate().then(this.registration.map(oidc -> prepareLogoutUri(request, oidc, oidcUser.getIdToken())));
}

private Map<String, String> prepareLogoutUri(ServerHttpRequest request, ClientRegistration clientRegistration, OidcIdToken idToken) {
Expand Down
10 changes: 6 additions & 4 deletions generators/spring-data-relational/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,15 @@ export default class SqlGenerator extends BaseApplicationGenerator {
publicConstructors: ['org.hibernate.binder.internal.BatchSizeBinder.class'],
});
},
async nativeMavenBuildTool({ application, source }) {
if (!application.buildToolMaven || !application.graalvmSupport) return;

source.addMavenProperty!({ property: 'spring.h2.console.enabled', value: 'true' });
},
async nativeGradleBuildTool({ application, source }) {
if (!application.buildToolGradle || !application.graalvmSupport) return;

const { reactive, javaManagedProperties, buildToolMaven } = application;
if (buildToolMaven) {
source.addMavenProperty!({ property: 'spring.h2.console.enabled', value: 'true' });
}
const { reactive, javaManagedProperties } = application;
if (!reactive) {
source.addGradleDependencyCatalogVersion!({ name: 'hibernate', version: javaManagedProperties!['hibernate.version']! });
source.addGradleDependencyCatalogPlugin!({
Expand Down
Loading