Sha256: 332d7b41d75fb06859859cd700000cf9b1f73aa62a85fe96e065514b025d6368

Contents?: true

Size: 1.36 KB

Versions: 15

Compression:

Stored size: 1.36 KB

Contents

# Authorizer public methods get turned into Lambda functions.
#
# Jets::Authorizer::Base < Jets::Lambda::Functions
# Both Jets::Authorizer::Base and Jets::Lambda::Functions have Dsl modules included.
# So the Jets::Authorizer::Dsl overrides some of the Jets::Lambda::Functions behavior.
module Jets::Authorizer
  class Base < Jets::Lambda::Functions
    include Dsl
    include Helpers::IamHelper
    prepend Jets::ExceptionReporting::Process

    class << self
      def process(event, context, meth)
        authorizer = new(event, context, meth)
        authorizer.send(meth)
      end

      # Parameter: authorizer: Example: "main#protect"
      #
      # Determines authorization_type based on whether the authorizer is a Lambda or Cognito authorizer.
      #
      # Returns custom or cognito_user_pools
      def authorization_type(authorizer)
        class_name, meth = authorizer.split('#')
        klass = "#{class_name}_authorizer".camelize.constantize
        meth = meth.to_sym

        # If there's a lambda function associated with the authorizer then it's a custom authorizer
        # Otherwise it's a cognito authorizer.
        #
        # Returns: Valid values: none, aws_iam, custom, cognito_user_pools, aws_cross_account_iam
        methods = klass.public_instance_methods(false)
        methods.include?(meth) ? :custom : :cognito_user_pools
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/authorizer/base.rb
jets-5.0.12 lib/jets/authorizer/base.rb
jets-5.0.11 lib/jets/authorizer/base.rb
jets-5.0.10 lib/jets/authorizer/base.rb
jets-5.0.9 lib/jets/authorizer/base.rb
jets-5.0.8 lib/jets/authorizer/base.rb
jets-5.0.7 lib/jets/authorizer/base.rb
jets-5.0.6 lib/jets/authorizer/base.rb
jets-5.0.5 lib/jets/authorizer/base.rb
jets-5.0.4 lib/jets/authorizer/base.rb
jets-5.0.3 lib/jets/authorizer/base.rb
jets-5.0.2 lib/jets/authorizer/base.rb
jets-5.0.1 lib/jets/authorizer/base.rb
jets-5.0.0 lib/jets/authorizer/base.rb
jets-5.0.0.beta1 lib/jets/authorizer/base.rb