In this episode we will explore supporting JSON Web Tokens, or JWTs. These are a common standard for use in authentication tokens which allows you to support 3rd party authentication providers, token expiration, user metadata and more. These are cryptographically signed and can be verified by the server with a secret. There is also the option to use RSA public/private key pairs to allow clients to verify tokens without going back to the server that signed them. For these reasons JWTs are a really powerful option. Here we will use the Vapor JWT package to provide support for generating and authenticating with HS256 tokens.
Episode Links Vapor Docs - Note that these were slightly out of date when I recorded this video, but they were still very helpful in understanding the general idea. Vapor JWT Package JWT.io - Useful for seeing the structure of tokens Boop App - This is the app I like to use for quick things like decoding JWTs, base64 encoding/decoding. (Mac App Store Link) Apple's Public JWKS - This is an example of a JWKS resource you can fetch to validate tokens. This is only if using RS256 tokens. We'd use this if we supported Sign in with Apple.