Skip to content

Instantly share code, notes, and snippets.

Created July 20, 2013 01:41
Show Gist options
  • Save anonymous/6043492 to your computer and use it in GitHub Desktop.
Save anonymous/6043492 to your computer and use it in GitHub Desktop.
Get current user password
import org.springframework.security.core.Authentication
import org.springframework.security.core.context.SecurityContextHolder
class AuthFilters {
def springSecurityService
def dataSource
def filters = {
databaseConn(controller: '*', action: '*') {
before = {
if(!(controllerName in ['login','logout','password']) && springSecurityService.isLoggedIn()) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth.getName(); //get logged in username
String password = (String)auth.getCredentials();
dataSource.setCredentialsForCurrentThread(username, password)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment