Class: Kennedy::Granter
- Inherits:
-
Object
- Object
- Kennedy::Granter
- Defined in:
- lib/kennedy/granter.rb
Overview
Granter is used to authenticate credentials and grant tickets to services once a client has been authenticated.
Instance Method Summary collapse
-
#authenticate(args = {}) ⇒ true, false
Authenticates the given credentials against the current backend.
-
#generate_ticket(args = {}) ⇒ Kennedy::Ticket
Generates a ticket object to pass back to clients requesting authentication.
-
#initialize(args = {}) ⇒ Granter
constructor
A new instance of Granter.
- #read_ticket(args = {}) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Granter
Returns a new instance of Granter.
12 13 14 15 16 |
# File 'lib/kennedy/granter.rb', line 12 def initialize(args = {}) @iv = args[:iv] || raise(ArgumentError, "Encryption IV must be given as :iv") @passphrase = args[:passphrase] || raise(ArgumentError, "Encryption passphrase must be given as :passphrase") @backend = args[:backend] || raise(ArgumentError, "Authentication backend must be given as :backend") end |
Instance Method Details
#authenticate(args = {}) ⇒ true, false
Authenticates the given credentials against the current backend
23 24 25 |
# File 'lib/kennedy/granter.rb', line 23 def authenticate(args = {}) !!@backend.authenticate(args[:identifier], args[:password]) end |
#generate_ticket(args = {}) ⇒ Kennedy::Ticket
Generates a ticket object to pass back to clients requesting authentication
31 32 33 34 |
# File 'lib/kennedy/granter.rb', line 31 def generate_ticket(args = {}) identifier = args[:identifier] || raise(ArgumentError, "An identifier must be given as :identifier") new_ticket(identifier) end |
#read_ticket(args = {}) ⇒ Object
36 37 38 39 |
# File 'lib/kennedy/granter.rb', line 36 def read_ticket(args = {}) data = args[:data] || raise(ArgumentError, "Data must be given as :data") decrypt_ticket(args[:data]) end |