Created
November 1, 2012 20:56
-
-
Save candrews/3996484 to your computer and use it in GitHub Desktop.
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
package com.mfc.marketing | |
import org.springframework.web.util.UriUtils | |
class PageFilters { | |
def permissionsMappingService | |
def filterLogic(Permission permission) { | |
log.debug("before filter for action[${actionName}] -> ${params}") | |
log.debug("url is ${request.request.requestURI}") | |
if(!permission) { | |
log.warn "Access denied for url ${request.request.requestURI}" | |
render status: 404 | |
} | |
params.filename = UriUtils.encodeQueryParam(permission.filename, "UTF-8"); | |
params.lang = UriUtils.encodeQueryParam(permission.locale, "UTF-8"); | |
} | |
def filters = { | |
page(controller:"pages", action:"serve") { | |
before = { | |
String uri = request.request.requestURI | |
Permission permission = permissionsMappingService.getPagePermission(uri) | |
filterLogic(permission) | |
} | |
after = { Map model -> | |
} | |
afterView = { Exception e -> | |
} | |
} | |
asset(controller:"assets", action:"serve") { | |
before = { | |
String uri = request.request.requestURI | |
Permission permission = permissionsMappingService.getPagePermission(uri) | |
filterLogic(permission) | |
} | |
} | |
} | |
} |
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
package com.mfc.marketing | |
import org.springframework.web.util.UriUtils | |
class PageFilters { | |
def permissionsMappingService | |
def filterLogic(Permission permission, String controller, String action) { | |
log.debug("before filter for action[${actionName}] -> ${params}") | |
log.debug("url is ${request.request.requestURI}") | |
if(permission){ | |
// TODO check permission.role, make sure user is authorized. if not render 403 and return false | |
params.filename = UriUtils.encodeQueryParam(permission.filename, "UTF-8"); | |
params.lang = UriUtils.encodeQueryParam(permission.locale, "UTF-8"); | |
forward(controller:controller, action:action); | |
} | |
} | |
def filters = { | |
page(uri:"/**") { | |
before = { | |
String uri = request.request.requestURI | |
Permission permission = permissionsMappingService.getPagePermission(uri) | |
filterLogic(permission, "pages", "serve") | |
} | |
} | |
asset(uri:"/**") { | |
before = { | |
String uri = request.request.requestURI | |
Permission permission = permissionsMappingService.getAssetPermission(uri) | |
filterLogic(permission, "assets", "serve") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment