Java Quarkus β "" Kubernetes Java- -, (serverless) ( ). AOT , , . . , , Quarkus, , !
Spring Micronaut, Quarkus GraalVM JVM- , .
Java- , Kubernetes , Supersonic Subatomic Java. Quarkus Java (, MicroProfile, JAX-RS), Java- (, Hibernate Vert.x). Spring.
Quarkus + JHipster = Java
, . , - -, JHipster.
JHipster β , , - . JHipster Spring Boot, . blueprint- JHipster Quarkus.
, , JHipster, blueprint-. Blueprint- JHipster , Β« Β».
, blueprint- Kotlin JHipster , . blueprint- . JHipster Java (, Node + NestJS .NET Core). JHipster, blueprint- Quarkus, OAuth .
Java- Quarkus
, .
:
JHipster blueprint- Quarkus, npm:
# Install JHipster globally
npm install -g generator-jhipster@6.10.5
# Install the JHipster Quarkus blueprint
npm install -g generator-jhipster-quarkus@1.1.1
jhipster-quarkus β jhipster --blueprints quarkus. --help.
$ jhipster-quarkus --help
JHipster Quarkus
mkdir okta-jhipster-quarkus-example && cd okta-jhipster-quarkus-example
# oh-my-zsh users: take okta-jhipster-quarkus-example
, jhipster-quarkus:
jhipster-quarkus
.
JHipster Quarkus JWT ( ) OAuth 2.0/OIDC , Keycloak Okta. OIDC OpenID Connect, Β« Β» OAuth 2.0. β .
.
, JHipster npm install.
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp",
"nativeLanguage": "en"
},
"jhipsterVersion": "6.10.5",
"applicationType": "monolith",
"baseName": "jhipster",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8080",
"authenticationType": "oauth2",
"cacheProvider": "no",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"messageBroker": false,
"buildTool": "maven",
"embeddableLaunchScript": false,
"useSass": true,
"clientPackageManager": "npm",
"clientFramework": "angularX",
"clientTheme": "none",
"clientThemeVariant": "",
"creationTimestamp": 1614834465776,
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [
{
"name": "generator-jhipster-quarkus",
"version": "1.1.1"
}
],
"enableTranslation": true,
"nativeLanguage": "en",
"languages": ["en"],
"blueprints": [
{
"name": "generator-jhipster-quarkus",
"version": "1.1.1"
}
]
}
}
JHipster, .
, Keycloak OAuth 2.0/OIDC
JHipster Quarkus Docker Compose, , . Keycloak, , .
https://gitlab.webant.ru/russia_quiz/frontend/-/merge_requests
Keycloak , . Maven:
./mvnw
, 3,351 , Quarkus ( oidc). http://localhost:8080 sign in ().
Keycloak . admin/admin.
Quarkus.
OAuth 2.0 JHipster Quarkus
blueprint- JHipster, Quarkus, .
JHipster - (Angular, React Vue.js), Java-, Spring Boot Spring Cloud.
JHipster Quarkus OAuth 2.0 URI- login/oauth2/code/oidc, Spring Security. , ( - - ).
JHipster Quarkus, OAuth 2.0, HTTP-. JHipster Quarkus UserOauth2Controller Quarkus OIDC, .
, . JHipster, , .
JHipster Quarkus Okta
, Okta OAuth 2.0/OIDC. Okta OIDC-. , Okta CLI.
Okta CLI JHipster
Okta CLI JHipster Okta. Okta CLI .
macOS ( Homebrew):
brew install --cask oktadeveloper/tap/okta
Linux ( Flatpak):
# Add Flathub repo
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# install the package
flatpak install com.okta.developer.CLI
# add this to your appropriate dot file
alias okta="flatpak run com.okta.developer.CLI"
Windows ( Chocolatey):
choco install okta -version 0.8.0
bash:
curl https://raw.githubusercontent.com/okta/okta-cli/master/cli/src/main/scripts/install.sh | bash
Okta, , Quarkus okta register. , okta login.
$ okta register
First name: Daniel
Last name: Petisme
Email address: daniel.petisme@gmail.com
Company: Okta
Creating new Okta Organization, this may take a minute:
OrgUrl: https://dev-9323263.okta.com
An email has been sent to you with a verification code.
Check your email
Verification code: 232819
New Okta Account created!
Your Okta Domain: https://dev-9323263.okta.com
To set your password open this link:
https://dev-9323263.okta.com/welcome/drpt2SjbRAPR-gvVHhnm
Okta, okta login. Quarkus okta apps create jhipster. URI.
$ okta apps create jhipster
Application name [okta-jhipster-quarkus-example]:
Redirect URI
Common defaults:
Spring Security - http://localhost:8080/login/oauth2/code/okta
Quarkus OIDC - http://localhost:8080/callback
JHipster - http://localhost:8080/login/oauth2/code/oidc
Enter your Redirect URI(s) [http://localhost:8080/login/oauth2/code/oidc, http://localhost:8761/login/oauth2/code/oidc]:
Enter your Post Logout Redirect URI(s) [http://localhost:8080/, http://localhost:8761/]:
Configuring a new OIDC Application, almost done:
Created OIDC application, client-id: 0oa5ozjxyNQPPbKc65d6
Creating Authorization Server claim 'groups':
Adding user daniel.petisme@gmail.com to groups: [ROLE_USER, ROLE_ADMIN]
Creating group: ROLE_USER
Creating group: ROLE_ADMIN
Okta : /Users/daniel/workspace/okta-jhipster-quarkus-example/.okta.env
: URI, http://localhost:8761*, JHipster, JHipster. Okta CLI . , , , .
Okta CLI .okta.env . , , , OIDC.
$ cat .okta.env
export QUARKUS_OIDC_AUTH_SERVER_URL="https://dev-9323263.okta.com/oauth2/default"
export QUARKUS_OIDC_CLIENT_ID="0oa5ozjxyNQPPbKc65d6"
export QUARKUS_OIDC_CREDENTIALS_SECRET="KEJ0oNOTFEUEFHP7i1TELLING1xLm1XPRn"
export QUARKUS_OIDC_AUTHENTICATION_REDIRECT_PATH="/login/oauth2/code/oidc"
export JHIPSTER_OIDC_LOGOUT_URL="https://dev-9323263.okta.com/oauth2/default/v1/logout"
, , Maven.
source .okta.env
./mvnw
\*.env .gitignore, .
, http://localhost:8080 . Okta.
. .
Okta CLI JHipster .
OIDC URI.
ROLE_ADMIN ROLE_USER, JHipster.
ROLE_ADMIN ROLE_USER.
, .
? , ! Okta CLI , , , . OIDC, JHipster Quarkus.
Okta JHipster
Okta, sign up (). : , , , β . , :
Applications () , Applications > Create App Integration ( > ), .
OIDC Web Application. Next ().
.
Name (): , Β«JHipster QuarkusΒ» - ?
Login redirect URIs ( URI ): , Okta . http://localhost:8080/login/oauth2/code/oidc, .
Logout redirect URIs ( URI ): http://localhost:8080 β , .
Group assignments ( ): , .
. , Save (). .
:
(ID ). Java Okta ;
Okta, Quarkus URL OAuth/OIDC.
ROLE_USER: ;
ROLE_ADMIN: .
Directory > Groups ( > ). Add Group ( ) ROLE_ADMIN
ROLE_USER.
, , .
, . Okta, Directory > People ( > ). Add Person ( ). Administrator.
Administrator ROLE_ADMIN. , , Set by Admin ( ). Set by User ( ) . .
, User ROLE_USER. , . Applications > JHipster Quarkus ( > JHipster Quarkus) Assignments (). , .
ID
, , β , ID. Security > API ( > API), default ( ). Claims > Add Claim ( > ). :
Name (): groups ();
Include in token type ( ): ID Token ( ID);
Value type ( ): groups ();
Filter (): Matches regex with a value of .* ( .*).
Create (). Okta JHipster !
Quarkus OIDC Okta
, JHipster Quarkus Keycloak . Okta. -, - JHipster, cookie. Account > Sign Out ( > ).
: . Quarkus (Dev Mode), «» . !
src/main/resources/application.properties OIDC.
# OAuth 2.0 and OIDC
quarkus.oidc.enabled=true
quarkus.oidc.auth-server-url=http://localhost:9080/auth/realms/jhipster/
%dev.quarkus.oidc.client-id=web_app
%dev.quarkus.oidc.credentials.secret=web_app
quarkus.oidc.application-type=hybrid
quarkus.oidc.authentication.scopes=profile,address,email,address,phone,offline_access
quarkus.oidc.authentication.cookie-path=/
quarkus.oidc.authentication.redirect-path=/login/oauth2/code/oidc
quarkus.oidc.authentication.restore-path-after-redirect=false
jhipster.oidc.logout-url=http://localhost:9080/auth/realms/jhipster/protocol/openid-connect/logout
%test.quarkus.oidc.client-id=dummy
%test.quarkus.oidc.application-type=service
%test.jhipster.oidc.logout-url=some-dummy-logoutUrl
Keycloak. , Okta;
quarkus.oidc.auth-server-url: URL API Okta, OIDC;
quarkus.oidc.client-id: ID OIDC;
quarkus.oidc.credentials.secret: OIDC;
jhipster.oidc.logout-url: JHipster . ( OIDC-).
, :
# OAuth 2.0 and OIDC
quarkus.oidc.enabled=true
quarkus.oidc.auth-server-url=https://dev-9323263.okta.com/oauth2/default
quarkus.oidc.client-id=0oaajhdr9q9jxbBM95d6
quarkus.oidc.credentials.secret=NEVERSHOWSECRETS
quarkus.oidc.application-type=hybrid
quarkus.oidc.authentication.scopes=profile,address,email,address,phone
quarkus.oidc.authentication.cookie-path=/
quarkus.oidc.authentication.redirect-path=/login/oauth2/code/oidc
quarkus.oidc.authentication.restore-path-after-redirect=false
jhipster.oidc.logout-url=https://dev-9323263.okta.com/oauth2/default/v1/logout
, http://localhost:8080. sign in () Okta.
admin , . Okta , , . Quarkus.
Quarkus GraalVM
Java ( ). JHipster , . Maven package native:
./mvnw package -Pnative -DskipTests
, , : β . , , . JDK GraalVM, :
[error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an
exception: java.lang.RuntimeException: Cannot find the `native-image` in the
GRAALVM_HOME, JAVA_HOME and System PATH. Install it using `gu install native-image`
SDKMAN Java 11 GraalVM:
sdk install java 21.0.0.2.r11-grl
gu install native-image:
$ gu install native-image Downloading: Component catalog from www.graalvm.org Processing Component: Native Image Downloading: Component native-image: Native Image from github.com Installing new component: Native Image (org.graalvm.native-image, version 21.0.0.2)
, package Maven:
./mvnw package -Pnative -DskipTests
. , - . , , :
:
, target/*runner:
Java- 1 ! , ? , :
$ ps -o pid,rss,command | grep --color jhipster | awk '{$2=int($2/1024)"M";}{ print;}'
30951 46M ./target/jhipster-1.0.0-SNAPSHOT-runner
31433 0M grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --color jhipster
50 . http://localhost:8080 , . !
JHipster Quarkus
, , Java, Quarkus JHipster. , , JHipster Okta CLI ?! , , GitHub. blueprint- Quarkus, generator-jhipster-quarkus, GitHub.
Java , , Java, TIOBE. Java , , ; , Java. , Java, 14 Java-.