AcrashcourseoServerlessAutheticatio/Authorizatio
AshortadeasyboilerplateshowcasigJWTauthwithNodejs,theServerlessframework,MogoDBadAWSLambda.
TheauthfolderhasaVerifyToke.jsfilewhichisthebaseoftheauthorizerfuctio.TheVerifyToke.authmethodisaddedtotheauthorizerfielditheserverless.ymlforAPIGatewayroutesyouwishtokeepprivate.Seethemefuctio.AuthHadler.meusesevet.requestCotext.authorizer.pricipalIdtoaccesstheuserIdoftheuseraccessigtheresourceiftheJWTisvalid.Otherwisereturs'Uauthorized'.Note:Thecoceptofmiddlewarescabeappliedtothisforuderstadigiteasily.










评论