mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-24 22:47:14 +02:00
core/authorize: result denied improvements (#4952)
* core/authorize: result denied improvements * add authenticate robots.txt * fix tests
This commit is contained in:
parent
61a9bd7c6b
commit
55eb2fa3dc
8 changed files with 19 additions and 91 deletions
|
@ -136,6 +136,11 @@ func (a *Authorize) deniedResponse(
|
|||
|
||||
var respBody []byte
|
||||
switch {
|
||||
case getCheckRequestURL(in).Path == "/robots.txt":
|
||||
code = 200
|
||||
respBody = []byte("User-agent: *\nDisallow: /")
|
||||
respHeader = append(respHeader,
|
||||
mkHeader("Content-Type", "text/plain"))
|
||||
case isJSONWebRequest(in):
|
||||
respBody, _ = json.Marshal(map[string]any{
|
||||
"error": reason,
|
||||
|
@ -369,7 +374,11 @@ func isGRPCWebRequest(in *envoy_service_auth_v3.CheckRequest) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
return accept.Acceptable("application/grpc-web-text")
|
||||
mediaType, _ := accept.MostAcceptable([]string{
|
||||
"text/html",
|
||||
"application/grpc-web-text",
|
||||
})
|
||||
return mediaType == "application/grpc-web-text"
|
||||
}
|
||||
|
||||
func isJSONWebRequest(in *envoy_service_auth_v3.CheckRequest) bool {
|
||||
|
@ -388,7 +397,11 @@ func isJSONWebRequest(in *envoy_service_auth_v3.CheckRequest) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
return accept.Acceptable("application/json")
|
||||
mediaType, _ := accept.MostAcceptable([]string{
|
||||
"text/html",
|
||||
"application/json",
|
||||
})
|
||||
return mediaType == "application/json"
|
||||
}
|
||||
|
||||
func getHeader(hdrs map[string]string, key string) string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue