Skip to content

ar-sandbox3/level5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

level5

This repository exhibits the basic concept of middleware, in the context of Go-based HTTP Server.

Utilities

This also holds utilities on dealing with JWT.

  1. rsagen
  2. jwtgen
  3. jwtval

rsagen

It generates RSA keypair (private.pem and public.pem).

go run cmd/rsagen/main.go

jwtgen

It generates a JWT (token.jwt) file, that can be generated using symmetric (HS256) or assymmetric (RS256) key.

See: https://auth0.com/blog/rs256-vs-hs256-whats-the-difference/.

To run with symmetric key, you need to specify the key.

go run cmd/jwtgen/main.go --symmetric --key supersecret

However, this program is by default generating RS256 token.

Note

Please make sure to generate RSA keypair first.

go run cmd/jwtgen/main.go

jwtval

It validates the generated token.jwt using the defined key strategy (symmetric/asymmetric).

go run cmd/jwtgen/main.go --symmetric --key supersecret

And if the token.jwt was generated using RSHA256.

go run cmd/jwtgen/main.go

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages