polite-traffic-4036
04/08/2024, 4:34 AM<http://github.com/ory/client-go|github.com/ory/client-go>
and will this respect the relations i created in the namespace file?
package main
import (
"context"
"fmt"
ory "<http://github.com/ory/client-go|github.com/ory/client-go>"
"os"
)
func main() {
readServerUrl := "...."
configuration := ory.NewConfiguration()
configuration.Servers = []ory.ServerConfiguration{
{
URL: readServerUrl,
},
}
readClient := ory.NewAPIClient(configuration)
check, r, err := readClient.PermissionAPI.CheckPermission(context.Background()).
Namespace("projects").
Object("PROJECT_ID").
Relation("edit").
SubjectId("USER_ID").
Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Full HTTP response (HasProjectEditPermission): %v\n", r)
panic(err)
}
if !check.Allowed {
fmt.Println("You do not have permission to edit this project")
return
}
fmt.Println("You have permission to edit this project")
}