Oc Auth x Hydra x LDAP : draft of claims enrich for traefik + draft of forwarding
This commit is contained in:
21
infrastructure/utils/utils.go
Normal file
21
infrastructure/utils/utils.go
Normal 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")
|
||||
}
|
||||
Reference in New Issue
Block a user