Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit d877b16

Browse files
committed
Updated Spring Security Refined section of the tutorial.
1 parent 681effd commit d877b16

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

docs/source/tutorial.rst

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,11 @@ In the next section, we'll add a small amount of code to be able to dynamically
512512
Spring Security Refined
513513
-----------------------
514514

515-
The code for this section can be found in `tutorials/spring-boot/03-spring-security-refined <https://github.com/stormpath/stormpath-sdk-java/tree/master/tutorials/spring-boot/03-spring-security-refined>`_.
515+
#if( $springboot )
516+
The code for this section can be found in `tutorials/spring-boot/03-spring-security-refined`_.
517+
#elseif( $spring )
518+
The code for this section can be found in `tutorials/spring/03-spring-security-refined`_.
519+
#end
516520

517521
In the previous section, we hard-coded the Stormpath group href into ``HelloService``.
518522

@@ -558,7 +562,7 @@ Let's now take a look at this ``groups`` bean.
558562
559563
@Autowired
560564
public Groups(Environment env) {
561-
USER = env.getProperty("stormpath.authorized.group.user");
565+
USER = env.getProperty("stormpath.authorized.user.group.href");
562566
}
563567
}
564568
@@ -569,17 +573,17 @@ By default, Spring will name the bean in context using camelcase conventions. Th
569573

570574
We use some Spring magic on lines 5 and 6 to pass the ``Environment`` into the constructor using the `@Autowired` annotation.
571575

572-
In the constructor, we set the ``USER`` variable to the value of the environment property called ``stormpath.authorized.group.user``.
576+
In the constructor, we set the ``USER`` variable to the value of the environment property called ``stormpath.authorized.user.group.href``.
573577

574-
The expectation is that the ``stormpath.authorized.group.user`` environment variable will hold the fully qualified href to the
578+
The expectation is that the ``stormpath.authorized.user.group.href`` environment variable will hold the fully qualified href to the
575579
Stormpath group that backs the ``USER`` group.
576580

577-
With Spring, you can define the ``stormpath.authorized.group.user`` in the ``application.properties`` file and that property will be available
578-
to your app.
581+
With Spring, you can define the ``stormpath.authorized.user.group.href`` in the ``application.properties`` file and that
582+
property will be available to your app.
579583

580-
Now, for the Stormpath magic. You can also have a system environment variable named ``STORMPATH_AUTHORIZED_GROUP_USER``.
584+
Now, for the Stormpath magic. You can also have a system environment variable named ``STORMPATH_AUTHORIZED_USER_GROUP_HREF``.
581585
Behind the scenes, Stormpath will convert that system environment variable to a Spring environment variable named
582-
``stormpath.authorized.group.user``.
586+
``stormpath.authorized.user.group.href``.
583587

584588
This makes it very easy to change the group ``USER`` group href in different deployment environments without having to
585589
reconfigure and recompile your code.
@@ -598,19 +602,28 @@ could update the ``Groups`` class like so:
598602
599603
@Autowired
600604
public Groups(Environment env) {
601-
USER = env.getProperty("stormpath.authorized.group.user");
602-
ADMIN = env.getProperty("stormpath.authorized.group.admin");
605+
USER = env.getProperty("stormpath.authorized.user.group.href");
606+
ADMIN = env.getProperty("stormpath.authorized.admin.group.href");
603607
}
604608
}
605609
606610
You can try this out for yourself by running this example like so:
607611

612+
#if( $springboot )
608613
.. code-block:: bash
609614
610615
mvn clean package
611616
612-
STORMPATH_AUTHORIZED_GROUP_USER=<href to your group in Stormpath> \
617+
STORMPATH_AUTHORIZED_USER_GROUP_HREF=<href to your group in Stormpath> \
613618
mvn spring-boot:run
619+
#elseif( $spring )
620+
.. code-block:: bash
621+
622+
mvn clean package
623+
624+
STORMPATH_AUTHORIZED_USER_GROUP_HREF=<href to your group in Stormpath> \
625+
mvn tomcat7:run
626+
#end
614627

615628
In this example, we are also taking advantage of Stormpath's configuration mechanism. This reduces boilerplate code.
616629

@@ -880,4 +893,6 @@ for more information on all that the Stormpath Java SDK has to offer.
880893
.. _tutorials/spring-boot/01-some-access-controls: https://github.com/stormpath/stormpath-sdk-java/tree/master/tutorials/spring-boot/01-some-access-controls
881894
.. _tutorials/spring/01-some-access-controls: https://github.com/stormpath/stormpath-sdk-java/tree/master/tutorials/spring/01-some-access-controls
882895
.. _tutorials/spring-boot/02-spring-security-ftw: https://github.com/stormpath/stormpath-sdk-java/tree/master/tutorials/spring-boot/02-spring-security-ftw
883-
.. _tutorials/spring/02-spring-security-ftw: https://github.com/stormpath/stormpath-sdk-java/tree/master/tutorials/spring/02-spring-security-ftw
896+
.. _tutorials/spring/02-spring-security-ftw: https://github.com/stormpath/stormpath-sdk-java/tree/master/tutorials/spring/02-spring-security-ftw
897+
.. _tutorials/spring-boot/03-spring-security-refined: https://github.com/stormpath/stormpath-sdk-java/tree/master/tutorials/spring-boot/03-spring-security-refined>
898+
.. _tutorials/spring/03-spring-security-refined: https://github.com/stormpath/stormpath-sdk-java/tree/master/tutorials/spring/03-spring-security-refined>

0 commit comments

Comments
 (0)