Class: HaveAPI::Fs::Auth::Base
- Inherits:
-
Object
- Object
- HaveAPI::Fs::Auth::Base
- Defined in:
- lib/haveapi/fs/auth/base.rb
Overview
Base class for all authentication methods.
Class Method Summary collapse
- .method_name ⇒ Object
-
.register(name) ⇒ Object
All authentication providers must register using this method.
-
.use?(opts) ⇒ Boolean
Check if this authentication provider should be used based on
opts
.
Instance Method Summary collapse
-
#authenticate(client) ⇒ Object
Authenticate the
client
object. -
#check(client) ⇒ Object
Check whether the authentication works by running some real API request.
-
#initialize(cfg, opts) ⇒ Base
constructor
A new instance of Base.
- #name ⇒ Object
-
#setup ⇒ Object
Called right after #initialize.
-
#validate ⇒ Object
In this method, the provider should check if it has all needed information.
Constructor Details
#initialize(cfg, opts) ⇒ Base
Returns a new instance of Base.
23 24 25 26 27 28 |
# File 'lib/haveapi/fs/auth/base.rb', line 23 def initialize(cfg, opts) @cfg = cfg @opts = opts setup end |
Class Method Details
.method_name ⇒ Object
4 5 6 |
# File 'lib/haveapi/fs/auth/base.rb', line 4 def self.method_name @method_name end |
.register(name) ⇒ Object
All authentication providers must register using this method.
10 11 12 13 |
# File 'lib/haveapi/fs/auth/base.rb', line 10 def self.register(name) HaveAPI::Fs.register_auth(name, self) @method_name = name end |
.use?(opts) ⇒ Boolean
Check if this authentication provider should be used based on opts
.
17 18 19 |
# File 'lib/haveapi/fs/auth/base.rb', line 17 def self.use?(opts) false end |
Instance Method Details
#authenticate(client) ⇒ Object
Authenticate the client
object
47 48 49 |
# File 'lib/haveapi/fs/auth/base.rb', line 47 def authenticate(client) end |
#check(client) ⇒ Object
Check whether the authentication works by running some real API request.
52 53 54 |
# File 'lib/haveapi/fs/auth/base.rb', line 52 def check(client) client.user.current end |
#name ⇒ Object
35 36 37 |
# File 'lib/haveapi/fs/auth/base.rb', line 35 def name self.class.method_name end |
#setup ⇒ Object
Called right after #initialize.
31 32 33 |
# File 'lib/haveapi/fs/auth/base.rb', line 31 def setup end |
#validate ⇒ Object
In this method, the provider should check if it has all needed information. Missing pieces can be queried from the user on stdin.
41 42 43 |
# File 'lib/haveapi/fs/auth/base.rb', line 41 def validate end |