abstract class Dwarf::Strategies::Base

Included Modules

Defined in:

dwarf/services/amber.cr
dwarf/services/common.cr
dwarf/services/kemal.cr
dwarf/strategies/base.cr

Constructors

Instance Method Summary

Instance methods inherited from module Dwarf::Mixins

files files, params : HTTP::Params params, request request

Constructor Detail

def self.new(scope : String | Nil = nil) #

[View source]

Instance Method Detail

abstract def authenticate!(scope : String | Nil = nil, strategy : String | Nil = nil) #

[View source]
def clear! #

Marks this strategy as not performed.


[View source]
def context : HTTP::Server::Context #

def context=(context : HTTP::Server::Context) #

[View source]
def context? : HTTP::Server::Context | Nil #

def custom!(body : String, status_code : Int32 = 200, headers = HTTP::Headers.new) #

[View source]
def custom_response : Response #

def custom_response=(custom_response : Response) #

[View source]
def custom_response? : Response | Nil #

def fail(message : Nil | String = "Failed to Login", halted : Bool = false) #

Causes the strategy to fail, but not halt. The strategies will cascade after this failure and warden will check the next strategy. The last strategy to fail will have it's message displayed.


[View source]
def fail!(message = "Failed to Login") #

This causes the strategy to fail. It does not raise Dwarf::Error to drop the request out to the failure application You must throw an :warden symbol somewhere in the application to enforce this Halts the strategies so that this is the last strategy checked


[View source]
def halt! #

Cause the processing of the strategies to stop and cascade no further


[View source]
def halted? #

Checks to see if a strategy was halted


[View source]
def headers(header = HTTP::Headers.new) #

[View source]
def message : String | Nil #

[View source]
def message=(message : String | Nil) #

[View source]
def params #

[View source]
def pass #

A simple method to return from authenticate! if you want to ignore this strategy


[View source]
def performed? : Bool #

Returns if this strategy was already performed.


[View source]
def redirect!(url, message : String | Nil = nil, content_type = "text/plain", permanent = true) #

Causes the authentication to redirect. An Dwarf::Error must be thrown to actually execute this redirect


[View source]
def request(*args, **options) #

[View source]
def request(*args, **options, &) #

[View source]
def result : Result #

[View source]
def result=(result : Result) #

[View source]
def success!(user : JSON::Any, message : String | Nil = nil) #

Whenever you want to provide a user object as "authenticated" use the #success! method. This will halt the strategy, and set the user in the appropriate scope. It is the "login" method


[View source]
def successful? #

Returns true only if the result is a success and a user was assigned.


[View source]
def user : JSON::Any #

def user=(user : JSON::Any) #

[View source]
def user? : JSON::Any | Nil #

abstract def valid? : String | Nil | Bool #

[View source]