Skip to content

Athena::Security::Bundle::Schema#

Represents the possible properties used to configure and customize the security integration. See the Getting Started docs for more information on how the bundle system works in Athena.

Configuration Properties

password_hashers#

type:

Hash(K, V)

default:

{__nil: nil}

The password hashers of each type of user, keyed by the type, or by the name an APH::PasswordHasherAwareInterface user returns. A hasher may also be configured by its algorithm alone, e.g. ASEC::User::InMemory => :auto.

password_hashers: {
  User                 => {algorithm: :auto, cost: 12},
  ASEC::User::InMemory => :auto,
  "legacy"             => {id: "legacy_password_hasher"},
}

This property consists of a map of key/value pairs where each value has the following properties:

algorithm#

type:

Symbol

default:

auto

The algorithm hashing the passwords: :auto, :bcrypt, or :native, which all use bcrypt via APH::Native.


cost#

type:

Int32 | ::Nil

default:

nil

The cost of the bcrypt algorithm, in the range of APH::Native::COST_RANGE. Defaults to the default cost of APH::Native.


migrate_from#

type:

Array(String)

default:

[] of String

The names of other password hashers, or algorithms, whose hashed passwords are still verified, and upgraded once their user logs in, see APH::Migrating.


id#

type:

String | ::Nil

default:

nil

The ID of a service including APH::Interface to use instead.


providers#

type:

Hash(K, V)

default:

{__nil: nil}

The user providers, keyed by their name, each configured via exactly one of id, memory, or chain.

This property consists of a map of key/value pairs where each value has the following properties:

id#

type:

String | ::Nil

default:

nil

The ID of a service including ASEC::User::Provider::Interface.


memory#

type:

Memory

default:

{users: nil}

Provides the users kept in memory, see Memory.

This property consists of an object with the following properties:

users#
type:

Hash(String, NamedTuple(password: String | ::Nil, roles: Array(String))) | ::Nil

default:

nil

The users, keyed by their identifier, each with its hashed password and its roles.


chain#

type:

Chain

default:

{providers: nil}

Provides the users of other providers, see Chain.

This property consists of an object with the following properties:

providers#
type:

Array(String) | ::Nil

default:

nil

The names of the providers.


firewalls#

type:

Hash(K, V)

default:

{__nil: nil}

The firewalls, keyed by their name. A request belongs to the first firewall matching it, while a firewall without pattern, host, or request_matcher matches every request.

This property consists of a map of key/value pairs where each value has the following properties:

pattern#

type:

Regex | ::Nil

default:

nil

Matches the requests whose path matches this regex.


host#

type:

Regex | ::Nil

default:

nil

Matches the requests whose host matches this regex.


methods#

type:

Array(String)

default:

[] of String

Only matches the requests using one of these methods, along with pattern or host.


request_matcher#

type:

String | ::Nil

default:

nil

The ID of a service including AHTTP::RequestMatcher::Interface matching the requests, instead of pattern, host, and methods.


security#

type:

Bool

default:

true

Whether security is enabled on the firewall, otherwise its requests are neither authenticated nor checked by access_control rules.


provider#

type:

String | ::Nil

default:

nil

The name of the user provider loading the users being authenticated, which defaults to the only configured provider.


user_checker#

type:

String | ::Nil

default:

nil

The ID of a service including ASEC::User::Checker::Interface checking the account of the users being authenticated. Defaults to an ASEC::User::Checker::InMemory.


entry_point#

type:

String | ::Nil

default:

nil

The ID of a service including ASEC::EntryPoint::Interface starting the authentication of users who must authenticate, which defaults to the only custom authenticator that includes it. Without one, these users get a 401 response.


custom_authenticators#

type:

Array(String)

default:

[] of String

The IDs of the services including ASEC::Authenticator::Interface authenticating the requests.


access_control#

type:

Array(T)

default:

[]

The rules requiring an attribute for the requests of firewalls, e.g. a role. A request requires the attribute of the first rule matching it, while a rule without path, host, methods, or request_matcher matches every request.

access_control: [
  {path: /^\/admin\/login/, role: "PUBLIC_ACCESS"},
  {path: /^\/admin/, role: "ROLE_ADMIN"},
]

This property consists of an array of objects with the following properties:

path#

type:

Regex | ::Nil

default:

nil

Matches the requests whose path matches this regex.


host#

type:

Regex | ::Nil

default:

nil

Matches the requests whose host matches this regex.


methods#

type:

Array(String)

default:

[] of String

Only matches the requests using one of these methods.


request_matcher#

type:

String | ::Nil

default:

nil

The ID of a service including `AHTTP


role#

type:

String | ::Nil

default:

nil

The attribute the requests require, or nil to require nothing, e.g. to exclude them from a later rule.


role_hierarchy#

type:

Hash(String, Array(String))

default:

{} of String => Array(String)

The roles granted by other roles, see ASEC::Role::Hierarchy.

role_hierarchy: {
  "ROLE_ADMIN"       => ["ROLE_USER"],
  "ROLE_SUPER_ADMIN" => ["ROLE_ADMIN"],
}

expose_security_errors#

default:

none

Determines which authentication errors are shown to users, see ASEC::Authentication::ExposeSecurityLevel.