Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hako/branca
:key: Secure alternative to JWT. Authenticated Encrypted API Tokens for Go.
https://github.com/hako/branca
api api-token branca crypto cryptography go golang jwt token-authentication token-authetication xchacha20-poly1305
Last synced: 5 days ago
JSON representation
:key: Secure alternative to JWT. Authenticated Encrypted API Tokens for Go.
- Host: GitHub
- URL: https://github.com/hako/branca
- Owner: hako
- License: mit
- Created: 2018-01-09T15:27:31.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-08-07T06:24:03.000Z (over 4 years ago)
- Last Synced: 2024-11-17T12:27:46.887Z (2 months ago)
- Topics: api, api-token, branca, crypto, cryptography, go, golang, jwt, token-authentication, token-authetication, xchacha20-poly1305
- Language: Go
- Homepage: https://branca.io
- Size: 21.5 KB
- Stars: 173
- Watchers: 9
- Forks: 20
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-Char - branca - Golang implementation of Branca Tokens. (Authentication and OAuth / Contents)
- awesome-go - branca - Golang implementation of Branca Tokens. (Authentication and OAuth)
- awesome-repositories - hako/branca - :key: Secure alternative to JWT. Authenticated Encrypted API Tokens for Go. (Go)
- go-awesome - branca - a token solution claiming to be more secure than JWT (Open source library / Auth)
- awesome-go - branca
- awesome-go - branca - Golang implementation of Branca Tokens. - :arrow_down:0 - :star:20 (Authentication and OAuth)
- awesome-go - branca - Secure alternative to JWT. Authenticated Encrypted API Tokens for Go. - ★ 33 (Authentication and OAuth)
- awesome-go-cn - branca
README
# branca
[![Build Status](https://travis-ci.org/hako/branca.svg?branch=master)](https://travis-ci.org/hako/branca) [![Go Report Card](https://goreportcard.com/badge/github.com/hako/branca)](https://goreportcard.com/report/github.com/hako/branca)
[![GoDoc](https://godoc.org/github.com/hako/branca?status.svg)](https://godoc.org/github.com/hako/branca)branca is a secure alternative to JWT, This implementation is written in pure Go (no cgo dependencies) and implements the [branca token specification](https://github.com/tuupola/branca-spec).
# Requirements
Go 1.13+
# Install
```
go get -u github.com/hako/branca
```# Example
```go
package mainimport (
"fmt"
"github.com/hako/branca"
)func main() {
b := branca.NewBranca("supersecretkeyyoushouldnotcommit") // This key must be exactly 32 bytes long.
// Encode String to Branca Token.
token, err := b.EncodeToString("Hello world!")
if err != nil {
fmt.Println(err)
}
//b.SetTTL(3600) // Uncomment this to set an expiration (or ttl) of the token (in seconds).
//token = "87y8daMzSkn7PA7JsvrTT0JUq1OhCjw9K8w2eyY99DKru9FrVKMfeXWW8yB42C7u0I6jNhOdL5ZqL" // This token will be not allowed if a ttl is set.
// Decode Branca Token.
message, err := b.DecodeToString(token)
if err != nil {
fmt.Println(err) // token is expired.
return
}
fmt.Println(token) // 87y8da....
fmt.Println(message) // Hello world!
}
```# Todo
Here are a few things that need to be done:
- [x] Remove cgo dependencies.
- [x] Move to a pure XChaCha20 algorithm in Go.
- [x] Add more tests than just acceptance tests.
- [x] Increase test coverage.
- [ ] Additional Methods. (Encode, Decode []byte)
- [ ] Performance benchmarks.
- [ ] More comments, examples and documentation.# Contributing
Contributions are welcome! Fork this repo and add your changes and submit a PR.
If you would like to fix a bug, add a feature or provide feedback you can do so in the issues section.
You can run tests by runnning `go test`. Running `go test; go vet; golint` is recommended.
# License
MIT