{"id":21888675,"url":"https://github.com/swisscom/sample-uaa-spring-boot-resource-server","last_synced_at":"2025-04-15T10:22:14.908Z","repository":{"id":73689906,"uuid":"171312726","full_name":"swisscom/sample-uaa-spring-boot-resource-server","owner":"swisscom","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-16T15:19:13.000Z","size":62,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-04T22:02:06.524Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swisscom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-02-18T15:56:18.000Z","updated_at":"2024-10-16T15:19:15.000Z","dependencies_parsed_at":"2023-02-24T01:16:02.781Z","dependency_job_id":null,"html_url":"https://github.com/swisscom/sample-uaa-spring-boot-resource-server","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/swisscom%2Fsample-uaa-spring-boot-resource-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisscom%2Fsample-uaa-spring-boot-resource-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisscom%2Fsample-uaa-spring-boot-resource-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisscom%2Fsample-uaa-spring-boot-resource-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swisscom","download_url":"https://codeload.github.com/swisscom/sample-uaa-spring-boot-resource-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249048841,"owners_count":21204321,"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":[],"created_at":"2024-11-28T11:16:35.856Z","updated_at":"2025-04-15T10:22:14.881Z","avatar_url":"https://github.com/swisscom.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample Spring boot OAuth2/OIDC resource server for UAA\nDemo app that acts as OAuth2 resource server, meaning it offers a stateless API and is protected by an OAuth2 JWT access token verification.\nIt's mostly used in conjunction with a javascript frontend that obtains the OAuth2 JWT access token using the `implicit` flow and then uses this API as its backend.\n\nIt is primarily designed to run on CloudFoundry, since it expects the OAuth2 configuration to be passed in `VCAP_SERVICES`.\n\n## How it works\nThe client invokes the backend API with the HTTP header `Authorization: Bearer \u003cJWT access token\u003e`.\nThe backend extracts this JWT token and validates it on the OAuth2 IDP. See the comments in the code for details.\n\nIt was tested with [UAA](https://github.com/cloudfoundry/uaa) acting as OAuth2/OIDC provider, but it should work with every OIDC provider.\n\n## Configure, deploy and test\nThe app expects a `VCAP_SERVICES` env variable containing a service with a tag `oauth2` so make sure it is set when running the app.\n\nWhen deploying to CloudFoundry, one can use a [User provided service instance](https://docs.cloudfoundry.org/devguide/services/user-provided.html) to achieve this.\n\nFull example:\n```\n# compile the app\nmvn clean package\n\n# adjust ALLOWED_CORS_ORIGIN in manifest.yml if you want to use a browser client, then push\ncf push sample --random-route --no-start -p target/sample-uaa-spring-boot-resource-server-0.0.1-SNAPSHOT.jar\n\n# Now create the user provided service which will be provided to the app in VCAP_SERVICES.\n# The client specified here must be created manually beforehand on the OAuth2 provider.\nCREDENTIALS='{\"userInfoEndpoint\": \"\u003cuaa-url\u003e/userinfo\", \"introspectEndpoint\": \"\u003cuaa-url\u003e/introspect\", \"clientId\": \"\u003cclient-id\u003e\", \"clientSecret\": \"\u003cclient-secret\u003e\"}'\ncf create-user-provided-service OAUTH2-CLIENT -p $CREDENTIALS -t oauth2\n\n# Bind \u0026 start the app to make the service instance available\ncf bind-service sample OAUTH2-CLIENT\ncf start sample\n```\n\nYou can now speak to the API, providing a valid token:\n```\nTOKEN=obtain token from IDP\ncurl -v https://\u003cpath-to-your-app\u003e/env -H \"Authorization: Bearer $TOKEN\"\n```\n\nAnd the app will return the user attributes it received from the IDP.\n\nFor a full demo, you can deploy a client sample app (see below) that will act as the client for you.\n\n\n## Sample overview\n### Authorization code\n- Service provider (Spring boot): https://github.com/swisscom/sample-uaa-spring-boot-service-provider\n- Service provider (Ruby): https://github.com/swisscom/sample-uaa-ruby-service-provider\n\n### Implicit flow \u0026 Client Credentials\n- Client (VueJS): https://github.com/swisscom/sample-uaa-vue-client\n- Client (React \u0026 Redux):https://github.com/swisscom/sample-uaa-react-redux-client\n- Client (AngularJS): https://github.com/swisscom/sample-uaa-angular-client\n\n- Resource Server (Spring boot): https://github.com/swisscom/sample-uaa-spring-boot-resource-server\n- Resource Server (Ruby): https://github.com/swisscom/sample-uaa-ruby-resource-server","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswisscom%2Fsample-uaa-spring-boot-resource-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswisscom%2Fsample-uaa-spring-boot-resource-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswisscom%2Fsample-uaa-spring-boot-resource-server/lists"}