{"id":20307473,"url":"https://github.com/oktadev/auth0-micro-frontends-jhipster-example","last_synced_at":"2025-04-11T15:12:10.848Z","repository":{"id":103823754,"uuid":"534464739","full_name":"oktadev/auth0-micro-frontends-jhipster-example","owner":"oktadev","description":"Micro Frontends for Java Microservices","archived":false,"fork":false,"pushed_at":"2023-12-13T17:37:31.000Z","size":1443,"stargazers_count":24,"open_issues_count":0,"forks_count":9,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-25T11:21:27.592Z","etag":null,"topics":["consul","java","microfrontends","microservices","module-federation","spring-boot"],"latest_commit_sha":null,"homepage":"https://auth0.com/blog/micro-frontends-for-java-microservices/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oktadev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-09-09T02:07:43.000Z","updated_at":"2024-08-26T22:07:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"9d4173a0-1474-404e-95f7-d2bd65d0252d","html_url":"https://github.com/oktadev/auth0-micro-frontends-jhipster-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fauth0-micro-frontends-jhipster-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fauth0-micro-frontends-jhipster-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fauth0-micro-frontends-jhipster-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fauth0-micro-frontends-jhipster-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oktadev","download_url":"https://codeload.github.com/oktadev/auth0-micro-frontends-jhipster-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248429110,"owners_count":21101783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["consul","java","microfrontends","microservices","module-federation","spring-boot"],"created_at":"2024-11-14T17:17:50.023Z","updated_at":"2025-04-11T15:12:10.808Z","avatar_url":"https://github.com/oktadev.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Micro Frontends for Java Microservices Example\n\nThis example uses JHipster 8 to generate a micro frontends and reactive microservice architecture. See [Micro Frontends for Java Microservices][blog] to see how it was built.\n\n**Prerequisites:** \n\n- [Java](https://sdkman.io/) 17+\n- [Node.js](https://nodejs.com/) 18+\n- [Docker Desktop](https://www.docker.com/products/docker-desktop/)\n- [JHipster](https://www.jhipster.tech/installation/) 8\n\n\u003e [Auth0](https://auth0.com) is an easy-to-implement, adaptable authentication and authorization platform.\nBasically, we make your login box awesome.\n\n* [Getting Started](#getting-started)\n* [Links](#links)\n* [Help](#help)\n* [License](#license)\n\n## Getting Started\n\nTo install this example, run the following commands:\n\n```bash\ngit clone https://github.com/oktadev/auth0-micro-frontends-jhipster-example.git micro-frontends-for-java\ncd micro-frontends-for-java\n```\n\n## Configure for Auth0\n\nJHipster ships with Keycloak when you choose OAuth 2.0 / OIDC as the authentication type. However, you can easily change it to another identity provider, like Auth0!\n\nFirst, you'll need to register a regular web application. Log in to your Auth0 account (or [sign up](https://auth0.com/signup) if you don't have an account). You should have a unique domain like `dev-xxx.us.auth0.com`.\n\nSelect **Create Application** in the [Applications section](https://manage.auth0.com/#/applications). Use a name like `Micro Frontends`, select **Regular Web Applications**, and click **Create**.\n\nSwitch to the **Settings** tab and configure your application settings:\n\n- Allowed Callback URLs: `http://localhost:8080/login/oauth2/code/oidc`\n- Allowed Logout URLs: `http://localhost:8080/`\n\nScroll to the bottom and click **Save Changes**.\n\nIn the [roles](https://manage.auth0.com/#/roles) section, create new roles named `ROLE_ADMIN` and `ROLE_USER`.\n\nCreate a new user account in the [users](https://manage.auth0.com/#/users) section. Click the **Role** tab to assign the roles you just created to the new account.\n\n_Make sure your new user's email is verified before attempting to log in!_\n\nNext, head to **Actions** \u003e **Flows** and select **Login**. Create a new action named `Add Roles` and use the default trigger and runtime. Change the `onExecutePostLogin` handler to be as follows:\n\n```js\nexports.onExecutePostLogin = async (event, api) =\u003e {\n  const namespace = 'https://www.jhipster.tech';\n  if (event.authorization) {\n    api.idToken.setCustomClaim('preferred_username', event.user.email);\n    api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);\n    api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);\n  }\n}\n```\n\nThis code adds the user's roles to a custom claim (prefixed with `https://www.jhipster.tech/roles`). This claim is mapped to Spring Security authorities in `SecurityUtils.java` in the gateway app.\n\nSelect **Deploy** and drag the `Add Roles` action to your Login flow.\n\nEdit `docker-compose/central-server-config/application.yml` and append the following YAML block to add your Auth0 settings.\n\n```yaml\njhipster:\n  security:\n    oauth2:\n      audience: https://\u003cyour-auth0-domain\u003e/api/v2/\n\nspring:\n  security:\n    oauth2:\n      client:\n        provider:\n          oidc:\n            issuer-uri: https://\u003cyour-auth0-domain\u003e/ # make sure to include the trailing slash!\n        registration:\n          oidc:\n            client-id: \u003cyour-client-id\u003e\n            client-secret: \u003cyour-client-secret\u003e\n```\n\nBuild all the Docker images for each application by running the following command from the root directory.\n\n```shell\nnpm run java:docker\n```\n\nThe command is slightly different if you're using a Mac with Apple Silicon.\n\n```shell\nnpm run java:docker:arm64\n```\n\nNavigate to the `docker-compose` directory and start your microservices stack.\n\n```shell\ncd docker-compose\ndocker compose up\n```\n\nNow, Spring Security will be configured to use Auth0, and Consul will distribute these settings to all your microservices. When everything is started, navigate to `http://localhost:8080` and click **sign in**. You will be prompted for your Auth0 credentials.\n\nIf you'd like to use Okta for your identity provider, see [JHipster's documentation](https://www.jhipster.tech/security/#okta).\n\n## Links\n\nThis example uses the following open source libraries:\n\n* [Consul](https://www.consul.io/)\n* [JHipster](https://www.jhipster.tech)\n* [Spring Boot](https://spring.io/projects/spring-boot)\n* [Spring Cloud](https://spring.io/projects/spring-cloud)\n* [Spring Cloud Gateway](https://spring.io/projects/spring-cloud-gateway)\n* [Spring Security](https://spring.io/projects/spring-security)\n\n## Help\n\nPlease post any questions as comments on [this example's blog post][blog], or on the [Okta Developer Forums](https://devforum.okta.com/).\n\n## License\n\nApache 2.0, see [LICENSE](LICENSE).\n\n[blog]: https://auth0.com/blog/micro-frontends-for-java-microservices/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktadev%2Fauth0-micro-frontends-jhipster-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foktadev%2Fauth0-micro-frontends-jhipster-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktadev%2Fauth0-micro-frontends-jhipster-example/lists"}