token

package
v0.51.6-beta1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetExpiry

func GetExpiry(tokenStr string, now time.Time) (expires bool,
	left time.Duration, err error)

func GetUsername

func GetUsername(tokenStr string) (username string, ok bool)

GetUsername extracts the username claim value from the JWT

func IsOrgAdmin

func IsOrgAdmin(tokenStr string) bool

IsOrgAdmin returns the value of the `is_org_admin` claim

func MapClaims

func MapClaims(token *jwt.Token) (claims jwt.MapClaims, err error)

func Parse

func Parse(textToken string) (token *jwt.Token, err error)

Types

type Token

type Token struct {
	Logger       logging.Logger
	AccessToken  string `json:"access_token,omitempty" doc:"Bearer access token."`
	RefreshToken string `json:"refresh_token,omitempty" doc:"Offline or refresh token."`
}

Token contains the current access and refresh tokens from the Authorization server

func (*Token) IsValid

func (t *Token) IsValid() (tokenIsValid bool, err error)

func (*Token) NeedsRefresh

func (t *Token) NeedsRefresh() bool

NeedsRefresh checks if the access token is missing, expired or nearing expiry and should be refreshed

Jump to

Keyboard shortcuts

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