~netlandish/gobwebs-oauth2

30c7e578294580d5b8073fba9a249293928d7710 — Peter Sanchez 1 year, 5 months ago bf77e24
Adding personal type to personal access tokens
2 files changed, 14 insertions(+), 3 deletions(-)

M bearer.go
M routes.go
M bearer.go => bearer.go +12 -2
@@ 12,8 12,18 @@ import (
	"hg.code.netlandish.com/~netlandish/gobwebs/crypto"
)

// TokenVersion ...
const TokenVersion uint = 0
const (
	// TokenVersion ...
	TokenVersion uint = 0

	// Token types

	// TypePersonal ...
	TypePersonal string = "PERSONAL"

	// TypeOAuth2 ...
	TypeOAuth2 string = "OAUTH2"
)

// Timestamp ...
type Timestamp int64

M routes.go => routes.go +2 -1
@@ 96,6 96,7 @@ func (s *Service) AddPersonal(c echo.Context) error {

		grant := BearerToken{
			Version:  TokenVersion,
			Type:     TypePersonal,
			Issued:   ToTimestamp(issued),
			Expires:  ToTimestamp(expires),
			Grants:   "",


@@ 575,7 576,7 @@ func (s *Service) AccessTokenPOST(c echo.Context) error {

	bt := BearerToken{
		Version:  TokenVersion,
		Type:     "OAUTH2",
		Type:     TypeOAuth2,
		Issued:   ToTimestamp(issued),
		Expires:  ToTimestamp(expires),
		Grants:   payload.Grants,