refactor unprotected paths check

This commit is contained in:
David Christofas
2022-08-12 10:47:51 +02:00
parent f35c8b9205
commit ddfc01bff9
2 changed files with 38 additions and 26 deletions
@@ -25,11 +25,6 @@ const (
_bearerPrefix = "Bearer "
)
var (
// _unauthenticatePaths contains paths which don't need to be authenticated.
_unauthenticatePaths = [...]string{"/konnect/v1/userinfo", "/status.php"}
)
// OIDCProvider used to mock the oidc provider during tests
type OIDCProvider interface {
UserInfo(ctx context.Context, ts oauth2.TokenSource) (*gOidc.UserInfo, error)
@@ -146,14 +141,6 @@ func (m OIDCAuthenticator) shouldServe(req *http.Request) bool {
return false
}
// todo: looks dirty, check later
// TODO: make a PR to coreos/go-oidc for exposing userinfo endpoint on provider, see https://github.com/coreos/go-oidc/issues/248
for _, ignoringPath := range _unauthenticatePaths {
if req.URL.Path == ignoringPath {
return false
}
}
header := req.Header.Get(_headerAuthorization)
return strings.HasPrefix(header, _bearerPrefix)
}