class RbSSO::Authentication

Constants

VERSION

Attributes

domain[R]
expires[R]
groups[R]
nonce[R]
service[R]
user[R]

Public Class Methods

check_version(version) click to toggle source
# File lib/rbsso/authentication.rb, line 55
def self.check_version(version)
  return if version.to_s == VERSION.to_s
  raise VersionMismatch.new(version)
end
new(user:, service:, domain:, groups: [], nonce: nil, ttl: 3600, expires: nil) click to toggle source
# File lib/rbsso/authentication.rb, line 13
def initialize(user:, service:, domain:, groups: [], nonce: nil, ttl: 3600, expires: nil)
  @user, @service, @domain, @groups = user, service, domain, groups
  @nonce = nonce
  @expires = expires || (Time.now + ttl).to_i
end
parse(string) click to toggle source
# File lib/rbsso/authentication.rb, line 19
def self.parse(string)
  version, user, service, domain, expires, nonce, groups = string.split '|'
  check_version(version)
  new user: user,
    service: service,
    domain: domain,
    expires: expires.to_i,
    nonce: nonce,
    groups: (groups || '').split(',')
end

Public Instance Methods

==(other) click to toggle source
# File lib/rbsso/authentication.rb, line 42
def ==(other)
  user == other.user &&
    service == other.service &&
    domain == other.domain &&
    groups == other.groups &&
    expires == other.expires &&
    nonce == other.nonce
end
content() click to toggle source
# File lib/rbsso/authentication.rb, line 38
def content
  [VERSION, user, service, domain, expires.to_s, nonce, groups.join(',')]
end
expired?() click to toggle source
# File lib/rbsso/authentication.rb, line 51
def expired?
  self.expires < Time.now.to_i
end
to_info() click to toggle source
# File lib/rbsso/authentication.rb, line 34
def to_info
  { name: user, email: user + '@' + domain }
end
to_s() click to toggle source
# File lib/rbsso/authentication.rb, line 30
def to_s
  content.join '|'
end