All Projects → ericchiang → Go Past

ericchiang / Go Past

Licence: mit
Go implementation of Platform-Agnostic Security Tokens

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Labels

Projects that are alternatives of or similar to Go Past

X Restful Api Generator Koa
一个基于 Koa 的 RESTful API 服务脚手架。 A RESTful API generator for Koa
Stars: ✭ 18 (-14.29%)
Mutual labels:  jwt
Jose
JSON Object Signing and Encryption for Node.js and the browser
Stars: ✭ 25 (+19.05%)
Mutual labels:  jwt
Devise Jwt
JWT token authentication with devise and rails
Stars: ✭ 881 (+4095.24%)
Mutual labels:  jwt
Go jwt
golang for websocket wechat or weixin and jwt,http ratelimit
Stars: ✭ 19 (-9.52%)
Mutual labels:  jwt
Koa Typeorm Starter
Starter project for using koa with TS and TypeORM
Stars: ✭ 23 (+9.52%)
Mutual labels:  jwt
Oc Jwtauth Plugin
JWTAuth Plugin for OctoberCMS.
Stars: ✭ 8 (-61.9%)
Mutual labels:  jwt
Geek Framework
基于SpringBoot+Shiro+Redis+Jwt+Thymeleaf+MyBatis 开发的后台用户、角色、权限、会员管理、RestFul、Token和前台用户登录注册以及前后台用户分离的脚手架,技术交流请加QQ群:805442966
Stars: ✭ 804 (+3728.57%)
Mutual labels:  jwt
Nextjs Sequelize
Next.js With Sequelize Web Application, a Full-Stack Web App Development Boilerplate. https://medium.com/@defrian.yarfi/next-js-with-sequelize-web-application-a-full-stack-web-development-a0051074e998
Stars: ✭ 21 (+0%)
Mutual labels:  jwt
Go Base
Go RESTful API Boilerplate with JWT Authentication backed by PostgreSQL
Stars: ✭ 928 (+4319.05%)
Mutual labels:  jwt
Access
Ponzu Addon to manage API access grants and tokens for authentication
Stars: ✭ 13 (-38.1%)
Mutual labels:  jwt
Fastify Esso
The easiest authentication plugin for Fastify, with built-in support for Single sign-on
Stars: ✭ 20 (-4.76%)
Mutual labels:  jwt
Jwt Example
Playing with user registration, login/logout, auth, etc using JWTs, serverless functions & faunadb as the data store.
Stars: ✭ 22 (+4.76%)
Mutual labels:  jwt
Hello Sso Jwt Resource
Single Sign On (SSO) Example with JSON Web Token (JWT), Spring Boot
Stars: ✭ 10 (-52.38%)
Mutual labels:  jwt
Silhouette
Silhouette is a framework agnostic authentication library for Scala that supports several authentication methods, including OAuth2, OpenID Connect, Credentials, Basic Authentication or custom authentication schemes.
Stars: ✭ 18 (-14.29%)
Mutual labels:  jwt
Ee7 Jaxrs Sample
Building RESTful APIs with Java EE 7 and JAXRS
Stars: ✭ 15 (-28.57%)
Mutual labels:  jwt
Go Book Store Api
Go Sample project to understand Mysql CRUD operation with best practises Includes logging, JWT, Swagger and Transactions
Stars: ✭ 18 (-14.29%)
Mutual labels:  jwt
Emqx Auth Jwt
EMQ X JWT Authentication Plugin
Stars: ✭ 26 (+23.81%)
Mutual labels:  jwt
Spring Security Rbac Jwt
springboot2项目的脚手架工程(包含security + jwt方式的动态权限校验)
Stars: ✭ 21 (+0%)
Mutual labels:  jwt
Jose
A JOSE implementation
Stars: ✭ 20 (-4.76%)
Mutual labels:  jwt
Symfony Api Skeleton
rest api skeleton based on symfony-flex, api-platform, fosuserbundle etc.
Stars: ✭ 11 (-47.62%)
Mutual labels:  jwt

