Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
basic code for using Ladon; taken + merged from readme: https://github.com/ory/ladon
package main
import (
"log"
"github.com/ory/ladon"
manager "github.com/ory/ladon/manager/memory"
)
func main() {
warden := &ladon.Ladon{
Manager: manager.NewMemoryManager(),
}
var pol = &ladon.DefaultPolicy{}
_ = warden.Manager.Create(pol)
err := warden.IsAllowed(&ladon.Request{
Subject: "peter",
Action: "delete",
Resource: "myrn:some.domain.com:resource:123",
Context: ladon.Context{
"ip": "127.0.0.1",
},
})
if err != nil {
log.Fatal("Access denied")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment