AuthN: Use EqualFold for skipping introspection endpoint (#69126)

Add equality check for introspect ep in basic.go
This commit is contained in:
Misi 2023-05-26 10:22:59 +02:00 committed by GitHub
parent 6a995d526a
commit 6702f07a87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -44,7 +44,7 @@ func (c *Basic) Test(ctx context.Context, r *authn.Request) bool {
return false
}
// 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 looksLikeBasicAuthRequest(r)

View File

@ -85,6 +85,12 @@ func TestBasic_Test(t *testing.T) {
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 {