Class DefaultClientRedirectService
- All Implemented Interfaces:
ClientRedirectService
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultClientRedirectService
(AuthorizedClientService<AuthorizedClient> clientService, AuthorizationServerService<AuthorizationServer> serverService) -
Method Summary
Modifier and TypeMethodDescriptionprotected AuthorizedClientService<AuthorizedClient>
getDefaultRedirectUrlForClientId
(String clientId) Used for returning the default redirect URL for the provided clientprotected Stream<org.springframework.web.util.UriComponents>
getPostAuthenticationSuccessRedirectUriComponents
(AuthorizedClient authorizedClient) protected AuthorizationServerService<AuthorizationServer>
boolean
isValidPostAuthenticationSuccessUrl
(String requestedRedirectUrl, AuthorizedClient authorizedClient) Similar toClientRedirectService.isValidPostAuthenticationSuccessUrl(String, String)
, but takes a pre-providedAuthorizedClient
for performing the validation.boolean
isValidPostAuthenticationSuccessUrl
(String requestedRedirectUrl, String clientId) Checks if the givenrequestedRedirectUrl
is valid when compared toAuthorizedClient.getPostAuthenticationSuccessRedirectUris()
.protected boolean
isValidPostAuthenticationSuccessUrlInternal
(String requestedRedirectUrl, Supplier<AuthorizedClient> authorizedClientSupplier) protected boolean
matchesWhitelistedPostAuthenticationSuccessRedirectUri
(org.springframework.web.util.UriComponents requested, org.springframework.web.util.UriComponents whitelisted) protected boolean
pathsEqual
(org.springframework.web.util.UriComponents uri1, org.springframework.web.util.UriComponents uri2) protected boolean
queryParamsMatch
(org.springframework.web.util.UriComponents requested, org.springframework.web.util.UriComponents whitelisted) Checks whether the query params in the requested redirect URI matches the ones specified in the whitelisted redirect URI.protected String
protected org.springframework.web.util.UriComponents
toUriComponents
(String uri)
-
Constructor Details
-
DefaultClientRedirectService
public DefaultClientRedirectService(AuthorizedClientService<AuthorizedClient> clientService, AuthorizationServerService<AuthorizationServer> serverService)
-
-
Method Details
-
getDefaultRedirectUrlForClientId
Description copied from interface:ClientRedirectService
Used for returning the default redirect URL for the provided client- Specified by:
getDefaultRedirectUrlForClientId
in interfaceClientRedirectService
- Parameters:
clientId
- The String id of the client to resolve the redirect URL for- Returns:
- The default redirect URL for the given client, if exists, or null
-
isValidPostAuthenticationSuccessUrl
Description copied from interface:ClientRedirectService
Checks if the givenrequestedRedirectUrl
is valid when compared toAuthorizedClient.getPostAuthenticationSuccessRedirectUris()
.By default, the validation is an exact match. If given a relative input, it must exactly match an existing relative whitelist value. If given an absolute input, it must exactly match an existing absolute whitelist value. Request parameters must also be an exact match.
Notably, at this time, Broadleaf does not use this method for redirects after standard login operations.
- Specified by:
isValidPostAuthenticationSuccessUrl
in interfaceClientRedirectService
- Parameters:
requestedRedirectUrl
- The URL to check. Can be absolute or relative.clientId
- The id of theAuthorizedClient
to use for validating the URL- Returns:
- True if the requested URL matches a value in
AuthorizedClient.getPostAuthenticationSuccessRedirectUris()
, false otherwise - See Also:
-
isValidPostAuthenticationSuccessUrl
public boolean isValidPostAuthenticationSuccessUrl(String requestedRedirectUrl, AuthorizedClient authorizedClient) Description copied from interface:ClientRedirectService
Similar toClientRedirectService.isValidPostAuthenticationSuccessUrl(String, String)
, but takes a pre-providedAuthorizedClient
for performing the validation.- Specified by:
isValidPostAuthenticationSuccessUrl
in interfaceClientRedirectService
- Parameters:
requestedRedirectUrl
- The URL to check. Can be absolute or relative.authorizedClient
- TheAuthorizedClient
to use for validating the URL- Returns:
- True if the requested URL matches a value in
AuthorizedClient.getPostAuthenticationSuccessRedirectUris()
, false otherwise - See Also:
-
isValidPostAuthenticationSuccessUrlInternal
protected boolean isValidPostAuthenticationSuccessUrlInternal(String requestedRedirectUrl, Supplier<AuthorizedClient> authorizedClientSupplier) -
getPostAuthenticationSuccessRedirectUriComponents
protected Stream<org.springframework.web.util.UriComponents> getPostAuthenticationSuccessRedirectUriComponents(AuthorizedClient authorizedClient) -
toUriComponents
-
matchesWhitelistedPostAuthenticationSuccessRedirectUri
protected boolean matchesWhitelistedPostAuthenticationSuccessRedirectUri(org.springframework.web.util.UriComponents requested, org.springframework.web.util.UriComponents whitelisted) -
queryParamsMatch
protected boolean queryParamsMatch(org.springframework.web.util.UriComponents requested, org.springframework.web.util.UriComponents whitelisted) Checks whether the query params in the requested redirect URI matches the ones specified in the whitelisted redirect URI.This checks that all the parameters specified in the whitelisted URI are present and match the expected values. Any additional params or param values in the requested URI are ignored as long as the required ones are present. For example, if the whitelisted URI has
?param1=value1
then this requested URI will pass?param1=value1,value2¶m2=otherValue
. However, this URI will not pass:?param1=value2
.- Parameters:
requested
- The requested URI to redirect towhitelisted
- One of the whitelisted redirect URIs- Returns:
- Whether
requested
matcheswhitelisted
.
-
pathsEqual
protected boolean pathsEqual(org.springframework.web.util.UriComponents uri1, org.springframework.web.util.UriComponents uri2) -
stripTrailingSlashIfPresent
-
getClientService
-
getServerService
-