pkg: authorization: add Err to tweak response status code

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2015-12-15 09:49:18 +01:00
parent 16870807fe
commit 16d022c482
3 changed files with 42 additions and 1 deletions

View file

@ -84,6 +84,10 @@ func (a *Ctx) AuthZRequest(w http.ResponseWriter, r *http.Request) error {
return err
}
if authRes.Err != "" {
return fmt.Errorf(authRes.Err)
}
if !authRes.Allow {
return fmt.Errorf(authRes.Msg)
}
@ -107,6 +111,10 @@ func (a *Ctx) AuthZResponse(rm ResponseModifier, r *http.Request) error {
return err
}
if authRes.Err != "" {
return fmt.Errorf(authRes.Err)
}
if !authRes.Allow {
return fmt.Errorf(authRes.Msg)
}