Module: OAuth2::Provider::Models::Client

Extended by:
ActiveSupport::Concern
Defined in:
lib/oauth2/provider/models/client.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#allow_grant_type?(grant_type) ⇒ Boolean


22
23
24
# File 'lib/oauth2/provider/models/client.rb', line 22

def allow_grant_type?(grant_type)
  true
end

#allow_redirection?(uri) ⇒ Boolean


26
27
28
29
30
31
32
33
34
35
# File 'lib/oauth2/provider/models/client.rb', line 26

def allow_redirection?(uri)
  uri_host = Addressable::URI.parse(uri).host
  unless oauth_redirect_uri.nil? or oauth_redirect_uri.empty?
    Addressable::URI.parse(oauth_redirect_uri).host == uri_host
  else
    !uri_host.nil? && true
  end
rescue Addressable::URI::InvalidURIError
  false
end

#initialize(*args, &block) ⇒ Object


12
13
14
15
16
# File 'lib/oauth2/provider/models/client.rb', line 12

def initialize(*args, &block)
  super
  self.oauth_identifier ||= self.class.unique_random_token(:oauth_identifier)
  self.oauth_secret ||= self.class.unique_random_token(:oauth_secret)
end

#to_paramObject


18
19
20
# File 'lib/oauth2/provider/models/client.rb', line 18

def to_param
  new_record? ? nil : oauth_identifier
end