Skip to content

module Athena::Security::Authentication::Token::Interface #

Represents the authentication of a user, such as the user itself, its roles, and the firewall it authenticated on.

Tokens may hold attributes, e.g. the scopes of an access token. Each value is stored as JSON, so any type that can be serialized via #to_json and deserialized via .from_json can be stored.

Direct including types

Athena::Security::Authentication::Token::AbstractToken Athena::Security::Authentication::Token::Null

Methods#

abstract #attribute(name : String, type : T.class) forall T#

Returns the value of the attribute with the provided name, deserialized as the provided type.

Raises an ASEC::Exception::InvalidArgument if this token has no attribute with that name.

View source

abstract #attribute?(name : String, type : T.class) forall T#

Returns the value of the attribute with the provided name, deserialized as the provided type, or nil if this token has no attribute with that name.

View source

abstract #attributes : Hash(String, String)#

Returns the attributes of this token, with their values serialized as JSON.

View source

abstract #attributes=(attributes : Hash(String, String))#

Replaces the attributes of this token with the provided attributes, whose values are serialized as JSON.

View source

abstract #has_attribute?(name : String) : Bool#

Returns true if this token has an attribute with the provided name, otherwise false.

View source

abstract #role_names : Array(String)#

Returns the roles granted to the user by this token.

View source

abstract #set_attribute(name : String, value : _) : Nil#

Sets the attribute with the provided name to the provided value.

View source

abstract #to_s(io : IO) : Nil#

Writes a representation of this token to the provided io, for debugging purposes.

View source

abstract #user : ASEC::User::Interface | ::Nil#

Returns the authenticated user, if any.

View source

abstract #user=(user : ASEC::User::Interface)#

Sets the authenticated user.

View source

abstract #user_identifier : String#

Returns the identifier of the user, e.g. its username or email address, or an empty string if there is no user.

View source