class WineBouncer::AuthStrategies::Protected

Public Instance Methods

auth_scopes() click to toggle source
# File lib/wine_bouncer/auth_strategies/protected.rb, line 16
def auth_scopes
  endpoint_authorizations[:scopes].map(&:to_sym)
end
endpoint_protected?() click to toggle source
# File lib/wine_bouncer/auth_strategies/protected.rb, line 6
def endpoint_protected?
  has_authorizations?
end
has_auth_scopes?() click to toggle source
# File lib/wine_bouncer/auth_strategies/protected.rb, line 10
def has_auth_scopes?
  endpoint_authorizations &&
    endpoint_authorizations.key?(:scopes) &&
    endpoint_authorizations[:scopes].any?
end

Private Instance Methods

endpoint_authorizations() click to toggle source
# File lib/wine_bouncer/auth_strategies/protected.rb, line 38
def endpoint_authorizations
  api_context.options[:route_options][:auth]
end
has_authorizations?() click to toggle source

returns true if an authorization hash has been found First it checks for the old syntax, then for the new.

# File lib/wine_bouncer/auth_strategies/protected.rb, line 28
def has_authorizations?
  (nil_authorizations? || !!endpoint_authorizations) && scope_keys?
end
nil_authorizations?() click to toggle source
# File lib/wine_bouncer/auth_strategies/protected.rb, line 22
def nil_authorizations?
  endpoint_authorizations.nil?
end
scope_keys?() click to toggle source

if false or nil scopes are entered the authorization should be skipped. nil_authorizations? is used to check against the legacy hash.

# File lib/wine_bouncer/auth_strategies/protected.rb, line 34
def scope_keys?
  nil_authorizations? || endpoint_authorizations[:scopes] != [false]
end