diff --git a/generators/server/__snapshots__/generator.spec.mjs.snap b/generators/server/__snapshots__/generator.spec.mjs.snap index 50067119..762fada5 100644 --- a/generators/server/__snapshots__/generator.spec.mjs.snap +++ b/generators/server/__snapshots__/generator.spec.mjs.snap @@ -299,6 +299,12 @@ Object { "src/main/resources/.h2.server.properties": Object { "stateCleared": "modified", }, + "src/main/resources/META-INF/native-image/jwt/reflect-config.json": Object { + "stateCleared": "modified", + }, + "src/main/resources/META-INF/native-image/jwt/resource-config.json": Object { + "stateCleared": "modified", + }, "src/main/resources/META-INF/native-image/liquibase/reflect-config.json": Object { "stateCleared": "modified", }, diff --git a/generators/server/generator.mjs b/generators/server/generator.mjs index de9955c1..9c68fb31 100644 --- a/generators/server/generator.mjs +++ b/generators/server/generator.mjs @@ -262,6 +262,18 @@ logging: ); }, + async jwt({ application: { authenticationTypeOauth2 } }) { + if (authenticationTypeOauth2) return; + await this.copyTemplate( + 'src/main/resources/META-INF/native-image/jwt/reflect-config.json', + 'src/main/resources/META-INF/native-image/jwt/reflect-config.json' + ); + await this.copyTemplate( + 'src/main/resources/META-INF/native-image/jwt/resource-config.json', + 'src/main/resources/META-INF/native-image/jwt/resource-config.json' + ); + }, + async liquibase({ application: { databaseTypeSql } }) { if (!databaseTypeSql) return; await this.copyTemplate( diff --git a/generators/server/templates/src/main/resources/META-INF/native-image/jwt/reflect-config.json b/generators/server/templates/src/main/resources/META-INF/native-image/jwt/reflect-config.json new file mode 100644 index 00000000..88ef51fc --- /dev/null +++ b/generators/server/templates/src/main/resources/META-INF/native-image/jwt/reflect-config.json @@ -0,0 +1,38 @@ +[ + { + "name": "io.jsonwebtoken.impl.compression.GzipCompressionCodec", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "io.jsonwebtoken.impl.compression.DeflateCompressionCodec", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "io.jsonwebtoken.impl.DefaultJwtParserBuilder", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "io.jsonwebtoken.impl.DefaultJwtBuilder", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] diff --git a/generators/server/templates/src/main/resources/META-INF/native-image/jwt/resource-config.json b/generators/server/templates/src/main/resources/META-INF/native-image/jwt/resource-config.json new file mode 100644 index 00000000..4097a33f --- /dev/null +++ b/generators/server/templates/src/main/resources/META-INF/native-image/jwt/resource-config.json @@ -0,0 +1,13 @@ +{ + "resources": [ + { + "pattern": "META-INF/services/io.jsonwebtoken.CompressionCodec" + }, + { + "pattern": "META-INF/services/io.jsonwebtoken.io.Deserializer" + }, + { + "pattern": "META-INF/services/io.jsonwebtoken.io.Serializer" + } + ] +} diff --git a/test-integration/samples/postgresql-mvc-jwt.jdl b/test-integration/samples/postgresql-mvc-jwt.jdl new file mode 100644 index 00000000..38c87273 --- /dev/null +++ b/test-integration/samples/postgresql-mvc-jwt.jdl @@ -0,0 +1,36 @@ +application { + config { + applicationType monolith + cacheProvider no + creationTimestamp 1632872179205 + devDatabaseType h2Disk + enableHibernateCache false + enableTranslation false + testFrameworks [cypress] + } + + entities Blog, Post, Tag +} + +entity Blog { + name String required minlength(3) + handle String required minlength(2) +} + +entity Post { + title String required + content TextBlob required + date Instant required +} + +entity Tag { + name String required minlength(2) +} + +relationship ManyToOne { + Post{blog(name)} to Blog +} + +relationship ManyToMany { + Post{tag(name)} to Tag{entry} +} diff --git a/test-integration/samples/postgresql-webflux-jwt.jdl b/test-integration/samples/postgresql-webflux-jwt.jdl new file mode 100644 index 00000000..b19b5662 --- /dev/null +++ b/test-integration/samples/postgresql-webflux-jwt.jdl @@ -0,0 +1,35 @@ +application { + config { + applicationType monolith + authenticationType oauth2 + creationTimestamp 1632872179205 + reactive true + enableTranslation false + testFrameworks [cypress] + } + + entities Blog, Post, Tag +} + +entity Blog { + name String required minlength(3) + handle String required minlength(2) +} + +entity Post { + title String required + content TextBlob required + date Instant required +} + +entity Tag { + name String required minlength(2) +} + +relationship ManyToOne { + Post{blog(name)} to Blog +} + +relationship ManyToMany { + Post{tag(name)} to Tag{entry} +}