Skip to content

Commit

Permalink
updated the get super org id function
Browse files Browse the repository at this point in the history
  • Loading branch information
vsumit89 committed Sep 14, 2022
1 parent a813ebd commit 34033c1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion middlewarex/superOrganisation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"net/http"
"net/url"
"strconv"
"strings"

Expand Down Expand Up @@ -64,7 +65,20 @@ func CheckSuperOrganisation(app string, GetOrganisation func(ctx context.Context

// GetSuperOrganisationID get superorganisation id from keto policy
func GetSuperOrganisationID(app string) (int, error) {
req, err := http.NewRequest("GET", viper.GetString("keto_url")+"/relation-tuples?namespace=superorganisation", nil)
requestURL, err := url.Parse(viper.GetString("keto_read_api_url"))
if err != nil {
return 0, err
}

requestURL.Path += "relation-tuples"

// add Query Parameters
params := url.Values{}
params.Add("namespace", "superorganisation")
params.Add("subject_id", app)
requestURL.RawQuery = params.Encode()

req, err := http.NewRequest("GET", requestURL.String(), nil)
if err != nil {
return 0, err
}
Expand Down

0 comments on commit 34033c1

Please sign in to comment.