Package org.dspace.app.rest.security
Class OidcLoginFilter
java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
org.dspace.app.rest.security.StatelessLoginFilter
org.dspace.app.rest.security.OidcLoginFilter
- All Implemented Interfaces:
jakarta.servlet.Filter,Aware,BeanNameAware,DisposableBean,InitializingBean,ApplicationEventPublisherAware,EnvironmentAware,MessageSourceAware,EnvironmentCapable,ServletContextAware
This class will filter OpenID Connect (OIDC) requests and try and authenticate them.
In this case, the actual authentication is performed by OIDC. After authentication succeeds, OIDC will send
the authentication data to this filter in order for it to be processed by DSpace.
- Author:
- Pasquale Cavallo (pasquale.cavallo at 4science dot it)
-
Field Summary
Fields inherited from class org.dspace.app.rest.security.StatelessLoginFilter
authenticationManager, restAuthenticationServiceFields inherited from class org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
authenticationDetailsSource, eventPublisher, messagesFields inherited from class org.springframework.web.filter.GenericFilterBean
logger -
Constructor Summary
ConstructorsConstructorDescriptionOidcLoginFilter(String url, String httpMethod, AuthenticationManager authenticationManager, RestAuthenticationService restAuthenticationService) -
Method Summary
Modifier and TypeMethodDescriptionattemptAuthentication(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Attempt to authenticate the user by using Spring Security's AuthenticationManager.protected voidsuccessfulAuthentication(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, jakarta.servlet.FilterChain chain, Authentication auth) If the above attemptAuthentication() call was successful (no authentication error was thrown), then this method will take the returnedDSpaceAuthenticationclass (which includes all the data from the authenticated user) and add the authentication data to the response.Methods inherited from class org.dspace.app.rest.security.StatelessLoginFilter
afterPropertiesSet, unsuccessfulAuthenticationMethods inherited from class org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
doFilter, getAllowSessionCreation, getAuthenticationManager, getFailureHandler, getRememberMeServices, getSuccessHandler, requiresAuthentication, setAllowSessionCreation, setApplicationEventPublisher, setAuthenticationDetailsSource, setAuthenticationFailureHandler, setAuthenticationManager, setAuthenticationSuccessHandler, setContinueChainBeforeSuccessfulAuthentication, setFilterProcessesUrl, setMessageSource, setRememberMeServices, setRequiresAuthenticationRequestMatcher, setSecurityContextHolderStrategy, setSecurityContextRepository, setSessionAuthenticationStrategyMethods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
Constructor Details
-
OidcLoginFilter
public OidcLoginFilter(String url, String httpMethod, AuthenticationManager authenticationManager, RestAuthenticationService restAuthenticationService)
-
-
Method Details
-
attemptAuthentication
public Authentication attemptAuthentication(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) throws AuthenticationException Description copied from class:StatelessLoginFilterAttempt to authenticate the user by using Spring Security's AuthenticationManager. The AuthenticationManager will delegate this task to one or more AuthenticationProvider classes.For DSpace, our custom AuthenticationProvider is
EPersonRestAuthenticationProvider, so that is the authenticate() method which is called below.- Overrides:
attemptAuthenticationin classStatelessLoginFilter- Parameters:
req- current requestres- current response- Returns:
- a valid Spring Security Authentication object if authentication succeeds
- Throws:
AuthenticationException- if authentication fails- See Also:
-
successfulAuthentication
protected void successfulAuthentication(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, jakarta.servlet.FilterChain chain, Authentication auth) throws IOException, jakarta.servlet.ServletException Description copied from class:StatelessLoginFilterIf the above attemptAuthentication() call was successful (no authentication error was thrown), then this method will take the returnedDSpaceAuthenticationclass (which includes all the data from the authenticated user) and add the authentication data to the response.For DSpace, this is calling our
JWTTokenRestAuthenticationServiceImplin order to create a JWT based on the authentication data & send that JWT back in the response.- Overrides:
successfulAuthenticationin classStatelessLoginFilter- Parameters:
req- current requestres- responsechain- FilterChainauth- Authentication object containing info about user who had a successful authentication- Throws:
IOExceptionjakarta.servlet.ServletException- See Also:
-