{"id":25719984,"url":"https://github.com/gregwhitaker/springboot-rsocketjwt-example","last_synced_at":"2025-05-06T19:45:08.675Z","repository":{"id":82733470,"uuid":"229082127","full_name":"gregwhitaker/springboot-rsocketjwt-example","owner":"gregwhitaker","description":"Example of using JWT with RSocket and Spring Boot","archived":false,"fork":false,"pushed_at":"2020-12-04T19:49:53.000Z","size":155,"stargazers_count":28,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T02:21:30.261Z","etag":null,"topics":["jwt","reactive","reactive-programming","reactive-streams","rsocket","rsocket-java","spring-boot","spring-messaging","spring-security"],"latest_commit_sha":null,"homepage":"","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/gregwhitaker.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":"2019-12-19T15:21:04.000Z","updated_at":"2024-03-12T03:55:07.000Z","dependencies_parsed_at":"2023-11-10T11:43:36.476Z","dependency_job_id":null,"html_url":"https://github.com/gregwhitaker/springboot-rsocketjwt-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/gregwhitaker%2Fspringboot-rsocketjwt-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregwhitaker%2Fspringboot-rsocketjwt-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregwhitaker%2Fspringboot-rsocketjwt-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregwhitaker%2Fspringboot-rsocketjwt-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregwhitaker","download_url":"https://codeload.github.com/gregwhitaker/springboot-rsocketjwt-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252756470,"owners_count":21799480,"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":["jwt","reactive","reactive-programming","reactive-streams","rsocket","rsocket-java","spring-boot","spring-messaging","spring-security"],"created_at":"2025-02-25T17:36:14.424Z","updated_at":"2025-05-06T19:45:08.648Z","avatar_url":"https://github.com/gregwhitaker.png","language":"Java","readme":"# springboot-rsocketjwt-example\n![Build](https://github.com/gregwhitaker/springboot-rsocketjwt-example/workflows/Build/badge.svg)\n\nAn example of using [JWT](https://jwt.io/), for authentication and authorization, with [RSocket](http://rsocket.io) and Spring Boot.\n\nThis example consists of an RSocket service, `hello-service`, that returns hello messages based upon the method called and the supplied JWT token from the `hello-client` application.\n\nThe example assumes that you have already retrieved valid JWT tokens from your choice of Authorization Server. To mimic this, a `token-generator`\nproject has been included to get valid tokens for use with this demo.\n\n## Building the Example\nRun the following command to build the example:\n\n    ./gradlew clean build\n    \n## Running the Example\nFollow the steps below to run the example:\n\n1. Run the following command to generate the admin and user JWT tokens to use for authenticating with the `hello-service`:\n\n        ./gradlew :token-generator:run\n        \n    If successful, you will see the tokens displayed in the console:\n\n        \u003e Task :token-generator:run\n        \n        Generated Tokens\n        ================\n        Admin:\n        eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImF1ZCI6ImhlbGxvLXNlcnZpY2UiLCJzY29wZSI6IkFETUlOIiwiaXNzIjoiaGVsbG8tc2VydmljZS1kZW1vIiwiZXhwIjoxNTc2ODY4MjE0LCJqdGkiOiIyYjgwOTUwMC0wZWJlLTQ4MDEtOTYwZS1mZjc2MGQ3MjE0ZGUifQ.fzWzcvelcaXooMa5C3w7BI4lJxcruZiA7TwFyPQuH1k\n        \n        User:\n        eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiYXVkIjoiaGVsbG8tc2VydmljZSIsInNjb3BlIjoiVVNFUiIsImlzcyI6ImhlbGxvLXNlcnZpY2UtZGVtbyIsImV4cCI6MTU3Njg2ODIxNCwianRpIjoiOGQzZDE2YWUtZTg5MS00Nzc4LWFjNWEtN2NhY2ExOGEwMTYwIn0.Tlg1WxTcrMliLOBmBRSPR33C3xfbc6KUEkEZit928tE\n        \n2. In a new terminal, run the following command to start the `hello-service`:\n\n        ./gradlew :hello-service:bootRun\n        \n    If successful, you will see a message stating the service has been started in the console:\n    \n        2019-12-20 10:33:59.223  INFO 1889 --- [           main] e.service.hello.HelloServiceApplication  : Started HelloServiceApplication in 1.185 seconds (JVM running for 1.546)\n        \n    Now you are ready to start calling the `hello-service`.\n    \n3. In a new terminal, run the following command to call the unsecured `hello` endpoint:\n\n        ./gradlew :hello-client:bootRun --args=\"hello Bob\"\n        \n   Notice that the request was successful and you received a hello response:\n   \n        2019-12-20 10:37:24.282  INFO 1919 --- [           main] e.client.hello.HelloClientApplication    : Response: Hello, Bob! - from unsecured method \n        \n4. Next, run the following command to call the `hello.secure` method which requires that the user is authenticated:\n\n        ./gradlew :hello-client:bootRun --args=\"hello.secure Bob\"\n        \n    You will receive an `io.rsocket.exceptions.ApplicationErrorException: Access Denied` exception because you have not supplied a valid JWT token.\n \n5. Now, run the same command again, but this time supply the `User` JWT token you generated earlier:\n\n        ./gradlew :hello-client:bootRun --args=\"--token {User Token Here} hello.secure Bob\"\n\n    You will now receive a successful hello message because you have authenticated with a valid JWT token:\n    \n        2019-12-20 10:42:14.371  INFO 1979 --- [           main] e.client.hello.HelloClientApplication    : Response: Hello, Bob! - from secured method\n        \n6. Next, let's test authorization by calling the `hello.secure.adminonly` endpoint with the `User` token by running the following command:\n\n        ./gradlew :hello-client:bootRun --args=\"--token {User Token Here} hello.secure.adminonly Bob\"\n\n    You will receive an `io.rsocket.exceptions.ApplicationErrorException: Access Denied` exception because while you are authenticated, you are not authorized to access the method.\n    \n7. Finally, let's call the `hello.secure.adminonly` endpoint again, but this time use the `Admin` token by running the following command:\n\n        ./gradlew :hello-client:bootRun --args=\"--token {Admin Token Here} hello.secure.adminonly Bob\"\n        \n    You will receive a successful hello message because you have supplied a valid JWT token with admin scope:\n    \n        2019-12-20 10:47:56.047  INFO 2054 --- [           main] e.client.hello.HelloClientApplication    : Response: Hello, Bob! - from secured method [admin only]\n\n## Bugs and Feedback\nFor bugs, questions, and discussions please use the [Github Issues](https://github.com/gregwhitaker/springboot-rsocketjwt-example/issues).\n\n## License\nMIT License\n\nCopyright (c) 2019 Greg Whitaker\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregwhitaker%2Fspringboot-rsocketjwt-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregwhitaker%2Fspringboot-rsocketjwt-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregwhitaker%2Fspringboot-rsocketjwt-example/lists"}