class
Orion::Middleware::SessionAuth
- Orion::Middleware::SessionAuth
- Orion::Middleware::Auth
- Reference
- Object
Overview
Session-based authentication Checks for user_id in session
Usage: use Orion::Middleware::SessionAuth.new( session_key: :user_id, redirect_to: "/login" # optional redirect instead of 401 )
Defined in:
orion/middleware/auth.crConstructors
Class Method Summary
-
.login(context : Orion::Server::Context, user_id : String | Int, key : String | Symbol = :user_id)
Helper to set authenticated user
-
.logout(context : Orion::Server::Context, key : String | Symbol = :user_id)
Helper to logout
-
.user_id(context : Orion::Server::Context, key : String | Symbol = :user_id) : String | Nil
Helper to get authenticated user ID
Instance Method Summary
-
#authenticate(context : Orion::Server::Context) : Bool
Override this to implement authentication logic
- #redirect_to : String | Nil
- #redirect_to=(redirect_to : String | Nil)
- #session_key : String | Symbol
- #session_key=(session_key : String | Symbol)
-
#unauthorized_response(context : Orion::Server::Context)
Override to customize unauthorized response
Instance methods inherited from class Orion::Middleware::Auth
authenticate(context : Orion::Server::Context) : Bool
authenticate,
call(context : HTTP::Server::Context)
call,
unauthorized_response(context : Orion::Server::Context)
unauthorized_response
Constructor Detail
Class Method Detail
def self.login(context : Orion::Server::Context, user_id : String | Int, key : String | Symbol = :user_id)
#
Helper to set authenticated user
Helper to logout
def self.user_id(context : Orion::Server::Context, key : String | Symbol = :user_id) : String | Nil
#
Helper to get authenticated user ID
Instance Method Detail
def authenticate(context : Orion::Server::Context) : Bool
#
Description copied from class Orion::Middleware::Auth
Override this to implement authentication logic
def unauthorized_response(context : Orion::Server::Context)
#
Description copied from class Orion::Middleware::Auth
Override to customize unauthorized response