fix: allow scim content type wildcards (#9245)

# Which Problems Are Solved
- requests to the scim interface with content type `*/*` are rejected

# How the Problems Are Solved
- `*/*` is accepted as content type

# Additional Context
Part of #8140
This commit is contained in:
Lars 2025-01-27 17:10:30 +01:00 committed by GitHub
parent 741434806a
commit b19333726c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,8 +13,10 @@ import (
)
const (
ContentTypeScim = "application/scim+json"
ContentTypeJson = "application/json"
ContentTypeScim = "application/scim+json"
ContentTypeJson = "application/json"
ContentTypeApplicationWildcard = "application/*"
ContentTypeWildcard = "*/*"
)
func ContentTypeMiddleware(next middleware.HandlerFuncWithError) middleware.HandlerFuncWithError {
@ -44,7 +46,11 @@ func validateContentType(contentType string) bool {
return false
}
if mediaType != "" && !strings.EqualFold(mediaType, ContentTypeJson) && !strings.EqualFold(mediaType, ContentTypeScim) {
if mediaType != "" &&
!strings.EqualFold(mediaType, ContentTypeWildcard) &&
!strings.EqualFold(mediaType, ContentTypeApplicationWildcard) &&
!strings.EqualFold(mediaType, ContentTypeJson) &&
!strings.EqualFold(mediaType, ContentTypeScim) {
return false
}