class
Orion::Middleware::JWTAuth
- Orion::Middleware::JWTAuth
- Orion::Middleware::Auth
- Reference
- Object
Overview
JWT Token authentication Validates Bearer tokens in Authorization header
Usage: use Orion::Middleware::JWTAuth.new( secret: ENV["JWT_SECRET"], algorithm: :HS256 )
Defined in:
orion/middleware/auth.crConstructors
Class Method Summary
-
.generate_token(payload : Hash(String, JSON::Any), secret : String, algorithm : Symbol = :HS256, expires_in : Time::Span = 24.hours) : String
Helper to generate JWT tokens
Instance Method Summary
- #algorithm : Symbol
- #algorithm=(algorithm : Symbol)
-
#authenticate(context : Orion::Server::Context) : Bool
Override this to implement authentication logic
- #header_name : String
- #header_name=(header_name : String)
- #secret : String
- #secret=(secret : String)
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
def self.new(secret : String, algorithm : Symbol = :HS256, header_name : String = "Authorization")
#
Class Method Detail
def self.generate_token(payload : Hash(String, JSON::Any), secret : String, algorithm : Symbol = :HS256, expires_in : Time::Span = 24.hours) : String
#
Helper to generate JWT tokens
Instance Method Detail
def authenticate(context : Orion::Server::Context) : Bool
#
Description copied from class Orion::Middleware::Auth
Override this to implement authentication logic