Skip to content

Instantly share code, notes, and snippets.

@eogiles
eogiles / gist:5723287
Created June 6, 2013 17:28
MockRequestHeaderAuthenticationFilter groovy class
package com.example.test.util
import org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter
class MockRequestHeaderAuthenticationFilter extends RequestHeaderAuthenticationFilter {
String mockPrincipal
@Override
protected Object getPreAuthenticatedPrincipal(javax.servlet.http.HttpServletRequest request) {
@eogiles
eogiles / gist:5723252
Last active December 18, 2015 04:08
Registering mock and production shib filters in BootStrap
environments {
development {
SpringSecurityUtils.clientRegisterFilter('mockTestFilter', SecurityFilterPosition.PRE_AUTH_FILTER.order + 10)
}
test {
SpringSecurityUtils.clientRegisterFilter('mockTestFilter', SecurityFilterPosition.PRE_AUTH_FILTER.order + 10)
}
qa {
SpringSecurityUtils.clientRegisterFilter('shibAuthFilter', SecurityFilterPosition.PRE_AUTH_FILTER.order + 10)
}
@eogiles
eogiles / gist:5723186
Last active December 18, 2015 04:08
Grails spring bean setup for shib auth
beans = {
userDetailsServiceWrapper(org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper) {
userDetailsService = ref('userDetailsService')
}
preauthAuthenticationProvider(org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider) {
preAuthenticatedUserDetailsService = ref('userDetailsServiceWrapper')
}
shibAuthFilter(org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter) {
package sample;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.text.DateFormat;
import java.text.SimpleDateFormat;