BlogEngine.Authorizer behaviour (blog_engine v0.1.0)

Copy Markdown View Source

Validates command actors and delegates authorization to the host application.

Summary

Callbacks

Authorizes one BlogEngine action in the host application's policy layer.

Functions

Returns the canonical action catalog accepted by BlogEngine authorizers.

Returns the validated canonical actor identity for a command context.

Validates the command actor, then invokes the context-selected authorizer.

Callbacks

authorize(t, atom, arg3)

@callback authorize(BlogEngine.Context.t(), atom(), struct() | map()) ::
  :ok | {:error, :forbidden}

Authorizes one BlogEngine action in the host application's policy layer.

Functions

actions()

@spec actions() :: [atom()]

Returns the canonical action catalog accepted by BlogEngine authorizers.

actor(context)

@spec actor(BlogEngine.Context.t()) ::
  {:ok, %{type: String.t(), key: String.t()}} | {:error, BlogEngine.Error.t()}

Returns the validated canonical actor identity for a command context.

authorize(context, action, resource)

@spec authorize(BlogEngine.Context.t(), atom(), struct() | map()) ::
  :ok | {:error, BlogEngine.Error.t()}

Validates the command actor, then invokes the context-selected authorizer.