Class: Jets::Authorizer::Base

Inherits:
Lambda::Functions show all
Includes:
Dsl, Helpers::IamHelper
Defined in:
lib/jets/authorizer/base.rb

Instance Attribute Summary

Attributes inherited from Lambda::Functions

#context, #event, #meth

Class Method Summary collapse

Methods inherited from Lambda::Functions

inherited, #initialize, output_keys, subclasses

Methods included from Lambda::Dsl

#lambda_functions

Constructor Details

This class inherits a constructor from Jets::Lambda::Functions

Class Method Details

.authorization_type(authorizer) ⇒ Object

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



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jets/authorizer/base.rb', line 22

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

.process(event, context, meth) ⇒ Object



12
13
14
15
# File 'lib/jets/authorizer/base.rb', line 12

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