Sha256: b1815f1fe2426c81440fad2ef2f088c30f7613415a676b82622aa29998b7aacc
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true module Doorkeeper module OAuth module Helpers module ScopeChecker class Validator attr_reader :parsed_scopes, :scope_str 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) if grant_type @scopes_by_grant_type = Doorkeeper.configuration.scopes_by_grant_type[grant_type.to_sym] end end def valid? scope_str.present? && scope_str !~ /[\n\r\t]/ && @valid_scopes.has_scopes?(parsed_scopes) && permitted_to_grant_type? end private def valid_scopes(server_scopes, app_scopes) if app_scopes.present? app_scopes else server_scopes end end def permitted_to_grant_type? return true unless @scopes_by_grant_type OAuth::Scopes.from_array(@scopes_by_grant_type) .has_scopes?(parsed_scopes) end end def self.valid?(scope_str:, server_scopes:, app_scopes: nil, grant_type: nil) Validator.new(scope_str, server_scopes, app_scopes, grant_type).valid? end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
doorkeeper-5.1.0.rc2 | lib/doorkeeper/oauth/helpers/scope_checker.rb |
doorkeeper-5.1.0.rc1 | lib/doorkeeper/oauth/helpers/scope_checker.rb |