Oc Auth x Hydra x LDAP : draft of claims enrich for traefik + draft of forwarding

This commit is contained in:
mr
2024-10-28 14:58:11 +01:00
parent 05c4aab72a
commit 7198c40d30
37 changed files with 4181 additions and 610 deletions

View File

@@ -0,0 +1,21 @@
package utils
import (
"errors"
"strings"
"cloud.o-forge.io/core/oc-lib/tools"
)
func ExtractMethod(relation string, internal bool) (tools.METHOD, error) {
meths := []tools.METHOD{tools.GET, tools.PUT, tools.POST, tools.DELETE}
if internal {
meths = append(meths, []tools.METHOD{tools.STRICT_INTERNAL_GET, tools.STRICT_INTERNAL_POST, tools.STRICT_INTERNAL_POST, tools.STRICT_INTERNAL_DELETE}...)
}
for _, method := range meths {
if (!internal && strings.Contains(strings.ToUpper(relation), strings.ToUpper(method.String()))) || (internal && strings.ToUpper(relation) == strings.ToUpper(method.String())) {
return method, nil
}
}
return tools.GET, errors.New("method not found")
}