class HaveAPI::Authentication::Base
Base
class for authentication providers.
Attributes
@return [Symbol]
Public Class Methods
Source
# File lib/haveapi/authentication/base.rb, line 8 def self.auth_method(v = nil) if v @auth_method = v else @auth_method || name.split('::').last.underscore.to_sym end end
Get or set auth method name @param v [Symbol, nil] @return [Symbol]
Source
# File lib/haveapi/authentication/base.rb, line 16 def self.inherited(subclass) super subclass.send(:instance_variable_set, '@auth_method', @auth_method) end
Calls superclass method
Source
# File lib/haveapi/authentication/base.rb, line 24 def initialize(server, v) @name = self.class.auth_method @server = server @version = v setup end
Public Instance Methods
Source
# File lib/haveapi/authentication/base.rb, line 43 def authenticate(request); end
Reimplement this method in your authentication provider. ‘request` is passed directly from Sinatra.
Source
# File lib/haveapi/authentication/base.rb, line 46 def describe {} end
Reimplement to describe provider.
Source
# File lib/haveapi/authentication/base.rb, line 34 def register_routes(sinatra, prefix); end
Register custom path handlers in sinatra @param sinatra [Sinatra::Base] @param prefix [String]
Source
# File lib/haveapi/authentication/base.rb, line 37 def resource_module nil end
@return [Module, nil]
Protected Instance Methods
Source
# File lib/haveapi/authentication/base.rb, line 57 def deny throw(:return) end
Immediately return from authentication chain. User is not allowed to authenticate.
Source
# File lib/haveapi/authentication/base.rb, line 53 def setup; end
Called during API mount.