From 0d339aeda61b558a2e45e2e688bc0eaf2ecc399d Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Mon, 20 Sep 2021 16:51:25 -0500 Subject: [PATCH] Add Reactive Getting Started Page --- docs/modules/ROOT/nav.adoc | 1 + .../ROOT/pages/reactive/getting-started.adoc | 80 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 docs/modules/ROOT/pages/reactive/getting-started.adoc diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 86e69a6013..c5a915faa9 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -81,6 +81,7 @@ *** xref:servlet/appendix/namespace.adoc[XML Namespace] *** xref:servlet/appendix/faq.adoc[FAQ] * xref:reactive/index.adoc[Reactive Applications] +** xref:reactive/getting-started.adoc[Getting Started] ** xref:reactive/webflux.adoc[WebFlux Security] ** xref:reactive/exploits/index.adoc[Protection Against Exploits] *** xref:reactive/exploits/csrf.adoc[CSRF] diff --git a/docs/modules/ROOT/pages/reactive/getting-started.adoc b/docs/modules/ROOT/pages/reactive/getting-started.adoc new file mode 100644 index 0000000000..aac4095a4c --- /dev/null +++ b/docs/modules/ROOT/pages/reactive/getting-started.adoc @@ -0,0 +1,80 @@ +[[getting-started]] += Getting Started with WebFlux Applications + +This section covers the minimum setup for how to use Spring Security with Spring Boot in a reactive application. + +[NOTE] +==== +The completed application can be found {gh-samples-url}/reactive/webflux/java/hello-security[in our samples repository]. +For your convenience, you can download a minimal Reactive Spring Boot + Spring Security application by https://start.spring.io/starter.zip?type=maven-project&language=java&packaging=jar&jvmVersion=1.8&groupId=example&artifactId=hello-security&name=hello-security&description=Hello%20Security&packageName=example.hello-security&dependencies=webflux,security[clicking here]. +==== + +[[dependencies]] +== Updating Dependencies + +You can add Spring Security to your Spring Boot project by adding `spring-boot-starter-security`. + +==== +.Maven +[source,xml,role="primary"] +---- + + org.springframework.boot + spring-boot-starter-security + +---- + +.Gradle +[source,groovy,role="secondary"] +---- + implementation 'org.springframework.boot:spring-boot-starter-security' +---- +==== + + +[[servlet-hello-starting]] +== Starting Hello Spring Security Boot + +You can now https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-running-with-the-maven-plugin[run the Spring Boot application] by using the Maven Plugin's `run` goal. +The following example shows how to do so (and the beginning of the output from doing so): + +.Running Spring Boot Application + +==== +.Maven +[source,bash,role="primary"] +---- +$ ./mvnw spring-boot:run +... +INFO 23689 --- [ restartedMain] .s.s.UserDetailsServiceAutoConfiguration : + +Using generated security password: 8e557245-73e2-4286-969a-ff57fe326336 + +... +---- + +.Gradle +[source,bash,role="secondary"] +---- +$ ./gradlew bootRun +... +INFO 23689 --- [ restartedMain] .s.s.UserDetailsServiceAutoConfiguration : + +Using generated security password: 8e557245-73e2-4286-969a-ff57fe326336 + +... +---- +==== + +[[authenticating]] +== Authenticating + +You can access the application at http://localhost:8080/ which will redirect the browser to the default log in page. You can provide the default username of `user` with the randomly generated password that is logged to the console. The browser is then taken to the orginally requested page. + +To log out you can visit http://localhost:8080/logout and then confirming you wish to log out. + +[[auto-configuration]] +== Spring Boot Auto Configuration + +Spring Boot automatically adds Spring Security which requires all requests be authenticated. It also generates a user with a randomly generated password that is logged to the console which can be used to authenticate using form or basic authentication. +