{"id":20307227,"url":"https://github.com/oktadev/spring-boot-microservices-example","last_synced_at":"2025-04-05T15:07:46.175Z","repository":{"id":38816705,"uuid":"89417802","full_name":"oktadev/spring-boot-microservices-example","owner":"oktadev","description":"Bootiful Microservices with Spring Boot","archived":false,"fork":false,"pushed_at":"2023-02-27T19:28:25.000Z","size":6743,"stargazers_count":329,"open_issues_count":10,"forks_count":152,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-29T14:08:56.568Z","etag":null,"topics":["eureka-server","feign","hystrix","spring-boot","spring-cloud","spring-cloud-netflix"],"latest_commit_sha":null,"homepage":"https://developer.okta.com/blog/2017/06/15/build-microservices-architecture-spring-boot","language":"TypeScript","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-26T00:01:28.000Z","updated_at":"2025-01-29T00:09:42.000Z","dependencies_parsed_at":"2024-11-24T08:15:13.535Z","dependency_job_id":null,"html_url":"https://github.com/oktadev/spring-boot-microservices-example","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fspring-boot-microservices-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fspring-boot-microservices-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fspring-boot-microservices-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fspring-boot-microservices-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oktadev","download_url":"https://codeload.github.com/oktadev/spring-boot-microservices-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353745,"owners_count":20925329,"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":["eureka-server","feign","hystrix","spring-boot","spring-cloud","spring-cloud-netflix"],"created_at":"2024-11-14T17:16:51.136Z","updated_at":"2025-04-05T15:07:46.154Z","avatar_url":"https://github.com/oktadev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bootiful Microservices with Spring Boot\n\nThis example shows how to create a microservices architecture with Spring Boot and display its data with an Angular UI.\n\nPlease read [Build a Microservices Architecture for Microbrews with Spring Boot](https://developer.okta.com/blog/2017/06/15/build-microservices-architecture-spring-boot) for a tutorial that shows you how to build this application.\n\n**Prerequisites:** [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) and [Node.js](https://nodejs.org/).\n\n\u003e [Okta](https://developer.okta.com/) has Authentication and User Management APIs that reduce development time with instant-on, scalable user infrastructure. Okta's intuitive API and expert support make it easy for developers to authenticate, manage and secure users and roles in any application.\n\n* [Getting Started](#getting-started)\n* [Help](#help)\n* [Links](#links)\n* [License](#license)\n\n## Getting Started\n\nTo install this example application, run the following commands:\n\n```bash\ngit clone https://github.com/oktadeveloper/spring-boot-microservices-example.git\ncd spring-boot-microservices-example\n```\n\nThis will get a copy of the project installed locally. To run the client and all the servers, execute `./run.sh`, or execute the [commands in this file](https://github.com/oktadeveloper/spring-boot-microservices-example/blob/master/run.sh) manually.\n\n```bash\nr=`pwd`\necho $r\n\n# Eureka\ncd $r/eureka-service\necho \"Starting Eureka Service...\"\nmvn -q clean spring-boot:run \u0026\n\n# Beer Service\necho \"Starting Beer Catalog Service...\"\ncd $r/beer-catalog-service\nmvn -q clean spring-boot:run \u0026\n\n# Edge Service\necho \"Starting Edge Service...\"\ncd $r/edge-service\nmvn -q clean spring-boot:run \u0026\n\n# Client\ncd $r/client\nnpm install\necho \"Starting Angular Client...\"\nnpm start\n```\n\nThe primary example (without authentication) is in the `master` branch. A pure Spring Security OAuth implementation is in an `oauth` branch, and an example with the Stormpath SDK is in the `okta` branch. Both branches use the Okta Sign-In Widget on the front end. \n\n### Spring Security OAuth\n\nOkta implements the [OAuth 2.0](https://oauth.net/) protocol for its API. This means you can use libraries like [Spring Security OAuth](http://projects.spring.io/spring-security-oauth/) to provide single sign-on to your applications. \n\nTo check out the branch that uses Spring Security OAuth, run the following command.\n\n```bash\ngit checkout oauth\n```\n\nThe code in the `oauth` branch is described in [Secure a Spring Microservices Architecture with Spring Security and OAuth 2.0](https://developer.okta.com/blog/2018/02/13/secure-spring-microservices-with-oauth).\n\n\u003e The changes required to move from the Stormpath SDK to Spring Security OAuth can be viewed in [pull request #8](https://github.com/oktadeveloper/spring-boot-microservices-example/pull/8/files).\n\n### Create Applications in Okta\n\nIf you don't have one, [create an Okta Developer account](https://developer.okta.com/signup/). After you've completed the setup process, log in to your account and navigate to **Applications** \u003e **Add Application**. Click **Web** and **Next**. On the next page, enter the following values and click **Done**.\n\n* Application Name: `Spring OAuth`\n* Base URIs: `http://localhost:8081`\n* Login redirect URIs: `http://localhost:8081/login`\n\nYou need to add a `roles` claim to your ID Token, so your groups in Okta are translated to Spring Security authorities. In your Okta developer console, navigate to **API** \u003e **Authorization Servers**, click the **Authorization Servers** tab and edit the default one. Click the **Claims** tab and **Add Claim**. Name it \"roles\" and include it in the ID Token. Set the value type to \"Groups\" and set the filter to be a Regex of `.*`.\n\nChange `security.oauth2.*` properties in the following files to enter your client ID and client secret. \n\n* [edge-service/src/main/resources/application.properties](../../tree/oauth/edge-service/src/main/resources/application.properties)\n* [beer-catalog-service/src/main/resources/application.properties](../../tree/oauth/beer-catalog-service/src/main/resources/application.properties)\n\nYou can also create a `~/.okta.env` file to override the properties in these files.\n\n```bash\n#!/bin/bash\n\n# Okta with JHipster\nexport SECURITY_OAUTH2_CLIENT_ACCESS_TOKEN_URI=\"https://{yourOktaDomain}.com/oauth2/default/v1/token\"\nexport SECURITY_OAUTH2_CLIENT_USER_AUTHORIZATION_URI=\"https://{yourOktaDomain}.com/oauth2/default/v1/authorize\"\nexport SECURITY_OAUTH2_RESOURCE_USER_INFO_URI=\"https://{yourOktaDomain}.com/oauth2/default/v1/userinfo\"\nexport SECURITY_OAUTH2_RESOURCE_TOKEN_INFO_URI=\"https://{yourOktaDomain}.com/oauth2/default/v1/introspect\"\nexport SECURITY_OAUTH2_CLIENT_CLIENT_ID=\"{clientId}\"\nexport SECURITY_OAUTH2_CLIENT_CLIENT_SECRET=\"{clientSecret}\"\n```\n\nThen run the following before starting any servers.\n\n```source\nsource ~/.okta.env\n```\n\nTo use Okta's Sign-In Widget, you'll need to modify your app in Okta to enable an *Implicit* grant type. Log in to your account, navigate to **Applications** \u003e **Spring OAuth** \u003e **General** tab and click **Edit**. Enable **Implicit (Hybrid)** under **Allowed grant types** and select both checkboxes below it. Add `http://localhost:4200` under **Login redirect URIs** and click **Save**.\n\nIn order for the Sign-In Widget to make requests to this application, you'll also need to configure the client URL as a trusted origin. Click **API** \u003e **Trusted Origins** \u003e **Add Origin**. Enter `http://localhost:4200` as the **Origin URL** and select both checkboxes under it.\n\nChange `{clientId}` and `{yourOktaDomain}` in `client/src/app/shared/okta/okta.service.ts` to match your app's values.\n\n```typescript\nsignIn = new OktaSignIn({\n  baseUrl: 'https://{yourOktaDomain}.com',\n  clientId: '{clientId}',\n  authParams: {\n    issuer: 'default',\n    responseType: ['id_token', 'token'],\n    scopes: ['openid', 'email', 'profile']\n  }\n});\n```\n\n### Stormpath SDK\n\nTo check out the branch that uses the Stormpath SDK, run the following command.\n\n```bash\ngit checkout okta\n```\n\nThe code in the `okta` branch is described in [Secure a Spring Microservices Architecture with Spring Security, JWTs, Juiser, and Okta](https://developer.okta.com/blog/2017/08/08/secure-spring-microservices).\n\n### Create Applications in Okta\n\nYou will need to [create an Okta developer account](https://github.com/stormpath/stormpath-sdk-java/blob/okta/OktaGettingStarted.md) to configure the Spring Boot side of things. After creating an app and an access token, you should be able to set the following environment variables:\n\n```bash\nexport STORMPATH_CLIENT_BASEURL={baseUrl}\nexport OKTA_APPLICATION_ID={applicationId}\nexport OKTA_API_TOKEN={apiToken}\nexport OKTA_AUTHORIZATIONSERVER_ID=default\n```\n\nAfter you set these environment variables, make sure to restart your Spring Boot applications.\n\nFor Angular, you'll need to create an OIDC app on Okta. Change `{clientId}` and `{yourOktaDomain}` in `client/src/app/shared/okta/okta.service.ts` to match your app's values.\n\n```typescript\nsignIn = new OktaSignIn({\n  baseUrl: 'https://{yourOktaDomain}.com',\n  clientId: '{clientId}',\n  authParams: {\n    issuer: 'default',\n    responseType: ['id_token', 'token'],\n    scopes: ['openid', 'email', 'profile']\n  }\n});\n```\n\n**NOTE:** The value of `{yourOktaDomain}` should be something like `dev-123456.oktapreview.com`. Make sure you don't include `-admin` in the value!\n\nAfter making these changes, you should be able to log in with your credentials at `http://localhost:4200`.\n\n## Links\n\nThis example uses the following libraries provided by Okta:\n\n* [Stormpath Java SDK](https://github.com/stormpath/stormpath-sdk-java)\n* [Okta Sign-In Widget](https://github.com/okta/okta-signin-widget)\n\n## Help\n\nPlease post any questions as comments on the following blog posts, or visit our [Okta Developer Forums](https://devforum.okta.com/). You can also email developers@okta.com if would like to create a support ticket.\n\n* [Build a Microservices Architecture for Microbrews with Spring Boot](https://developer.okta.com/blog/2017/06/15/build-microservices-architecture-spring-boot)\n* [Secure a Spring Microservices Architecture with Spring Security, JWTs, Juiser, and Okta](https://developer.okta.com/blog/2017/08/08/secure-spring-microservices)\n* [Secure a Spring Microservices Architecture with Spring Security and OAuth 2.0](https://developer.okta.com/blog/2018/02/13/secure-spring-microservices-with-oauth)\n\n## License\n\nApache 2.0, see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktadev%2Fspring-boot-microservices-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foktadev%2Fspring-boot-microservices-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktadev%2Fspring-boot-microservices-example/lists"}