HTTP-. HTTP- , . spring -security . , HTTP- 401, . / , .
Grails , "" grails-app/conf. :
class SimpleAuthFilters {
def USERNAME = "foo"
def PASSWORD = "bar"
static filters = {
httpAuth(uri:"/**") {
before = {
def authHeader = request.getHeader('Authorization')
if (authHeader) {
def usernamePassword = new String(authHeader.split(' ')[1].decodeBase64())
if (usernamePassword == "$USERNAME:$PASSWORD") {
return true
}
}
response.setHeader('WWW-Authenticate', 'basic realm="myRealm"')
response.sendError(response.SC_UNAUTHORIZED)
return false
}
}
}
}