Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thilux/go-jwt
https://github.com/thilux/go-jwt
actions go golang jwt jwt-claims jwt-token
Last synced: about 5 hours 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 (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-10T22:58:54.000Z (about 4 years ago)
- Last Synced: 2024-07-30T16:45:54.204Z (3 months 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
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/thilux/go-jwt/Go?logo=github&style=for-the-badge)](https://github.com/thilux/go-jwt/actions?query=workflow%3AGo)
[![codecov](https://img.shields.io/codecov/c/github/thilux/go-jwt/master?logo=codecov&style=for-the-badge)](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 mainimport (
"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":"[email protected]"}
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.