Skip to content

Instantly share code, notes, and snippets.

@Kallin
Kallin / branch_clean.rb
Created February 27, 2015 17:14
delete selected branches in ruby
delete_branches = [
'branch_a',
'branch_b',
'branch_c',
]
delete_branches.each do |branch|
system "git branch -D #{branch}"
system "git push origin --delete #{branch}"
end
module Elasticsearcher
module QuerybuilderAdapter
def self.included base
base.extend ClassMethods
end
module ClassMethods
QUERYBUILDER_TO_ELASTIC_RANGES = {
'before' => 'lt',
@Kallin
Kallin / Config.groovy
Created June 22, 2012 18:07
Config.groovy
grails.plugins.springsecurity.providerNames = [
'samlAuthenticationProvider',
'daoAuthenticationProvider',
'anonymousAuthenticationProvider',
'rememberMeAuthenticationProvider']
@Kallin
Kallin / SamlAuthenticationProvider.groovy
Created June 22, 2012 18:05
SamlAuthenticationProvider.groovy
import org.springframework.security.authentication.dao.DaoAuthenticationProvider
import org.springframework.security.core.Authentication
import sonicg.authentication.SAMLAuthenticationService
class SamlAuthenticationProvider extends DaoAuthenticationProvider {
@Override
Authentication authenticate(Authentication authentication) {
def token = (SamlAuthenticationToken) authentication
@Kallin
Kallin / SamlAuthenticationToken.groovy
Created June 22, 2012 18:01
SamlAuthenticationToken.groovy
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken
import org.springframework.security.core.userdetails.UserDetails
class SamlAuthenticationToken extends UsernamePasswordAuthenticationToken {
String token
public SamlAuthenticationToken(String token) {
super(null, null);
this.token = token;
@Kallin
Kallin / bootstrap.groovy
Created June 22, 2012 17:59
bootstrap.groovy
import org.codehaus.groovy.grails.plugins.springsecurity.SecurityFilterPosition
import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
class BootStrap {
def init = { servletContext ->
SpringSecurityUtils.clientRegisterFilter('samlAuthenticationFilter', SecurityFilterPosition.SECURITY_CONTEXT_FILTER.order + 10)
}
def destroy = {
@Kallin
Kallin / resources.groovy
Created June 22, 2012 17:57
resources.groovy
import SamlAuthenticationFilter
import SamlAuthenticationProvider
beans = {
samlAuthenticationFilter(SamlAuthenticationFilter) {
authenticationManager = ref('authenticationManager')
sessionAuthenticationStrategy = ref('sessionAuthenticationStrategy')
authenticationSuccessHandler = ref('authenticationSuccessHandler')
authenticationFailureHandler = ref('authenticationFailureHandler')
rememberMeServices = ref('rememberMeServices')
@Kallin
Kallin / SamlAuthenticationFilter.groovy
Created June 22, 2012 17:52
SamlAuthenticationFilter.groovy
class SamlAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
public SamlAuthenticationFilter() {
super("/somecustomauth")
}
@Override
Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) {
if (!request.getMethod().equals("POST")) {
throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod())
@Kallin
Kallin / persistent_session_attribute_value.groovy
Created June 19, 2012 23:02
persistent_session_attribute_value serialized column
column(name: "serialized", type: "bytea(20000)") {
constraints(nullable: "false")
}
@Kallin
Kallin / dbsessionpk.groovy
Created June 19, 2012 22:58
dbsession pk gen
column(autoIncrement: "true", name: "id", type: "int8") {
constraints(nullable: "false", primaryKey: "true", primaryKeyName: "persistent_sePK")
}