Class: RbSSO::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/rbsso/server.rb

Instance Method Summary collapse

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_options = {})
  auth = RbSSO::Authentication.new auth_options
  ticket = RbSSO::Ticket.sign auth, key
  return ticket.to_base64
end

#verify_keyObject



30
31
32
# File 'lib/rbsso/server.rb', line 30

def verify_key
  key.verify_key.to_s.unpack('H*').first
end