Update redirect-uri-template in oauth sample and docs

Fixes gh-11014
pull/11071/head
Madhura Bhave 7 years ago
parent d1766509f1
commit 4a41c02926

@ -2900,7 +2900,7 @@ You can register multiple OAuth2 clients and providers under the
spring.security.oauth2.client.registration.my-client-1.client-name=Client for user scope
spring.security.oauth2.client.registration.my-client-1.provider=my-oauth-provider
spring.security.oauth2.client.registration.my-client-1.scope=user
spring.security.oauth2.client.registration.my-client-1.redirect-uri=http://my-redirect-uri.com
spring.security.oauth2.client.registration.my-client-1.redirect-uri-template=http://my-redirect-uri.com
spring.security.oauth2.client.registration.my-client-1.client-authentication-method=basic
spring.security.oauth2.client.registration.my-client-1.authorization-grant-type=authorization_code
@ -2909,7 +2909,7 @@ You can register multiple OAuth2 clients and providers under the
spring.security.oauth2.client.registration.my-client-2.client-name=Client for email scope
spring.security.oauth2.client.registration.my-client-2.provider=my-oauth-provider
spring.security.oauth2.client.registration.my-client-2.scope=email
spring.security.oauth2.client.registration.my-client-2.redirect-uri=http://my-redirect-uri.com
spring.security.oauth2.client.registration.my-client-2.redirect-uri-template=http://my-redirect-uri.com
spring.security.oauth2.client.registration.my-client-2.client-authentication-method=basic
spring.security.oauth2.client.registration.my-client-2.authorization-grant-type=authorization_code
@ -2920,6 +2920,28 @@ You can register multiple OAuth2 clients and providers under the
spring.security.oauth2.client.provider.my-oauth-provider.user-name-attribute=name
----
By default, Spring Security's `OAuth2LoginAuthenticationFilter` will only process URLs matching
`/login/oauth2/code/*`. If you want to customize the `redirect-uri-template` to use a different pattern,
you will need to provide configuration to process that custom pattern. For example, you can add your own
`WebSecurityConfigurerAdapter` that looks like this:
[source,java,indent=0]
----
public class OAuth2LoginSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.oauth2Login()
.redirectionEndpoint()
.baseUri("/custom-callback");
}
}
----
For common OAuth2 and OpenID providers such as Google, Github, Facebook, and Okta,
we provide a set of provider defaults (`google`, `github`, `facebook`, and `okta`
respectively).

@ -2,7 +2,7 @@
== Register Github OAuth2 application
To run the sample, you need to link:https://github.com/settings/applications/new[register an OAuth application on Github].
While registering your application, ensure the Authorization callback URL is set to http://localhost:8080/oauth2/authorize/code/github.
While registering your application, ensure the Authorization callback URL is set to http://localhost:8080/login/oauth2/code/github.
After completing the registration, you will have a new OAuth Application with a Client ID and Client Secret.
== Configuring application.yml

@ -9,11 +9,11 @@ spring:
client-name: Github user
provider: github
scope: user
redirect_uri: http://localhost:8080/oauth2/authorize/code/github
redirect-uri-template: http://localhost:8080/login/oauth2/code/github
github-client-2:
client-id: ${APP-CLIENT-ID}
client-secret: ${APP-CLIENT-SECRET}
client-name: Github email
provider: github
scope: user:email
redirect_uri: http://localhost:8080/oauth2/authorize/code/github
redirect-uri-template: http://localhost:8080/login/oauth2/code/github
Loading…
Cancel
Save