Cognito Authorization not working locally?


#1

Hi, I can deploy and get 401 errors but when I run jets locally it gives a 200 response. When I remove the authorizers i get a 200 on both my local and dev environments

Controller

class OrdersController < ApplicationController

authorizer "main#my_cognito"

Authorizer

class MainAuthorizer < ApplicationAuthorizer
  authorizer(
name: "MyCognito", # <= name is used as the "function" name
identity_source: "Authorization", # maps to method.request.header.Authorization
type: :cognito_user_pools,
provider_arns: [
  "...",
],
  )
  # no lambda function
end

#3

Also is there a way to define a userpool per environment?


#4

You can probably do it with Shared Resources http://rubyonjets.com/docs/shared-resources/

But wouldn’t recommend it. Cognitio Pools have state, like a database. So wouldn’t couple it with the Jets app. IE: You delete the Jets app, you’ll delete the Cognito Pool or database. Jets apps are probably better stateless. Define the Cognito Pool outside of the Jets.