mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-11-25 10:51:08 +00:00
find -name "*.adoc" | xargs -I{file} awk -v file={file} '/\[\[/ { gsub("\[|\]", ""); id=$0; gsub("./docs/modules/ROOT/pages/", "", file); gsub("\[|\]", ""); id=$0;getline;text=$0; sub("^=+ ","", text); print file > "build/ids/"id".id"; print text > "build/ids/"id".text" }' {file}
find docs/modules -name "*.adoc"|while read adoc_file_to_replace; do
echo "Replacing $adoc_file_to_replace"
for id_file in build/ids/*.id; do
id=$(basename $id_file | sed 's/\.id$//')
xref_page=$(cat $id_file)
if [[ "$adoc_file_to_replace" -ef "./docs/modules/ROOT/pages/$xref_page" ]]
then
echo " - Skipping same page refid $id "
else
sed -i -E "s%<<$id(|,([^,>]+))>>%xref:${xref_page}#${id}[\2]%g" $adoc_file_to_replace
fi
done
done
53 lines
1.3 KiB
Plaintext
53 lines
1.3 KiB
Plaintext
[[webflux-oauth2-client]]
|
|
= OAuth2 Client
|
|
|
|
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
|
|
scope: 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.
|
|
|
|
.OAuth2 Client
|
|
====
|
|
.Java
|
|
[source,java,role="primary"]
|
|
----
|
|
@Bean
|
|
SecurityWebFilterChain configure(ServerHttpSecurity http) throws Exception {
|
|
http
|
|
// ...
|
|
.oauth2Client(withDefaults());
|
|
return http.build();
|
|
}
|
|
----
|
|
|
|
|
|
.Kotlin
|
|
[source,kotlin,role="secondary"]
|
|
----
|
|
@Bean
|
|
fun webFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
|
|
return http {
|
|
// ...
|
|
oauth2Client { }
|
|
}
|
|
}
|
|
----
|
|
====
|
|
|
|
You can now leverage Spring Security's <<webclient>> or xref:reactive/registered-oauth2-authorized-client.adoc#webflux-roac[@RegisteredOAuth2AuthorizedClient] support to obtain and use the access token.
|