auth
This commit is contained in:
@@ -56,7 +56,10 @@ func (f KetoConnector) permToQuery(perm Permission, permDependancies *Permission
|
||||
func (k KetoConnector) Status() tools.State {
|
||||
caller := tools.NewHTTPCaller(map[tools.DataType]map[tools.METHOD]string{})
|
||||
var responseBody map[string]interface{}
|
||||
host := conf.GetConfig().PermissionConnectorHost
|
||||
host := conf.GetConfig().PermissionConnectorReadHost
|
||||
if conf.GetConfig().Local {
|
||||
host = "localhost"
|
||||
}
|
||||
port := fmt.Sprintf("%v", conf.GetConfig().PermissionConnectorPort)
|
||||
resp, err := caller.CallGet("http://"+host+":"+port, "/health/ready")
|
||||
if err != nil {
|
||||
@@ -217,7 +220,10 @@ func (k KetoConnector) GetPermissionByUser(userID string, internal bool) ([]Perm
|
||||
func (k KetoConnector) get(object string, relation string, subject string) ([]Permission, error) {
|
||||
t := []Permission{}
|
||||
caller := tools.NewHTTPCaller(map[tools.DataType]map[tools.METHOD]string{})
|
||||
host := conf.GetConfig().PermissionConnectorHost
|
||||
host := conf.GetConfig().PermissionConnectorReadHost
|
||||
if conf.GetConfig().Local {
|
||||
host = "localhost"
|
||||
}
|
||||
port := fmt.Sprintf("%v", conf.GetConfig().PermissionConnectorPort)
|
||||
resp, err := caller.CallGet("http://"+host+":"+port, "/relation-tuples"+k.permToQuery(
|
||||
Permission{Object: object, Relation: relation, Subject: subject}, nil))
|
||||
@@ -344,7 +350,10 @@ func (k KetoConnector) createRelationShip(object string, relation string, subjec
|
||||
}
|
||||
body["subject_set"] = map[string]interface{}{"namespace": k.namespace(), "object": s.Object, "relation": s.Relation, "subject_id": s.Subject}
|
||||
}
|
||||
host := conf.GetConfig().PermissionConnectorHost
|
||||
host := conf.GetConfig().PermissionConnectorWriteHost
|
||||
if conf.GetConfig().Local {
|
||||
host = "localhost"
|
||||
}
|
||||
port := fmt.Sprintf("%v", conf.GetConfig().PermissionConnectorAdminPort)
|
||||
b, err := caller.CallPut("http://"+host+":"+port, "/relation-tuples", body)
|
||||
if err != nil {
|
||||
@@ -355,6 +364,7 @@ func (k KetoConnector) createRelationShip(object string, relation string, subjec
|
||||
var data map[string]interface{}
|
||||
err = json.Unmarshal(b, &data)
|
||||
if err != nil {
|
||||
fmt.Println(string(b), err)
|
||||
log := oclib.GetLogger()
|
||||
log.Error().Msg("createRelationShip2" + err.Error())
|
||||
return nil, 500, err
|
||||
@@ -382,7 +392,10 @@ func (k KetoConnector) deleteRelationShip(object string, relation string, subjec
|
||||
}
|
||||
caller := tools.NewHTTPCaller(map[tools.DataType]map[tools.METHOD]string{})
|
||||
n := k.permToQuery(Permission{Object: object, Relation: relation, Subject: subject}, subPerm)
|
||||
host := conf.GetConfig().PermissionConnectorHost
|
||||
host := conf.GetConfig().PermissionConnectorWriteHost
|
||||
if conf.GetConfig().Local {
|
||||
host = "localhost"
|
||||
}
|
||||
port := fmt.Sprintf("%v", conf.GetConfig().PermissionConnectorAdminPort)
|
||||
b, err := caller.CallDelete("http://"+host+":"+port, "/relation-tuples"+n)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,6 +2,7 @@ package perms_connectors
|
||||
|
||||
import (
|
||||
"oc-auth/conf"
|
||||
"strings"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
)
|
||||
@@ -55,5 +56,10 @@ var c = map[string]PermConnector{
|
||||
}
|
||||
|
||||
func GetPermissionConnector(scope string) PermConnector {
|
||||
return c[conf.GetConfig().PermissionConnectorHost]
|
||||
for k := range c {
|
||||
if strings.Contains(conf.GetConfig().PermissionConnectorReadHost, k) {
|
||||
return c[k]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user