To implement HMAC authentication, I made my own filter, provider and token. RestSecurityFilter:
public class RestSecurityFilter extends AbstractAuthenticationProcessingFilter { private final Logger LOG = LoggerFactory.getLogger(RestSecurityFilter.class); private AuthenticationManager authenticationManager; public RestSecurityFilter(String defaultFilterProcessesUrl) { super(defaultFilterProcessesUrl); } public RestSecurityFilter(RequestMatcher requiresAuthenticationRequestMatcher) { super(requiresAuthenticationRequestMatcher); } @Override public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { AuthenticationRequestWrapper request = new AuthenticationRequestWrapper(req);
Authentication Provider:
@Component public class RestAuthenticationProvider implements AuthenticationProvider { private final Logger LOG = LoggerFactory.getLogger(RestAuthenticationProvider.class); private ApiKeysService apiKeysService; @Autowired public void setApiKeysService(ApiKeysService apiKeysService) { this.apiKeysService = apiKeysService; } @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { RestToken restToken = (RestToken) authentication;
I do not know how to configure WebSecurityConfig to authenticate each request with my filter and authentication provider. I assume that I need to create @ Bean to initialize RestSecurityFilter . Also the JavaDoc for AbstractAuthenticationProcessingFilter says that I need the authenticationManager property. I would appreciate working with a custom filter, provider, and token.
java authentication spring-boot spring-security hmac
Loco May 28 '15 at 9:31 2015-05-28 09:31
source share