From 14ab5f7d384af0870993184475e0849a17f69360 Mon Sep 17 00:00:00 2001 From: Kyle Anderson Date: Thu, 8 Dec 2016 08:58:53 -0800 Subject: [PATCH 1/2] Fixed Conflicting Endpoint in Spring Boot Tutorials --- .../com/stormpath/tutorial/controller/HelloController.java | 6 +++--- .../src/main/resources/templates/home.html | 2 +- .../main/resources/templates/{me.html => userdetails.html} | 0 .../{MeController.java => UserDetailsController.java} | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename tutorials/spring-boot/04-a-finer-grain-of-control/src/main/resources/templates/{me.html => userdetails.html} (100%) rename tutorials/spring-boot/05-token-management/src/main/java/com/stormpath/tutorial/controller/{MeController.java => UserDetailsController.java} (91%) diff --git a/tutorials/spring-boot/04-a-finer-grain-of-control/src/main/java/com/stormpath/tutorial/controller/HelloController.java b/tutorials/spring-boot/04-a-finer-grain-of-control/src/main/java/com/stormpath/tutorial/controller/HelloController.java index 9e9db54a72..dfbce05a42 100644 --- a/tutorials/spring-boot/04-a-finer-grain-of-control/src/main/java/com/stormpath/tutorial/controller/HelloController.java +++ b/tutorials/spring-boot/04-a-finer-grain-of-control/src/main/java/com/stormpath/tutorial/controller/HelloController.java @@ -45,9 +45,9 @@ String home(HttpServletRequest req, Model model) { return "home"; } - @RequestMapping("/me") - String me() { - return "me"; + @RequestMapping("/userdetails") + String userDetails() { + return "userdetails"; } @RequestMapping("/restricted") diff --git a/tutorials/spring-boot/04-a-finer-grain-of-control/src/main/resources/templates/home.html b/tutorials/spring-boot/04-a-finer-grain-of-control/src/main/resources/templates/home.html index 9948b80f8e..47c4388a5d 100644 --- a/tutorials/spring-boot/04-a-finer-grain-of-control/src/main/resources/templates/home.html +++ b/tutorials/spring-boot/04-a-finer-grain-of-control/src/main/resources/templates/home.html @@ -35,7 +35,7 @@

Hello, [[${account.givenName}]]!

Restricted - My Groups + My Groups
diff --git a/tutorials/spring-boot/04-a-finer-grain-of-control/src/main/resources/templates/me.html b/tutorials/spring-boot/04-a-finer-grain-of-control/src/main/resources/templates/userdetails.html similarity index 100% rename from tutorials/spring-boot/04-a-finer-grain-of-control/src/main/resources/templates/me.html rename to tutorials/spring-boot/04-a-finer-grain-of-control/src/main/resources/templates/userdetails.html diff --git a/tutorials/spring-boot/05-token-management/src/main/java/com/stormpath/tutorial/controller/MeController.java b/tutorials/spring-boot/05-token-management/src/main/java/com/stormpath/tutorial/controller/UserDetailsController.java similarity index 91% rename from tutorials/spring-boot/05-token-management/src/main/java/com/stormpath/tutorial/controller/MeController.java rename to tutorials/spring-boot/05-token-management/src/main/java/com/stormpath/tutorial/controller/UserDetailsController.java index d561778633..243cf7fe7e 100644 --- a/tutorials/spring-boot/05-token-management/src/main/java/com/stormpath/tutorial/controller/MeController.java +++ b/tutorials/spring-boot/05-token-management/src/main/java/com/stormpath/tutorial/controller/UserDetailsController.java @@ -28,9 +28,9 @@ * @since 1.0.RC8.3 */ @RestController -public class MeController { +public class UserDetailsController { - @RequestMapping(value="/me", produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value="/userdetails", produces = MediaType.APPLICATION_JSON_VALUE) public AccountInfo info(HttpServletRequest req) { // must be logged in to get here per Spring Security config Account account = AccountResolver.INSTANCE.getAccount(req); From 05c47f913e3b70cf2e88a497c6982d1ca28abdd1 Mon Sep 17 00:00:00 2001 From: Kyle Anderson Date: Thu, 8 Dec 2016 09:08:19 -0800 Subject: [PATCH 2/2] Fixed Spring Boot Tutorial Documentation --- docs/source/tutorial.rst | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/source/tutorial.rst b/docs/source/tutorial.rst index 4acdeb4441..58179177a0 100644 --- a/docs/source/tutorial.rst +++ b/docs/source/tutorial.rst @@ -432,7 +432,7 @@ For more on ``HttpSecurity`` with Spring Security, see `its HttpSecurity documentation `_. We've added a new method to our ``HelloController``. It does not call out any other authorizaton requirements. As such, - anyone logged in will be able to access ``/me``. Furthermore, anyone NOT logged in trying to access ``/me`` will automatically + anyone logged in will be able to access ``/userdetails``. Furthermore, anyone NOT logged in trying to access ``/userdetails`` will automatically be redirected to the ``/login`` view. .. code-block:: java @@ -442,15 +442,15 @@ public class HelloController { ... - @RequestMapping("/me") - String me() { - return "me"; + @RequestMapping("/userdetails") + String userDetails() { + return "userdetails"; } ... } - Try it out. Launch the application as before, and then browse to: ``http://localhost:${port}/me``. You will be redirected to the ``/login`` - and then after you login to a valid Stormpath Account, you will automatically be brought back to ``/me``. That's the Stormpath magic at work! + Try it out. Launch the application as before, and then browse to: ``http://localhost:${port}/userdetails``. You will be redirected to the ``/login`` + and then after you login to a valid Stormpath Account, you will automatically be brought back to ``/userdetails``. That's the Stormpath magic at work! Now, we'll look at fine grained controls using Spring Security permissions connected to Stormpath custom data. @@ -534,13 +534,13 @@ This part of the tutorial exercises the Token Magement features using Spring Security Spring Boot WebMVC. - There's a simple `@RestController` called `MeController` that returns information about the authenticated account. + There's a simple `@RestController` called `UserDetailsController` that returns information about the authenticated account. .. code-block:: java @RestController - public class MeController { - @RequestMapping(value="/me", produces = MediaType.APPLICATION_JSON_VALUE) + public class UserDetailsController { + @RequestMapping(value="/userdetails", produces = MediaType.APPLICATION_JSON_VALUE) public AccountInfo info(HttpServletRequest req) { // must be logged in to get here per Spring Security config Account account = AccountResolver.INSTANCE.getAccount(req); @@ -549,7 +549,7 @@ } } - In order to hit the `/me` endpoint, we'll first, we'll get an `access_token` and a `refresh_token` by hitting the + In order to hit the `/userdetails` endpoint, we'll first, we'll get an `access_token` and a `refresh_token` by hitting the `/oauth/token` endpoint: .. code-block:: bash @@ -577,14 +577,14 @@ The response includes the tokens as well as information on their type (`Bearer` in this case) and when it expires. - We can now use the `access_token` to hit the `/me` endpoint: + We can now use the `access_token` to hit the `/userdetails` endpoint: .. code-block:: bash curl \ -H "Authorization: Bearer eyJraWQiOiJSOTJTQkhKQzFVNERBSU1HUTNNSE9HVk1YIiwiYWxnIjoiSFMyNTYifQ.eyJqdGkiOiI2M1laa1FBNjRTdEdUQjFhVEhlNGdPIiwiaWF0IjoxNDU0NDM4MTQ3LCJpc3MiOiJodHRwczovL2FwaS5zdG9ybXBhdGguY29tL3YxL2FwcGxpY2F0aW9ucy82dkZUNEFSZldDbXVIVlY4Vmt0alRvIiwic3ViIjoiaHR0cHM6Ly9hcGkuc3Rvcm1wYXRoLmNvbS92MS9hY2NvdW50cy80V1NjTWJBbm8zVjk1aWlTc3dralBYIiwiZXhwIjoxNDU0NDQxNzQ3LCJydGkiOiI2M1laa01xMTlzYUhxTHZqSDFtbzRLIn0.-3NNpi7-DTvl2VNCfHHFNwWVikmeCyNPy6KEu--XYjk" \ - http://localhost:${port}/me + http://localhost:${port}/userdetails You will get a response like this: @@ -644,7 +644,7 @@ curl \ -H "Authorization: Bearer eyJraWQiOiJSOTJTQkhKQzFVNERBSU1HUTNNSE9HVk1YIiwiYWxnIjoiSFMyNTYifQ.eyJqdGkiOiI1eDlxbWlES2U0RmlFMU02alhLSDBMIiwiaWF0IjoxNDU0NDQ0MTU1LCJpc3MiOiJodHRwczovL2FwaS5zdG9ybXBhdGguY29tL3YxL2FwcGxpY2F0aW9ucy82dkZUNEFSZldDbXVIVlY4Vmt0alRvIiwic3ViIjoiaHR0cHM6Ly9hcGkuc3Rvcm1wYXRoLmNvbS92MS9hY2NvdW50cy80V1NjTWJBbm8zVjk1aWlTc3dralBYIiwiZXhwIjoxNDU0NDQ3NzU1LCJydGkiOiI2M1laa01xMTlzYUhxTHZqSDFtbzRLIn0.J2NR7MV3OoolYImfUNiu8SCDvaQdresHTnPHgL7mO1Q" \ - http://localhost:${port}/me + http://localhost:${port}/userdetails Here's the response: