Skip to content

Instantly share code, notes, and snippets.

@Arvinje
Arvinje / authHandler.ts
Created December 31, 2019 00:37
Lambda Authorizer for AWS API Gateway in Typescript
import axios from 'axios'
import jwt from 'jsonwebtoken'
import jwkToPem from 'jwk-to-pem'
import { AuthResponse, CustomAuthorizerEvent, PolicyDocument } from 'aws-lambda'
import { AxiosError, AuthError, ValidationError } from '../../shared/errors'
// For AWS Cognito: https://cognito-idp.<region>.amazonaws.com/<user pool id>
// refer to: http://amzn.to/2fo77UI
const iss = process.env.ISS

Keybase proof

I hereby claim:

  • I am arvinje on github.
  • I am arvinje (https://keybase.io/arvinje) on keybase.
  • I have a public key ASAMcP7uLGWQrlTAXymVPLaXkl1z168B9DRPVkV84LGFgQo

To claim this, I am signing this object:

@Arvinje
Arvinje / action_controller_parameters_extension.rb
Last active December 12, 2015 20:37
ActionController extension to fix Persian numerals
module ActionControllerParametersExtension
extend ActiveSupport::Concern
# A recursive method to traverse the params hash. It replaces
# persian numerals with their equivalent english numerals.
# It's not the best way to do it, but it works for now.
def fix_numerals(element=self)
case element
when Hash
Hash[ element.map{ |k,v| [k, fix_numerals(v)] } ]