Class: Warden::Oauthed::Oauth::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/warden-oauthed/proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id, secret, scopes, oauth_domain, callback_url) ⇒ Proxy

Returns a new instance of Proxy.



6
7
8
9
10
11
12
# File 'lib/warden-oauthed/proxy.rb', line 6

def initialize(client_id, secret, scopes, oauth_domain, callback_url)
  @client_id = client_id
  @secret = secret
  @scopes = scopes
  @oauth_domain = oauth_domain
  @callback_url = callback_url
end

Instance Attribute Details

#callback_urlObject

Returns the value of attribute callback_url.



5
6
7
# File 'lib/warden-oauthed/proxy.rb', line 5

def callback_url
  @callback_url
end

#client_idObject

Returns the value of attribute client_id.



5
6
7
# File 'lib/warden-oauthed/proxy.rb', line 5

def client_id
  @client_id
end

#oauth_domainObject

Returns the value of attribute oauth_domain.



5
6
7
# File 'lib/warden-oauthed/proxy.rb', line 5

def oauth_domain
  @oauth_domain
end

#scopesObject

Returns the value of attribute scopes.



5
6
7
# File 'lib/warden-oauthed/proxy.rb', line 5

def scopes
  @scopes
end

#secretObject

Returns the value of attribute secret.



5
6
7
# File 'lib/warden-oauthed/proxy.rb', line 5

def secret
  @secret
end

Instance Method Details

#api_for(code) ⇒ Object



27
28
29
30
31
32
# File 'lib/warden-oauthed/proxy.rb', line 27

def api_for(code)
  client.auth_code.get_token(
    code,
    redirect_uri: callback_url
  )
end

#authorize_urlObject



34
35
36
37
38
39
# File 'lib/warden-oauthed/proxy.rb', line 34

def authorize_url
  client.auth_code.authorize_url(
    scope:        scopes,
    redirect_uri: callback_url
  )
end

#clientObject



18
19
20
21
22
23
24
25
# File 'lib/warden-oauthed/proxy.rb', line 18

def client
  @client ||= OAuth2::Client.new(
    @client_id,
    @secret,
    ssl: ssl_options,
    site: oauth_domain,
    authorize_url: '/oauth/authorize')
end

#ssl_optionsObject



14
15
16
# File 'lib/warden-oauthed/proxy.rb', line 14

def ssl_options
  { version: :TLSv1 }
end