Module: Doorkeeper::OAuth::Helpers::ScopeChecker

Defined in:
lib/doorkeeper/oauth/helpers/scope_checker.rb

Class Method Summary collapse

Class Method Details

.valid?(scope_str, server_scopes, application_scopes = nil) ⇒ Boolean

Returns:

  • (Boolean)

5
6
7
8
9
10
11
12
13
14
15
# File 'lib/doorkeeper/oauth/helpers/scope_checker.rb', line 5

def self.valid?(scope_str, server_scopes, application_scopes = nil)
  valid_scopes = if application_scopes.present?
                   server_scopes & application_scopes
                 else
                   server_scopes
                 end

  scope_str.present? &&
    scope_str !~ /[\n|\r|\t]/ &&
    valid_scopes.has_scopes?(OAuth::Scopes.from_string(scope_str))
end