Class ProviderSignInController
- java.lang.Object
-
- org.springframework.social.connect.web.ProviderSignInController
-
@Controller @RequestMapping("/signin") public class ProviderSignInController extends ObjectSpring MVC Controller for handling the provider user sign-in flow.- POST /signin/{providerId} - Initiate user sign-in with {providerId}.
- GET /signin/{providerId}?oauth_token&oauth_verifier||code - Receive {providerId} authentication callback and establish the connection.
- Author:
- Keith Donald
-
-
Constructor Summary
Constructors Constructor Description ProviderSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository, SignInAdapter signInAdapter)Creates a new provider sign-in controller.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSignInInterceptor(ProviderSignInInterceptor<?> interceptor)Adds a ConnectInterceptor to receive callbacks during the connection process.org.springframework.web.servlet.view.RedirectViewcanceledAuthorizationCallback()Process the authentication callback when neither the oauth_token or code parameter is given, likely indicating that the user denied authorization with the provider.org.springframework.web.servlet.view.RedirectViewoauth1Callback(String providerId, org.springframework.web.context.request.NativeWebRequest request)Process the authentication callback from an OAuth 1 service provider.org.springframework.web.servlet.view.RedirectViewoauth2Callback(String providerId, String code, org.springframework.web.context.request.NativeWebRequest request)Process the authentication callback from an OAuth 2 service provider.org.springframework.web.servlet.view.RedirectViewoauth2ErrorCallback(String providerId, String error, String errorDescription, String errorUri, org.springframework.web.context.request.NativeWebRequest request)Process an error callback from an OAuth 2 authorization as described at http://tools.ietf.org/html/rfc6749#section-4.1.2.1.voidsetApplicationUrl(String applicationUrl)Configures the base secure URL for the application this controller is being used in e.g.voidsetPostSignInUrl(String postSignInUrl)Sets the default URL to redirect the user to after signing in using a provider.voidsetSignInInterceptors(List<ProviderSignInInterceptor<?>> interceptors)Configure the list of sign in interceptors that should receive callbacks during the sign in process.voidsetSignInUrl(String signInUrl)Sets the URL of the application's sign in page.voidsetSignUpUrl(String signUpUrl)Sets the URL to redirect the user to if no local user account can be mapped when signing in using a provider.org.springframework.web.servlet.view.RedirectViewsignIn(String providerId, org.springframework.web.context.request.NativeWebRequest request)Process a sign-in form submission by commencing the process of establishing a connection to the provider on behalf of the user.
-
-
-
Constructor Detail
-
ProviderSignInController
@Inject public ProviderSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository, SignInAdapter signInAdapter)
Creates a new provider sign-in controller.- Parameters:
connectionFactoryLocator- the locator ofconnection factoriesused to support provider sign-in. Note: this reference should be a serializable proxy to a singleton-scoped target instance. This is becauseProviderSignInAttemptare session-scoped objects that hold ConnectionFactoryLocator references. If these references cannot be serialized, NotSerializableExceptions can occur at runtime.usersConnectionRepository- the global store for service provider connections across all users. Note: this reference should be a serializable proxy to a singleton-scoped target instance.signInAdapter- handles user sign-in
-
-
Method Detail
-
setSignInInterceptors
public void setSignInInterceptors(List<ProviderSignInInterceptor<?>> interceptors)
Configure the list of sign in interceptors that should receive callbacks during the sign in process. Convenient when an instance of this class is configured using a tool that supports JavaBeans-based configuration.- Parameters:
interceptors- the sign in interceptors to add
-
setSignInUrl
public void setSignInUrl(String signInUrl)
Sets the URL of the application's sign in page. Defaults to "/signin".- Parameters:
signInUrl- the signIn URL
-
setSignUpUrl
public void setSignUpUrl(String signUpUrl)
Sets the URL to redirect the user to if no local user account can be mapped when signing in using a provider. Defaults to "/signup".- Parameters:
signUpUrl- the signUp URL
-
setPostSignInUrl
public void setPostSignInUrl(String postSignInUrl)
Sets the default URL to redirect the user to after signing in using a provider. Defaults to "/".- Parameters:
postSignInUrl- the postSignIn URL
-
setApplicationUrl
public void setApplicationUrl(String applicationUrl)
Configures the base secure URL for the application this controller is being used in e.g.https://myapp.com. Defaults to null. If specified, will be used to generate OAuth callback URLs. If not specified, OAuth callback URLs are generated from web request info. You may wish to set this property if requests into your application flow through a proxy to your application server. In this case, the request URI may contain a scheme, host, and/or port value that points to an internal server not appropriate for an external callback URL. If you have this problem, you can set this property to the base external URL for your application and it will be used to construct the callback URL instead.- Parameters:
applicationUrl- the application URL value
-
addSignInInterceptor
public void addSignInInterceptor(ProviderSignInInterceptor<?> interceptor)
Adds a ConnectInterceptor to receive callbacks during the connection process. Useful for programmatic configuration.- Parameters:
interceptor- the connect interceptor to add
-
signIn
@RequestMapping(value="/{providerId}", method=POST) public org.springframework.web.servlet.view.RedirectView signIn(@PathVariable String providerId, org.springframework.web.context.request.NativeWebRequest request)Process a sign-in form submission by commencing the process of establishing a connection to the provider on behalf of the user. For OAuth1, fetches a new request token from the provider, temporarily stores it in the session, then redirects the user to the provider's site for authentication authorization. For OAuth2, redirects the user to the provider's site for authentication authorization.
-
oauth1Callback
@RequestMapping(value="/{providerId}", method=GET, params="oauth_token") public org.springframework.web.servlet.view.RedirectView oauth1Callback(@PathVariable String providerId, org.springframework.web.context.request.NativeWebRequest request)Process the authentication callback from an OAuth 1 service provider. Called after the member authorizes the authentication, generally done once by having he or she click "Allow" in their web browser at the provider's site. Handles the provider sign-in callback by first determining if a local user account is associated with the connected provider account. If so, signs the local user in by delegating toSignInAdapter.signIn(String, Connection, NativeWebRequest)If not, redirects the user to a signup page to create a new account withProviderSignInAttemptcontext exposed in the HttpSession.- See Also:
ProviderSignInAttempt,ProviderSignInUtils
-
oauth2Callback
@RequestMapping(value="/{providerId}", method=GET, params="code") public org.springframework.web.servlet.view.RedirectView oauth2Callback(@PathVariable String providerId, @RequestParam("code") String code, org.springframework.web.context.request.NativeWebRequest request)Process the authentication callback from an OAuth 2 service provider. Called after the user authorizes the authentication, generally done once by having he or she click "Allow" in their web browser at the provider's site. Handles the provider sign-in callback by first determining if a local user account is associated with the connected provider account. If so, signs the local user in by delegating toSignInAdapter.signIn(String, Connection, NativeWebRequest). If not, redirects the user to a signup page to create a new account withProviderSignInAttemptcontext exposed in the HttpSession.- See Also:
ProviderSignInAttempt,ProviderSignInUtils
-
oauth2ErrorCallback
@RequestMapping(value="/{providerId}", method=GET, params="error") public org.springframework.web.servlet.view.RedirectView oauth2ErrorCallback(@PathVariable String providerId, @RequestParam("error") String error, @RequestParam(value="error_description",required=false) String errorDescription, @RequestParam(value="error_uri",required=false) String errorUri, org.springframework.web.context.request.NativeWebRequest request)Process an error callback from an OAuth 2 authorization as described at http://tools.ietf.org/html/rfc6749#section-4.1.2.1. Called after upon redirect from an OAuth 2 provider when there is some sort of error during authorization, typically because the user denied authorization. Simply carries the error parameters through to the sign-in page.
-
canceledAuthorizationCallback
@RequestMapping(value="/{providerId}", method=GET) public org.springframework.web.servlet.view.RedirectView canceledAuthorizationCallback()Process the authentication callback when neither the oauth_token or code parameter is given, likely indicating that the user denied authorization with the provider. Redirects to application's sign in URL, as set in the signInUrl property.
-
-