Module: Swiftype::SSO

Defined in:
lib/swiftype/sso.rb

Overview

Single sign-on for the Swiftype Dashboard.

Constant Summary

BASE_URL =
'https://swiftype.com/sso'

Class Method Summary collapse

Class Method Details

.token(user_id, timestamp) ⇒ Object



16
17
18
# File 'lib/swiftype/sso.rb', line 16

def self.token(user_id, timestamp)
  Digest::SHA1.hexdigest("#{user_id}:#{Swiftype.platform_client_secret}:#{timestamp}")
end

.url(user_id) ⇒ Object

Generate a URL that a user can click on to be logged into the Swiftype Dashboard. This requires the platform_client_id and platform_client_secret configuration options be set.



10
11
12
13
14
# File 'lib/swiftype/sso.rb', line 10

def self.url(user_id)
  timestamp = Time.now.to_i

  "#{BASE_URL}?user_id=#{user_id}&client_id=#{Swiftype.platform_client_id}&timestamp=#{timestamp}&token=#{token(user_id, timestamp)}"
end