Reputation: 4093
In my Spring Boot app I have implemented login using Spring Social (1.1.4.RELEASE) (Facebook, Google, LinkedIn and Twitter).
During the login process the server calls the following HTTP GET:
https://accounts.google.com/o/oauth2/auth?client_id=XXX&response_type=code&redirect_uri=http://xzy.com:91/auth/google&scope=email&state=YYY
Problem is here: redirect_uri=http://xzy.com:91/auth/google
The app in behind the proxy and I need to change the redirect_uri to
http://xzy.com:91/auth/google -> http://xzy.com/auth/google
I guess this is pretty common problem, but I wasn't able to find working solution (
my pom:
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-security</artifactId>
<version>${spring-social-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-linkedin</artifactId>
<version>${spring-social-linkedin.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-twitter</artifactId>
<version>${spring-social-twitter.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-google</artifactId>
<version>${spring-social-google.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-facebook</artifactId>
<version>${spring-social-facebook.version}</version>
</dependency>
Upvotes: 3
Views: 943
Reputation: 2696
@Bean
public ProviderSignInController providerSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository) {
ProviderSignInController controller = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, new SimpleSignInAdapter());
// get the url from config, this just for example
controller.setApplicationUrl("http://xzy.com");
return controller;
}
As you can read from the code in spring-social
, the application url
will replace the base url.
protected String callbackUrl(NativeWebRequest request) {
if (callbackUrl != null) {
return callbackUrl;
}
HttpServletRequest nativeRequest = request.getNativeRequest(HttpServletRequest.class);
if (applicationUrl != null) {
return applicationUrl + connectPath(nativeRequest);
} else {
return nativeRequest.getRequestURL().toString();
}
}
Upvotes: 3