class RbSSO::Client

Attributes

service[R]
verify_key[R]

Public Class Methods

new(service, key) click to toggle source
# File lib/rbsso/client.rb, line 25
def initialize(service, key)
  if !key || key !~ /[0-9a-f]{64}/i
    raise ArgumentError, "key MUST be 32 bytes, hex encoded string, was: #{key}"
  end
  @service = service
  key = RbNaCl::VerifyKey.new [key].pack('H*')
  @verify_key = key
end

Public Instance Methods

open(ticket_string, nonce: nil) click to toggle source
# File lib/rbsso/client.rb, line 34
def open(ticket_string, nonce: nil)
  ticket = RbSSO::Ticket.open ticket_string, verify_key
  auth = RbSSO::Authentication.parse ticket.content
  raise TicketExpired.new(auth.expires) if auth.expired?
  raise WrongService.new(service, auth.service) if auth.service != service
  raise NonceMismatch.new(nonce, auth.nonce) if auth.nonce != nonce
  auth.to_info
end