go-past

GoDoc Build Status

A Go implementation of Platform-Agnostic Security Tokens (PAST), "a secure alternative to JWT."

Warning

This package still needs to be check for conformance against the original PHP implementaiton.

This package may change in the future, hasn't been audited, isn't thoroughly tested, and hasn't been fuzzed. Proceed with caution.

PAST

PAST is a JWT alternative for authenticating, signing, and encrypting payloads into URL frendly tokens. As opposed to JWTs which require parsing a complex header to determine the signature algorithm, PAST token headers only hold a version and an operation. For example the following token uses PAST v2 to authenticate (auth) a message.

v2.auth.ewogICJkYXRhIjogInRoaXMgaXMgYW4gYXV0aGVudGljYXRlZCBtZXNzYWdlIiwKICAiZXhwIjogIjIwMzktMDEtMDFUMDA6MDA6MDAiCn3OF39sdzCcOyUiVSSQwRfGoauVG5Xt9eZc45k31wdxjA

v2.auth. indicates that this token is authenticated with a symmetric key using HMAC-SHA512. The payload is a plain text and a MAC.

The map of versions and operations to algorithms can be found here: https://github.com/paragonie/past/tree/master/docs/01-Protocol-Versions

Usage

Given a symmetric key and a payload, a user can construct an authenticated message encoded as a PAST token.

key, err := past.NewKey()
if err != nil {
    // Handle error
}

payload := []byte(`{
  "data": "this is an authenticated message",
  "exp": "2039-01-01T00:00:00"
}`)

token, err := past.V2.Auth(key, payload)
if err != nil {
    // Handle error
}
fmt.Printf("%x\n", key)
fmt.Println(token)

The program above prints the generated authentication key and the PAST token.

e0ea39822d1b9fa67da2c63dd51b47892f66a1e80d14a40fb3d96dc0ab839fbd
v2.auth.ewogICJkYXRhIjogInRoaXMgaXMgYW4gYXV0aGVudGljYXRlZCBtZXNzYWdlIiwKICAiZXhwIjogIjIwMzktMDEtMDFUMDA6MDA6MDAiCn3OF39sdzCcOyUiVSSQwRfGoauVG5Xt9eZc45k31wdxjA

The key can be used at a later time to verify the token.

key, _ := hex.DecodeString("e0ea39822d1b9fa67da2c63dd51b47892f66a1e80d14a40fb3d96dc0ab839fbd")

token := "v2.auth.ewogICJkYXRhIjogInRoaXMgaXMgYW4gYXV0aGVudGljYXRlZCBtZXNzYWdlIiwKICAiZXhwIjogIjIwMzktMDEtMDFUMDA6MDA6MDAiCn3OF39sdzCcOyUiVSSQwRfGoauVG5Xt9eZc45k31wdxjA"

payload, err := past.V2.AuthVerify(key, token)
if err != nil {
    // Handle error
}
fmt.Printf("%s\n", payload)

The program above prints the original payload.

{
  "data": "this is an authenticated message",
  "exp": "2039-01-01T00:00:00"
}

The package also supports signing with an asymmetric key and encrypted authentication with a symmetric key.

Missing features

This implementation is missing the following features:

  • v1.sign (RSASSA-PSS) - PAST requires specifying the mask length, which Go doesn't expose directly
  • v2.enc (XChaCha20-Poly1305) - no XChaCha20 implementation in golang.org/x/crypto (only straight ChaCha20)
  • Footer data

Implementer experience report

Currently, PAST is more of a documented PHP library than a specification. Many of the implementation details require reading the source code, while certain aspects are extremely PHP specific (for example the pre-authentication encoding (PAE) just describes performing PHP's pack('P', n)).

Aspects of PAST can be complex at times. v1.enc's use of HKDF to derive keys and the pre-authentication encoding seralization are good examples of this. Though PAST is more straight forward than a JWT, cookbooks like gtank/cryptopasta might also be of interest for users looking for simpler strategies.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].