Class: HaveAPI::Authentication::Base
- Inherits:
-
Object
- Object
- HaveAPI::Authentication::Base
- Defined in:
- lib/haveapi/authentication/base.rb
Overview
Base class for authentication providers.
Direct Known Subclasses
HaveAPI::Authentication::Basic::Provider, OAuth2::Provider, Token::Provider
Instance Attribute Summary collapse
- #name ⇒ Symbol readonly
Class Method Summary collapse
-
.auth_method(v = nil) ⇒ Symbol
Get or set auth method name.
- .inherited(subclass) ⇒ Object
Instance Method Summary collapse
-
#authenticate(request) ⇒ Object
Reimplement this method in your authentication provider.
-
#describe ⇒ Object
Reimplement to describe provider.
-
#initialize(server, v) ⇒ Base
constructor
A new instance of Base.
-
#register_routes(sinatra, prefix) ⇒ Object
Register custom path handlers in sinatra.
- #resource_module ⇒ Module?
Constructor Details
#initialize(server, v) ⇒ Base
Returns a new instance of Base.
26 27 28 29 30 31 |
# File 'lib/haveapi/authentication/base.rb', line 26 def initialize(server, v) @name = self.class.auth_method @server = server @version = v setup end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
24 25 26 |
# File 'lib/haveapi/authentication/base.rb', line 24 def name @name end |
Class Method Details
.auth_method(v = nil) ⇒ Symbol
Get or set auth method name
10 11 12 13 14 15 16 |
# File 'lib/haveapi/authentication/base.rb', line 10 def self.auth_method(v = nil) if v @auth_method = v else @auth_method || name.split('::').last.underscore.to_sym end end |
.inherited(subclass) ⇒ Object
18 19 20 21 |
# File 'lib/haveapi/authentication/base.rb', line 18 def self.inherited(subclass) super subclass.send(:instance_variable_set, '@auth_method', @auth_method) end |
Instance Method Details
#authenticate(request) ⇒ Object
Reimplement this method in your authentication provider. request is passed directly from Sinatra.
45 |
# File 'lib/haveapi/authentication/base.rb', line 45 def authenticate(request); end |
#describe ⇒ Object
Reimplement to describe provider.
48 49 50 |
# File 'lib/haveapi/authentication/base.rb', line 48 def describe {} end |
#register_routes(sinatra, prefix) ⇒ Object
Register custom path handlers in sinatra
36 |
# File 'lib/haveapi/authentication/base.rb', line 36 def register_routes(sinatra, prefix); end |
#resource_module ⇒ Module?
39 40 41 |
# File 'lib/haveapi/authentication/base.rb', line 39 def resource_module nil end |