carny v2.0.0 Carny.Policy
Policies are lists of statements that you can validate an identifier against.
Link to this section Summary
Functions
Adds a statement to a given policy
Does the id pass a specific policy? The use case here is we have already looked up a policy for our given resource and want to make sure that it has access to some other resource (id).
Link to this section Functions
Link to this function
add_statement(policy, statement)
Adds a statement to a given policy
Examples
iex> Carny.Policy.add_statement(%Carny.Policy{statements: [%Carny.Statement{effect: :deny}]}, %Carny.Statement{})
%Carny.Policy{statements: [%Carny.Statement{}, %Carny.Statement{effect: :deny}]}
Link to this function
authorized?(privilege, id, policy)
Does the id pass a specific policy? The use case here is we have already looked up a policy for our given resource and want to make sure that it has access to some other resource (id).
Examples
iex> Carny.Policy.authorized?("start", %Carny.Identifier{}, %Carny.Policy{statements: [%Carny.Statement{privileges: ["start"], resources: [%Carny.Identifier{}]}]})
true