token

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Index

Constants

View Source
const (
	Prefix    = "Bearer"
	AuthField = "Authorization"
)

Variables

This section is empty.

Functions

func Generate

func Generate(userId string, state State, d ...time.Duration) (tokenString string, err error)

generate jwt token

func JoinPrefixToken

func JoinPrefixToken(token string) string

Types

type Claims

type Claims struct {
	Uid string `json:"uid"`
	jwt.StandardClaims
}

func Parse

func Parse(tokenString string, state State) (claims Claims, err error)

parse jwt token

type ClaimsInternal

type ClaimsInternal struct {
	Uid string `json:"uid"` // base64 encode
	jwt.StandardClaims
}

type State added in v0.7.0

type State string
const (
	StateUser  State = "user"
	StateAdmin State = "admin"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL