mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AuthN: Use EqualFold for skipping introspection endpoint (#69126)
Add equality check for introspect ep in basic.go
This commit is contained in:
parent
6a995d526a
commit
6702f07a87
@ -44,7 +44,7 @@ func (c *Basic) Test(ctx context.Context, r *authn.Request) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// The OAuth2 introspection endpoint uses basic auth but is handled by the oauthserver package.
|
// The OAuth2 introspection endpoint uses basic auth but is handled by the oauthserver package.
|
||||||
if strings.HasPrefix(r.HTTPRequest.RequestURI, "/oauth2/introspect") {
|
if strings.EqualFold(r.HTTPRequest.RequestURI, "/oauth2/introspect") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return looksLikeBasicAuthRequest(r)
|
return looksLikeBasicAuthRequest(r)
|
||||||
|
@ -85,6 +85,12 @@ func TestBasic_Test(t *testing.T) {
|
|||||||
HTTPRequest: &http.Request{Header: map[string][]string{authorizationHeaderName: {"something"}}},
|
HTTPRequest: &http.Request{Header: map[string][]string{authorizationHeaderName: {"something"}}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "should fail when the URL ends with /oauth2/introspect",
|
||||||
|
req: &authn.Request{
|
||||||
|
HTTPRequest: &http.Request{Header: map[string][]string{authorizationHeaderName: {encodeBasicAuth("user", "password")}}, RequestURI: "/oauth2/introspect"},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user