You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientProperties.java
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/web/spring-security.adoc
+36-5Lines changed: 36 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,33 @@ If you have `spring-security-oauth2-client` on your classpath, you can take adva
101
101
This configuration makes use of the properties under javadoc:org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties[].
102
102
The same properties are applicable to both servlet and reactive applications.
103
103
104
+
Each registration must specify an OAuth 2 provider.
105
+
When set, the value of the `spring.security.oauth2.client.registration.<registration-id>.provider` property is used to specify the registration's provider.
106
+
If the `provider` property is not set, the registration's ID is used instead.
107
+
Both approaches are shown in the following example:
108
+
109
+
[configprops,yaml]
110
+
----
111
+
spring:
112
+
security:
113
+
oauth2:
114
+
client:
115
+
registration:
116
+
my-client:
117
+
client-id: "abcd"
118
+
client-secret: "password"
119
+
provider: "example"
120
+
example:
121
+
client-id: "abcd"
122
+
client-secret: "password"
123
+
----
124
+
125
+
The registrations `my-client` and `example` will both use the provider with ID `example`.
126
+
The former will do so due to the value of the `spring.security.oauth2.client.registration.my-client.provider` property.
127
+
The latter will do so due to its ID being `example` and there being no `provider` property configured for the registration.
128
+
129
+
The specified provider can either be a reference to a provider configured using `spring.security.oauth2.client.provider.<provider-id>.*` properties or one of the xref:web/spring-security.adoc#web.security.oauth2.client.common-providers[known common providers].
130
+
104
131
You can register multiple OAuth2 clients and providers under the `spring.security.oauth2.client` prefix, as shown in the following example:
105
132
106
133
[configprops,yaml]
@@ -150,6 +177,10 @@ spring:
150
177
user-name-attribute: "name"
151
178
----
152
179
180
+
In this example, there are three registrations.
181
+
In order of declaration, their IDs are `my-login-client`, `my-client-1`, and `my-client-2`.
182
+
There is also a single provider with ID `my-oauth-provider`.
183
+
153
184
For OpenID Connect providers that support https://openid.net/specs/openid-connect-discovery-1_0.html[OpenID Connect discovery], the configuration can be further simplified.
154
185
The provider needs to be configured with an `issuer-uri` which is the URI that it asserts as its Issuer Identifier.
155
186
For example, if the `issuer-uri` provided is "https://example.com", then an "OpenID Provider Configuration Request" will be made to "https://example.com/.well-known/openid-configuration".
@@ -182,12 +213,12 @@ For production environments, consider using a javadoc:org.springframework.securi
182
213
[[web.security.oauth2.client.common-providers]]
183
214
==== OAuth2 Client Registration for Common Providers
184
215
185
-
For common OAuth2 and OpenID providers, including Google, Github, Facebook, and Okta, we provide a set of provider defaults (`google`, `github`, `facebook`, and `okta`, respectively).
186
-
187
-
If you do not need to customize these providers, you can set the `provider` attribute to the one for which you need to infer defaults.
188
-
Also, if the key for the client registration matches a default supported provider, Spring Boot infers that as well.
216
+
For common OAuth2 and OpenID providers (Google, Github, Facebook, and Okta), we provide a set of provider defaults.
217
+
The IDs of these common provides are `google`, `github`, `facebook`, and `okta`, respectively.
189
218
190
-
In other words, the two configurations in the following example use the Google provider:
219
+
If you do not need to customize these providers, set the registration's `provider` property to the ID of one of the common providers.
220
+
Alternatively, you can xref:web/spring-security.adoc#web.security.oauth2.client[use a registration ID that matches the ID of the provider].
221
+
The two configurations in the following example use the common `google` provider:
0 commit comments