Created
July 20, 2013 01:41
-
-
Save anonymous/6043492 to your computer and use it in GitHub Desktop.
Get current user password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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