Sha256: caaefad57e52ed83add8713cef2bf806c0304ea70839e30bc5d6a1e285e78904

Contents?: true

Size: 757 Bytes

Versions: 6

Compression:

Stored size: 757 Bytes

Contents

module WineBouncer
  module AuthStrategies
    class Swagger

      def endpoint_protected?(context)
        has_authorizations?(context) && !!authorization_type_oauth2(context)
      end

      def has_auth_scopes?(context)
        endpoint_protected?(context) && !authorization_type_oauth2(context).empty?
      end

      def auth_scopes(context)
        authorization_type_oauth2(context).map{ |hash| hash[:scope].to_sym }
      end

      private

      def has_authorizations?(context)
        !!endpoint_authorizations(context)
      end

      def endpoint_authorizations(context)
        context[:authorizations]
      end

      def authorization_type_oauth2(context)
        endpoint_authorizations(context)[:oauth2]
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wine_bouncer-0.2.2 lib/wine_bouncer/auth_strategies/swagger.rb
wine_bouncer-0.2.1 lib/wine_bouncer/auth_strategies/swagger.rb
wine_bouncer-0.2.0 lib/wine_bouncer/auth_strategies/swagger.rb
wine_bouncer-0.1.2 lib/wine_bouncer/auth_strategies/swagger.rb
wine_bouncer-0.1.1 lib/wine_bouncer/auth_strategies/swagger.rb
wine_bouncer-0.1.0 lib/wine_bouncer/auth_strategies/swagger.rb