Last active
May 26, 2022 19:10
-
-
Save gastaldi/6d86b71f9a8ba117adb3f7a38d286abb to your computer and use it in GitHub Desktop.
JBoss Forge Script to create a WildFly Swarm Microservice and configuring as a KeyCloak client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Install the required plugins | |
addon-install-from-git --url https://github.com/forge/wildfly-swarm-addon.git | |
addon-install-from-git --url https://github.com/forge/keycloak-addon.git | |
# Create the project and configure the WildFly Swarm maven plugin | |
project-new --named demo --stack JAVA_EE_7 --type wildfly-swarm | |
# Create the JPA entity | |
jpa-new-entity --named Customer | |
# Add some fields to the JPA entity | |
jpa-new-field --named firstName | |
jpa-new-field --named lastName | |
# Create the REST endpoint for the entity | |
rest-generate-endpoints-from-entities --targets org.demo.model.Customer | |
# Since we are running from a microservice, we need to enable CORS - Cross Origin Resource Sharing | |
rest-new-cross-origin-resource-sharing-filter | |
# Detect and add the missing fractions to the build descriptor (will build the project first) | |
wildfly-swarm-detect-fractions --build --depend | |
# Create a main class for custom Swarm configuration | |
wildfly-swarm-new-main-class | |
# Configure KeyCloak authentication | |
wildfly-swarm-add-fraction --fractions keycloak | |
security-add-login-config --auth-method KEYCLOAK --security-realm master | |
security-add-constraint --web-resource-name Customer --url-patterns /rest/customers --security-roles user | |
# Install the keycloak.json file to WEB-INF | |
keycloak-install-client-json --server-url http://localhost:9000/auth --realm master --client-id security-admin-console --user admin --password admin | |
# Copy the import.sql file to src/main/resources | |
echo TODO: Create an import.sql file in src/main/resources to have some example data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run this script, save this file somewhere in your computer, start Forge (you can download in http://forge.jboss.org/download) and execute: