Skip to content

Instantly share code, notes, and snippets.

View pgolding's full-sized avatar
🎯
Focusing

Oberon Dude pgolding

🎯
Focusing
View GitHub Profile
@pgolding
pgolding / readme.md
Last active August 17, 2023 08:34
How to use pyjwt to decode RS256-signed JWT tokens (e.g. for Auth0) and run it on AWS Lambda with Python 3.6 (e.g. custom authorizers for serverless)

PyJWT with Python AWS Lambda Functions (LF)

If you are using Auth0 (or some OAuth authorization service) then you will most likely be interested in using JWT tokens via some kind of grant. Auth0 discusses how to call an API with such a token.

Perhaps you wish to use a custom authorizer for your serverless project.

To do so, you must write code to decode the JWT token before creating a policy (or not) to grant invoke permissions on your LF. Per various recommendations, the best method to protect your JWT tokens is to use RS256 signing.

However, if you are using pyjwt to decode RS256 tokens, this library depends upon cryptography and that, in turn, has compiled dependencies

<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script src="http://s.phono.com/releases/0.1/jquery.phono.js"></script>
</head>
<body>
<input id="call" type="button" disabled="true" value="Loading..." />
<div id="pickup2" style="display:none"><input id="pickup" type="button" value="pickup" /></div>
<div id="hangupdiv" style="display:none"><input id="hangup" type="button" value="hangup" /></div>