Sha256: 9216d0cb6a2fd2d26d45424ecbb87de03f2cd7fc5ce058641fe47e26f1eb1a59
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
class LuxOauth @@keys = {} @@local_path = 'callback' class << self # LuxOauth.register :google, ENV.fetch('GOOGLE_OAUTH_KEY'), ENV.fetch('GOOGLE_OAUTH_SECRET') def register schema, client_key=nil, client_secret=nil client_key ||= ENV["#{schema.to_s.upcase}_OAUTH_KEY"] || raise('Oauth :%s key not defined' % schema) client_secret ||= ENV["#{schema.to_s.upcase}_OAUTH_SECRET"] || raise('Oauth :%s secret not defined' % schema) @@keys[schema] = {} @@keys[schema][:key] = client_key @@keys[schema][:secret] = client_secret end def local_path= value @@local_path = value end def get scheme, full_host "LuxOauth::#{scheme.to_s.classify}".constantize.new full_host end end ### def initialize full_host schema = self.class.to_s.split('::').last.downcase raise ArgumentError, 'Host is invalid: %s' % full_host.to_s unless full_host.to_s =~ /^https?:/ @schema = schema.to_sym raise "Oauth config :#{schema} is not registred" unless @@keys[@schema] raise "Oauth config :#{schema} is missing key" unless @@keys[@schema][:key] raise "Oauth config :#{schema} is missing secret" unless @@keys[@schema][:secret] @full_host = full_host @key = @@keys[@schema][:key] @secret = @@keys[@schema][:secret] end def redirect_url [@full_host, @@local_path, @schema].join('/') end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lux-fw-0.1.35 | ./lib/vendor/oauth/oauth.rb |
lux-fw-0.1.17 | ./lib/vendor/oauth/oauth.rb |