Cedarling Interfaces#
Cedarling provides a number of methods to interface with the Cedar engine. These are described below.
Init#
These methods are used to create a BootstrapConfig object, which is needed to initialize a Cedarling instance. Bootstrap properties are required to do this.
-
load_from_file(path)Creates a
BootstrapConfigobject by loading properties from a file -
load_from_json(config_json)Creates a
BootstrapConfigobject by reading in a string encoded JSON object containing properties. -
from_env(options)Creates a
BootstrapConfigobject by reading environment variables. If a dictionary is passed in, it will override environment variables. -
Cedarling(bootstrap_config)Initializes an instance of the Cedarling engine by reading the bootstrap configuration.
Authz#
These methods are called to create an authorization request, run authorization, and get decisions back.
-
Entity(entity_type, id, payload)Creates a
Principalor aResourceentity.-
from_dict(value)Creates a
Principalor aResourceentity from a dictionary.
-
-
Request(tokens, action, resource, context)Creates a
Requestobject which contains inputs for the Cedarling's authorization call. -
RequestUnsigned(principals, action, resource, context)Creates a
RequestUnsignedobject which contains inputs for Cedarling's unsigned authorization call. -
authorize(request)Runs authorization against the provided
Requestobject. -
authorize_unsigned(request)Runs unsigned authorization against the provided
RequestUnsignedobject. A trusted issuer is not required for this call.
Authz Result#
The following methods are called on the result obtained from the authorization call to view and analyze results, reasons and possible errors.
-
is_allowed()Returns
trueonly if the overall decision of the Cedarling istrue. -
workload()Returns the decision of the
Workloadauthorization -
principal()Returns the decision of the
Principalauthorization -
request_id()Returns the request ID of this authorization call. This is used to retrieve logs if the Cedarling is running in memory log mode.
-
decisionThis field represents the decision of this authorization call (allow/deny)
-
diagnosticsThis field contains additional information regarding the decision reached by Cedarling.
reason
This field is a set of policy IDs used to reach an
allowdecision, if they existerrors
This field contains a list of errors during authorization, if they exist.
Logs#
These methods are called to retrieve logs from the memory of the Cedarling instance when it is running in memory mode.
-
pop_logs()Removes and returns the latest log from the memory of the Cedarling instance
-
get_log_by_id(id)Retrieves a log given the ID of an active log entry.
-
get_log_ids()Returns the list of all active log entries in Cedarling's memory.
-
get_logs_by_tag(tag)Returns the list of all logs with a given tag. A tag can be either the type of log (System, Decision, Metric) or the log level
-
get_logs_by_request_id(request_id)Returns the list of all logs with a given request ID. This request ID is obtained from an authorization result.
-
get_logs_by_request_id_and_tag(request_id, tag)Returns the list of all logs with a given request ID and tag.