Sha256: ce421935c274c60eed46282fb5d6de1cc94f5af764c343bfb370d4ca8e4e784c
Contents?: true
Size: 1.41 KB
Versions: 11
Compression:
Stored size: 1.41 KB
Contents
module Warden module Github module Oauth class Proxy attr_accessor :client_id, :secret, :scopes, :oauth_domain, :callback_url def initialize(client_id, secret, scopes, oauth_domain, callback_url) @client_id, @secret, @scopes, @oauth_domain, @callback_url = client_id, secret, scopes, oauth_domain, callback_url end def ssl_options ca_file = "/usr/lib/ssl/certs/ca-certificates.crt" if File.exists?(ca_file) { :ca_file => ca_file } else { :ca_file => ''} end end def client @client ||= OAuth2::Client.new(@client_id, @secret, :ssl => ssl_options, :site => oauth_domain, :token_url => '/login/oauth/access_token', :authorize_url => '/login/oauth/authorize') end def api_for(code) client.auth_code.get_token(code, :redirect_uri => callback_url) end def state @state ||= Digest::SHA1.hexdigest(rand(36**8).to_s(36)) end def authorize_url client.auth_code.authorize_url( :state => state, :scope => scopes, :redirect_uri => callback_url ) end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems