Class: Kennedy::Granter
- Inherits:
- Object
- Defined in:
- lib/kennedy/granter.rb
Overview
Granter is used to authenticate credentials and grant tickets to services once a client has been authenticated.
Method Summary
- - (true) authenticate(args = {}) Authenticates the given credentials against the current backend.
- - (Kennedy::Ticket) generate_ticket(args = {}) Generates a ticket object to pass back to clients requesting authentication.
- - (Granter) initialize(args = {}) A new instance of Granter.
- - (Object) read_ticket(args = {})
Constructor Details
- (Granter) initialize(args = {})
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 |
Method Details
- (true) authenticate(args = {})
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 |
- (Kennedy::Ticket) generate_ticket(args = {})
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 |
- (Object) read_ticket(args = {})
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 |