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

add jwt reflect and resource config to support jwt authentication type #59

Merged
merged 6 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 0 deletions .github/workflows/jdl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
suite:
- postgresql-mvc
- postgresql-webflux
- postgresql-mvc-jwt
- postgresql-webflux-jwt
include:
- os: ubuntu-20.04
build-tool: gradle
Expand Down
9 changes: 9 additions & 0 deletions generators/server/__snapshots__/generator.spec.mjs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ Object {
"src/main/resources/.h2.server.properties": Object {
"stateCleared": "modified",
},
"src/main/resources/META-INF/native-image/common/reflect-config.json": 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",
},
Expand Down
30 changes: 30 additions & 0 deletions generators/server/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,36 @@ logging:
);
},

async asyncConfiguration({ application: { authenticationTypeOauth2, reactive, packageFolder } }) {
if (authenticationTypeOauth2) return;
if (!reactive) {
const asyncConfigurationPath = `${SERVER_MAIN_SRC_DIR}${packageFolder}/config/AsyncConfiguration.java`;
this.editFile(asyncConfigurationPath, content =>
content.replace(
'return new ExceptionHandlingAsyncTaskExecutor(executor);',
'executor.initialize();\nreturn new ExceptionHandlingAsyncTaskExecutor(executor);'
)
);
}
},
async jwt({ application: { authenticationTypeOauth2, reactive } }) {
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'
);
if (!reactive) {
await this.copyTemplate(
'src/main/resources/META-INF/native-image/common/reflect-config.json',
'src/main/resources/META-INF/native-image/common/reflect-config.json'
);
}
},

async liquibase({ application: { databaseTypeSql } }) {
if (!databaseTypeSql) return;
await this.copyTemplate(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"name": "java.util.Locale",
"allDeclaredFields": true,
"allDeclaredMethods": true
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"name": "io.jsonwebtoken.impl.compression.GzipCompressionCodec",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "io.jsonwebtoken.impl.compression.DeflateCompressionCodec",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "io.jsonwebtoken.impl.DefaultJwtParserBuilder",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "io.jsonwebtoken.impl.DefaultJwtBuilder",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
}
]
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
36 changes: 36 additions & 0 deletions test-integration/samples/postgresql-mvc-jwt.jdl
Original file line number Diff line number Diff line change
@@ -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}
}
35 changes: 35 additions & 0 deletions test-integration/samples/postgresql-webflux-jwt.jdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
application {
config {
applicationType monolith
authenticationType oauth2
atomfrede marked this conversation as resolved.
Show resolved Hide resolved
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}
}