public abstract class AbstractCrowdSSOAuthenticationProcessingFilter
extends org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
Modifier and Type | Field and Description |
---|---|
protected ClientProperties |
clientProperties |
protected static Consumer<org.springframework.security.core.AuthenticationException> |
SILENT_AUTHENTICATION_EXCEPTION_SWALLOWER |
protected CrowdHttpTokenHelper |
tokenHelper |
Modifier | Constructor and Description |
---|---|
protected |
AbstractCrowdSSOAuthenticationProcessingFilter(ClientProperties clientProperties,
CrowdHttpTokenHelper tokenHelper) |
Modifier and Type | Method and Description |
---|---|
protected void |
appendSuppliers(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
com.google.common.collect.ImmutableList.Builder<org.apache.commons.lang3.tuple.Pair<Supplier<org.springframework.security.authentication.AbstractAuthenticationToken>,Consumer<org.springframework.security.core.AuthenticationException>>> builder) |
protected boolean |
canUseSavedRequestToAuthenticate(javax.servlet.http.HttpServletRequest request)
If the request has been redirected from a page it was not authorised to see, we want to
authenticate the login page using the application of the source page.
|
protected void |
doSetDetails(javax.servlet.http.HttpServletRequest request,
org.springframework.security.authentication.AbstractAuthenticationToken authRequest) |
protected org.springframework.security.core.Authentication |
getAuthenticatedToken(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
protected CrowdSSOAuthenticationDetails |
getAuthenticationDetails(javax.servlet.http.HttpServletRequest request) |
protected abstract CookieConfiguration |
getCookieConfiguration() |
protected String |
getSavedPath(javax.servlet.http.HttpServletRequest request) |
protected abstract void |
onUnsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Remove any SSO tokens associated with the request, effectively logging the user out of Crowd.
|
protected boolean |
requiresAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
This filter will process all requests, however, if the filterProcessesUrl
is part of the request URI, the filter will assume the request is a
username/password authentication (login) request and will not check
for Crowd SSO authentication.
|
protected void |
setDetails(javax.servlet.http.HttpServletRequest request,
org.springframework.security.authentication.UsernamePasswordAuthenticationToken authRequest)
Provided so that subclasses may configure what is put into the authentication request's details
property.
|
void |
setLoginUrlAuthenticationEntryPoint(org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint filterEntryPoint)
Optional dependency, only required if multiple Crowd applications are coexisting in the same
web-application.
|
void |
setRequestToApplicationMapper(RequestToApplicationMapper requestToApplicationMapper)
Optional dependency.
|
protected void |
storeTokenIfCrowd(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.springframework.security.core.Authentication authResult) |
protected void |
successfulAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain filterChain,
org.springframework.security.core.Authentication authResult)
Attempts to write out the successful SSO token to a cookie,
if an SSO token was generated and stored via the AuthenticationProvider.
|
protected void |
unsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.springframework.security.core.AuthenticationException failed) |
attemptAuthentication, getPasswordParameter, getUsernameParameter, obtainPassword, obtainUsername, setPasswordParameter, setPostOnly, setUsernameParameter
afterPropertiesSet, doFilter, getAllowSessionCreation, getAuthenticationManager, getFailureHandler, getRememberMeServices, getSuccessHandler, setAllowSessionCreation, setApplicationEventPublisher, setAuthenticationDetailsSource, setAuthenticationFailureHandler, setAuthenticationManager, setAuthenticationSuccessHandler, setContinueChainBeforeSuccessfulAuthentication, setFilterProcessesUrl, setMessageSource, setRememberMeServices, setRequiresAuthenticationRequestMatcher, setSessionAuthenticationStrategy
protected static final Consumer<org.springframework.security.core.AuthenticationException> SILENT_AUTHENTICATION_EXCEPTION_SWALLOWER
protected final ClientProperties clientProperties
protected final CrowdHttpTokenHelper tokenHelper
protected AbstractCrowdSSOAuthenticationProcessingFilter(ClientProperties clientProperties, CrowdHttpTokenHelper tokenHelper)
protected boolean requiresAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Otherwise, an authentication request to Crowd will be made to verify any existing Crowd SSO token (via the ProviderManager).
requiresAuthentication
in class org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
request
- servlet request containing either username/password paramaters
or the Crowd token as a cookie.response
- servlet response to write out cookie.true
only if the filterProcessesUrl is in the request URI.protected org.springframework.security.core.Authentication getAuthenticatedToken(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected void appendSuppliers(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.google.common.collect.ImmutableList.Builder<org.apache.commons.lang3.tuple.Pair<Supplier<org.springframework.security.authentication.AbstractAuthenticationToken>,Consumer<org.springframework.security.core.AuthenticationException>>> builder)
protected void setDetails(javax.servlet.http.HttpServletRequest request, org.springframework.security.authentication.UsernamePasswordAuthenticationToken authRequest)
Sets the validation factors from the HttpServletRequest on the authentication request. Also sets the application name to the name of application responsible for authorising a particular request. For single-crowd-application-per-spring-security-context web apps, this will just return the application name specified in the ClientProperties. For multi-crowd-applications-per-spring-security-context web apps, the requestToApplicationMapper will be used to determine the application name.
setDetails
in class org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
request
- that an authentication request is being created forauthRequest
- the authentication request object that should have its details setprotected boolean canUseSavedRequestToAuthenticate(javax.servlet.http.HttpServletRequest request)
If the request has been redirected from a page it was not authorised to see, we want to authenticate the login page using the application of the source page. The only pages that should receive that special treatment are the login page itself and 'j_spring_security_check', the submission target of the login page.
This method contains that definition, and will only return true
for those pages.
protected void doSetDetails(javax.servlet.http.HttpServletRequest request, org.springframework.security.authentication.AbstractAuthenticationToken authRequest)
protected CrowdSSOAuthenticationDetails getAuthenticationDetails(javax.servlet.http.HttpServletRequest request)
protected String getSavedPath(javax.servlet.http.HttpServletRequest request)
protected void successfulAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain, org.springframework.security.core.Authentication authResult) throws IOException, javax.servlet.ServletException
This effectively establishes SSO when using the CrowdAuthenticationProvider in conjunction with this filter.
successfulAuthentication
in class org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
request
- servlet request.response
- servlet response.authResult
- result of a successful authentication. If it is a CrowdSSOAuthenticationToken
then the SSO token will be set to the "credentials" property.IOException
- not thrown.javax.servlet.ServletException
protected void storeTokenIfCrowd(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authResult)
protected void unsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException failed) throws IOException, javax.servlet.ServletException
unsuccessfulAuthentication
in class org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
IOException
javax.servlet.ServletException
protected abstract void onUnsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
request
- servlet request.response
- servlet response.protected abstract CookieConfiguration getCookieConfiguration() throws Exception
Exception
public void setRequestToApplicationMapper(RequestToApplicationMapper requestToApplicationMapper)
requestToApplicationMapper
- only required if multiple Crowd "applications" need to
be accessed via the same Spring Security context, eg. when one web-application corresponds to
multiple Crowd "applications".public void setLoginUrlAuthenticationEntryPoint(org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint filterEntryPoint)
Copyright © 2021 Atlassian. All rights reserved.