token

package
v1.1.1-0...-9418116 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAccountID

func GetAccountID(token string) (int, error)

GetAccountID retrieves the account id for the current user from the token

func GetAccountName

func GetAccountName(token string) (string, error)

GetAccountName retrieves the account name for the current user

func IsTokenValid

func IsTokenValid(token string) bool

IsTokenValid checks if the token is still valid

Types

type ClaimSet

type ClaimSet struct {
	Subject    string `json:"sub"`
	Admin      bool   `json:"admin"`
	IssuedAt   int64  `json:"iat"`
	Expiration int64  `json:"exp"`
	Hasura     Hasura `json:"https://hasura.io/jwt/claims"`
}

ClaimSet is the auth token claim set type

type Hasura

type Hasura struct {
	AccountID    string   `json:"x-hasura-user-id"`
	DefaultRole  string   `json:"x-hasura-default-role"`
	AllowedRoles []string `json:"x-hasura-allowed-roles"`
}

Hasura holds the hasura configuration

type Token

type Token struct {
	Raw       string
	Claims    *ClaimSet
	Signature []byte
}

Token describes a JSON Web Token.

func ParseTokenClaims

func ParseTokenClaims(rawToken string) (*Token, error)

ParseTokenClaims parses a token from a string

Jump to

Keyboard shortcuts

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