View Source Permify
Permify is an Elixir client for the project permify.
installation
Installation
def deps do
[
{:permify, "~> 0.1.0"}
]
end
usage
Usage
create-a-new-client
Create a new client
client = Permify.Client.new("http://localhost:3476/v1")
create-a-schema
Create a schema
schema = """
entity user {}
entity organization {
relation admin @user
relation member @user
action view_files = admin or member
action edit_files = admin
}
"""
{:ok, schema_version} = Permify.Schema.write(client, schema)
create-some-relationships
Create some relationships
relationship = %{
entity: %{id: "1", type: "organization"},
relation: "member",
subject: %{id: "1", type: "user"},
schema_version: schema_version
}
Permify.Relationship.write(client, relationship)
check-permissions
Check permissions
{:ok, %{"can" => can}} = Permify.Permission.check?(client, %{
action: "edit_files",
depth: 0,
entity: %{type: "organization", id: "1"},
subject: %{id: "1", type: "user"}
})
IO.inspect(can, label: "Is authorized")