bearer

package
v0.0.0-...-851e7b8 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bearer

type Bearer struct {
}

Bearer can create and refresh a bearer

func (*Bearer) Create

func (b *Bearer) Create(username, id, subject, userAgent, userDevice string, expiresTime int64) (string, error)

Create a bearer

func (*Bearer) RefreshToken

func (b *Bearer) RefreshToken(token string) (string, error)

RefreshToken will refresh a old token

type Claims

type Claims interface {
	Valid() error
}

Claims For a type to be a Claims object, it must just have a Valid method that determines if the token is invalid for any supported reason

type ClodraStandardClaims

type ClodraStandardClaims struct {
	Audience   string `json:"aud,omitempty"`
	ExpiresAt  int64  `json:"exp,omitempty"`
	ID         string `json:"jti,omitempty"`
	IssuedAt   int64  `json:"iat,omitempty"`
	Issuer     string `json:"iss,omitempty"`
	NotBefore  int64  `json:"nbf,omitempty"`
	Subject    string `json:"sub,omitempty"`
	UserAgent  string `json:"ua,omitempty"`
	UserDevice string `json:"ud,omitempty"`
}

ClodraStandardClaims is Structured version of Claims Section, as referenced at https://tools.ietf.org/html/rfc7519#section-4.1 See examples for how to use this with your own claim types

func (ClodraStandardClaims) Valid

func (c ClodraStandardClaims) Valid() error

Valid is Validates time based claims "exp, iat, nbf". There is no accounting for clock skew. As well, if any of the above claims are not in the token, it will still be considered a valid claim.

func (*ClodraStandardClaims) VerifyAudience

func (c *ClodraStandardClaims) VerifyAudience(cmp string, req bool) bool

VerifyAudience Compares the aud claim against cmp. If required is false, this method will return true if the value matches or is unset

func (*ClodraStandardClaims) VerifyExpiresAt

func (c *ClodraStandardClaims) VerifyExpiresAt(cmp int64, req bool) bool

VerifyExpiresAt Compares the exp claim against cmp. If required is false, this method will return true if the value matches or is unset

func (*ClodraStandardClaims) VerifyIssuedAt

func (c *ClodraStandardClaims) VerifyIssuedAt(cmp int64, req bool) bool

VerifyIssuedAt Compares the iat claim against cmp. If required is false, this method will return true if the value matches or is unset

func (*ClodraStandardClaims) VerifyIssuer

func (c *ClodraStandardClaims) VerifyIssuer(cmp string, req bool) bool

VerifyIssuer Compares the iss claim against cmp. If required is false, this method will return true if the value matches or is unset

func (*ClodraStandardClaims) VerifyNotBefore

func (c *ClodraStandardClaims) VerifyNotBefore(cmp int64, req bool) bool

VerifyNotBefore Compares the nbf claim against cmp. If required is false, this method will return true if the value matches or is unset

func (*ClodraStandardClaims) VerifyUserAgent

func (c *ClodraStandardClaims) VerifyUserAgent(cmp string, req bool) bool

VerifyUserAgent Compares the useragent with old useragent. If required is false, this method will return true if the value matches or is unset

func (*ClodraStandardClaims) VerifyUserDevice

func (c *ClodraStandardClaims) VerifyUserDevice(cmp string, req bool) bool

VerifyUserDevice Compares the userdevice with old userdevice. If required is false, this method will return true if the value matches or is unset

Jump to

Keyboard shortcuts

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