Class: RbSSO::Server
- Inherits:
-
Object
- Object
- RbSSO::Server
- Defined in:
- lib/rbsso/server.rb
Instance Method Summary collapse
-
#initialize(secret) ⇒ Server
constructor
A new instance of Server.
-
#ticket(auth_options = {}) ⇒ Object
Create a ticket based on the authentication options.
- #verify_key ⇒ Object
Constructor Details
#initialize(secret) ⇒ Server
Returns a new instance of Server.
8 9 10 11 12 13 14 |
# File 'lib/rbsso/server.rb', line 8 def initialize(secret) if !secret || secret !~ /[0-9a-f]{64}/i raise ArgumentError, "seed MUST be 32 bytes, hex encoded string" end seed_binary = [secret].pack('H*') @key = RbNaCl::SigningKey.new seed_binary end |
Instance Method Details
#ticket(auth_options = {}) ⇒ Object
Create a ticket based on the authentication options.
minimal example:
sso_server.ticket user: username, service: service, domain: domain
Other options:
nonce: nonce identifying the client session. Send to server in params.
ttl: time to live - number of seconds until the ticket expires.
24 25 26 27 28 |
# File 'lib/rbsso/server.rb', line 24 def ticket( = {}) auth = RbSSO::Authentication.new ticket = RbSSO::Ticket.sign auth, key return ticket.to_base64 end |
#verify_key ⇒ Object
30 31 32 |
# File 'lib/rbsso/server.rb', line 30 def verify_key key.verify_key.to_s.unpack('H*').first end |