Last active
August 29, 2015 14:13
-
-
Save aweigold/517acb0fefdc391fffa6 to your computer and use it in GitHub Desktop.
Auditing your Spring Security mappings with Groovy
This file contains hidden or 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
//Add net.sf.corn:corn-cps:1.0.1 to your classpath | |
import net.sf.corn.cps.* | |
import org.springframework.stereotype.Controller | |
import org.springframework.web.bind.annotation.RequestMapping | |
import org.springframework.security.access.prepost.PreAuthorize | |
def classes = CPScanner.scanClasses(new PackageNameFilter("com.company.*"), new ClassFilter().appendAnnotation(Controller)) | |
classes.each { clazz -> | |
clazz.getDeclaredMethods().each { method -> | |
RequestMapping mapping = method.getAnnotation(RequestMapping) | |
if (mapping != null){ | |
PreAuthorize auth = method.getAnnotation(PreAuthorize) | |
if (auth != null){ | |
println "URL: " + mapping.value() | |
println "PERM: " + auth.value() | |
println "------" | |
} | |
} | |
} | |
} | |
return "DONE!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment