Sha256: 24707ae26eed98ab9961d3a6bb55033dbd4aaf40da5cb7bf2328ffa5da07e15c
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
require 'mongoid' require 'validate_url' require 'chronic' require 'orm_adapter' require "oauth2_provider/engine" require "oauth2_provider/controller_mixin" module Oauth2Provider def self.settings @settings ||= YAML.load_file("#{Oauth2Provider::Engine.root}/config/oauth.yml") end def self.normalize_scope(scope = []) scope = scope.split(" ") if scope.kind_of? String normalized = self::Scope.any_in(name: scope) normalized = normalized.map(&:values).flatten if normalized.empty? return self.clean(scope) else return self.clean(scope) + self.normalize_scope(normalized) end end # Remove 'no action' keys. For example during normalization # we add keys like 'pizza' (resource names) or 'pizza/read' # wihch we have to remove to easily make the access recognition # with the bearer token. # # NOTE: at the moment are not allowed methods which contain # the word "read" because it will be removed def self.clean(scope) scope = scope.keep_if {|scope| scope =~ /\// } scope = scope.delete_if {|scope| scope =~ /read/ } scope = scope.uniq return scope end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
oauth2_provider_engine-0.0.2 | lib/oauth2_provider.rb |
oauth2_provider_engine-0.0.1 | lib/oauth2_provider.rb |