Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

This is demo program to show the working of the go-jwt tool, so we can use this library for authorization in out project.

License

Notifications You must be signed in to change notification settings

rvsingh-094/GO-JSON-Web-Tokens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GO-JSON-Web-Tokens

This is demo program to show the working of the go-jwt tool, so we can use this library for authorization in out project.
I used "github.com/dgrijalva/jwt-go" library for this project.
This library jwt-go used for json web token methods.
As we know that now a days for each user request, instead of validate the user from database side,
we validate the user from cache and by using token in that case json web token is pretty good for solving those problem and its very secure to use and very fast.

Steps for Using the Library

  1. Import the "github.com/dgrijalva/jwt-go
  2. Create public key and private key using command : ssh-keygen -t rsa
  3. Read this files and store in different PrivateKey and PublicKey Using the ioutill library
  4. Use Jwt.New function for create the token
  5. by using the help of jwt.MapClaims, store the metadata inside the jwt token file
  6. Use the files using "jwt.ParseRSAPrivateKeyFromPEM", most of the peopele do wrong here they try to use []byte("string") which most of time throw error
  7. By using (*token).SignedString(interface{}) generate the token response
  8. By using jwt.Parse function, parse the function the code and get the metadata from the db

Thanks if any changes required please let me know.

About

This is demo program to show the working of the go-jwt tool, so we can use this library for authorization in out project.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages