https://github.com/thilux/go-jwt
https://github.com/thilux/go-jwt
actions go golang jwt jwt-claims jwt-token
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/thilux/go-jwt
- Owner: thilux
- License: apache-2.0
- Created: 2020-06-11T01:13:59.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-10T22:58:54.000Z (almost 6 years ago)
- Last Synced: 2025-05-18T20:06:43.221Z (about 1 year ago)
- Topics: actions, go, golang, jwt, jwt-claims, jwt-token
- Language: Go
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# thilux JWT
[](https://github.com/thilux/go-jwt/actions?query=workflow%3AGo)
[](https://codecov.io/gh/thilux/go-jwt)
This is a very simple implementation of a JWT encode/decode library in Go. I have mainly done this to play around with some Go concepts and standard library.
## Getting started
To install thilux's go-jwt:
`go get xxxxxxxxx/thilux/jwt`
A very basic usage example:
```go
package main
import (
"fmt"
"thilux.io/thilux/jwt"
)
type myUserDetails struct {
Username string `json:"username"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Claims map[string]string `json:"claims"`
}
const tokenSecret = "19db940ghf439bf340fgu3bdlkwnhfpehdp"
func main() {
claims := map[string]string{"admin": "no", "email":"myuser@email.com"}
userDetails := myUserDetails{Username: "myuser", FirstName: "First", LastName: "Last", Claims: claims}
token, err := jwt.Encode(userDetails, tokenSecret, "HS256")
if err != nil {
fmt.Println("Error generating token: " + err.Error())
return
}
fmt.Println("Token: " + token)
}
```
## License
This project is under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for the full text.