Class: Doorkeeper::OAuth::Helpers::ScopeChecker::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/doorkeeper/oauth/helpers/scope_checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope_str, server_scopes, app_scopes, grant_type) ⇒ Validator

Returns a new instance of Validator.


10
11
12
13
14
15
16
# File 'lib/doorkeeper/oauth/helpers/scope_checker.rb', line 10

def initialize(scope_str, server_scopes, app_scopes, grant_type)
  @parsed_scopes = OAuth::Scopes.from_string(scope_str)
  @scope_str = scope_str
  @valid_scopes = valid_scopes(server_scopes, app_scopes)

  @scopes_by_grant_type = Doorkeeper.config.scopes_by_grant_type[grant_type.to_sym] if grant_type
end

Instance Attribute Details

#parsed_scopesObject (readonly)

Returns the value of attribute parsed_scopes


8
9
10
# File 'lib/doorkeeper/oauth/helpers/scope_checker.rb', line 8

def parsed_scopes
  @parsed_scopes
end

#scope_strObject (readonly)

Returns the value of attribute scope_str


8
9
10
# File 'lib/doorkeeper/oauth/helpers/scope_checker.rb', line 8

def scope_str
  @scope_str
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)

18
19
20
21
22
23
# File 'lib/doorkeeper/oauth/helpers/scope_checker.rb', line 18

def valid?
  scope_str.present? &&
    scope_str !~ /[\n\r\t]/ &&
    @valid_scopes.has_scopes?(parsed_scopes) &&
    permitted_to_grant_type?
end