Sha256: a90762e55ec940d3c847f69d2ed6a4d5f14d5e92e16e6316b73650067ced0c9b

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

module WineBouncer
  module AuthStrategies
    class Protected

      def endpoint_protected?(context)
        has_authorizations?(context)
      end

      def has_auth_scopes?(context)
        endpoint_authorizations(context) && 
          endpoint_authorizations(context).has_key?(:scopes) && 
          endpoint_authorizations(context)[:scopes].any?
      end

      def auth_scopes(context)
        endpoint_authorizations(context)[:scopes].map(&:to_sym)
      end

      private

      def nil_authorizations?(context)
        endpoint_authorizations(context).nil?
      end


      def has_authorizations?(context)
        nil_authorizations?(context) || endpoint_authorizations(context)
      end

      def endpoint_authorizations(context)
         context[:auth]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wine_bouncer-0.2.2 lib/wine_bouncer/auth_strategies/protected.rb