Hey, really loving jets so far, but I’m not able to find any strong examples of auth. So far I’ve tried porting devise to Jets without much success and using the built-in Cognito support, but neither has seemed to work.
I noticed that devise is not supported, and that Cognito was community added, so I’m not deeply surprised here, but I’d prefer not to roll my own auth without an example.
A couple of questions:
- Where can we find a working example of auth in a jets application?
- Is there something glaringly wrong with the below implementation of auth with Cognito?
For Cognito, locally, the jets server seems to ignore my authorizer altogether. Is my
class ApplicationAuthorizer < Jets::Authorizer::Base end
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: [ "arn:aws:cognito-idp:us-east-1:753319823037:userpool/us-east-1_VU1wbWqmY", ], ) end
Jets.application.routes.draw do resources :posts, authorizer: "main#my_cognito" root "jets/public#show", authorizer: "main#my_cognito" any "*catchall", to: "jets/public#show" end
class PostsController < ApplicationController authorizer "main#my_cognito" before_action :set_post, only: [:show, :edit, :update, :delete] # GET /posts def index pp event @posts = Post.all end # A bunch more scaffolded controller methods.... end