Module: Oauthio

Defined in:
lib/oauthio.rb,
lib/oauthio/util.rb,
lib/oauthio/client.rb,
lib/oauthio/version.rb

Defined Under Namespace

Classes: Client, Util

Constant Summary collapse

LEVEL_DEBUG =

map to the same values as the standard library’s logger

Logger::DEBUG
LEVEL_ERROR =
Logger::ERROR
LEVEL_INFO =
Logger::INFO
VERSION =
"0.9.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.csrf_tokensObject

Returns the value of attribute csrf_tokens.



28
29
30
# File 'lib/oauthio.rb', line 28

def csrf_tokens
  @csrf_tokens
end

.log_levelObject

LOGGING #



59
60
61
# File 'lib/oauthio.rb', line 59

def log_level
  @log_level
end

.public_keyObject (readonly)

Returns the value of attribute public_key.



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

def public_key
  @public_key
end

.secret_keyObject (readonly)

Returns the value of attribute secret_key.



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

def secret_key
  @secret_key
end

Class Method Details

.auth_url(provider, redirect_url, csrf_token) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/oauthio.rb', line 38

def self.auth_url provider, redirect_url, csrf_token
  Util.log_debug "[oauthio] Redirect to #{@oauthd_url}#{@oauthd_base}/#{provider} with k=#{@public_key} and redirect_uri=#{redirect_url}"

  url = endpoint_url + '/' + provider + '?k=' + @public_key

  opts = {state: csrf_token}.to_json
  url += '&opts=' + URI.escape("#{opts}", Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))

  url += '&redirect_type=server&redirect_uri=' + URI.escape(redirect_url, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))

  url
end

.endpoint_urlObject



51
52
53
# File 'lib/oauthio.rb', line 51

def self.endpoint_url
  @oauthd_url + @oauthd_base
end

.loggerObject



70
71
72
# File 'lib/oauthio.rb', line 70

def self.logger
  @logger
end

.logger=(val) ⇒ Object



74
75
76
# File 'lib/oauthio.rb', line 74

def self.logger=(val)
  @logger = val
end

.set_credentials(pk, sk) ⇒ Object



33
34
35
36
# File 'lib/oauthio.rb', line 33

def self.set_credentials pk, sk
  @public_key = pk
  @secret_key = sk
end