From 1e1b8ab3e74a9c2035a6f681f95347020e1f7d82 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Tue, 18 Sep 2018 09:55:49 -0500 Subject: [PATCH] Add WebFlux OAuth2 Client Reference Fixes: gh- 5865 --- .../reactive/oauth2/access-token.adoc | 34 +++++++++++++++++++ .../_includes/reactive/oauth2/index.adoc | 2 ++ 2 files changed, 36 insertions(+) create mode 100644 docs/manual/src/docs/asciidoc/_includes/reactive/oauth2/access-token.adoc diff --git a/docs/manual/src/docs/asciidoc/_includes/reactive/oauth2/access-token.adoc b/docs/manual/src/docs/asciidoc/_includes/reactive/oauth2/access-token.adoc new file mode 100644 index 0000000000..5f9281bd66 --- /dev/null +++ b/docs/manual/src/docs/asciidoc/_includes/reactive/oauth2/access-token.adoc @@ -0,0 +1,34 @@ += Access Token + +Spring Security's OAuth Support allows obtaining an access token without authenticating. +A basic configuration with Spring Boot can be seen below: + +[source,yml] +---- +spring: + security: + oauth2: + client: + registration: + github: + client-id: replace-with-client-id + client-secret: replace-with-client-secret + scopes: read:user,public_repo +---- + +You will need to replace the `client-id` and `client-secret` with values registered with GitHub. + +The next step is to instruct Spring Security that you wish to act as an OAuth2 Client so that you can obtain an access token. + +[source,java] +---- +@Bean +SecurityWebFilterChain configure(ServerHttpSecurity http) throws Exception { + http + // ... + .oauth2Client(); + return http.build(); +} +---- + +You can now leverage Spring Security's <> support to obtain and use the access token. diff --git a/docs/manual/src/docs/asciidoc/_includes/reactive/oauth2/index.adoc b/docs/manual/src/docs/asciidoc/_includes/reactive/oauth2/index.adoc index cd10b1223c..047a1e4eb7 100644 --- a/docs/manual/src/docs/asciidoc/_includes/reactive/oauth2/index.adoc +++ b/docs/manual/src/docs/asciidoc/_includes/reactive/oauth2/index.adoc @@ -3,3 +3,5 @@ Spring Security provides OAuth2 and WebFlux integration for reactive applications. include::login.adoc[leveloffset+=1] + +include::access-token.adoc[leveloffset+=1]