token_test

package
v0.0.0-...-2d73068 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 19 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TokenManager = newManager()

Functions

func ContextWithRequest

func ContextWithRequest(ctx context.Context) context.Context

func ContextWithTokenAndRequestID

func ContextWithTokenAndRequestID(t *testing.T) (context.Context, string, string)

func ContextWithTokenManager

func ContextWithTokenManager() context.Context

func EmbedIdentityInContext

func EmbedIdentityInContext(identity account.Identity) (context.Context, error)

EmbedIdentityInContext generates a token for the given identity and embed it into the context along with token manager

func EmbedTokenInContext

func EmbedTokenInContext(sub, username string) (context.Context, string, error)

EmbedTokenInContext generates a token and embed it into the context

func EqualAccessTokenWithIdentity

func EqualAccessTokenWithIdentity(ctx context.Context, accessToken string, expectedIdentity account.Identity) error

func EqualAccessTokens

func EqualAccessTokens(ctx context.Context, expectedToken, actualToken string) error

EqualAccessTokens returns an error if the tokens are not equal

func EqualRefreshTokens

func EqualRefreshTokens(ctx context.Context, expectedToken, actualToken string) error

EqualRefreshTokens returns an error if the refresh tokens are not equal

func GenerateAccessTokenWithClaims

func GenerateAccessTokenWithClaims(claims map[string]interface{}) (string, error)

func GenerateRefreshTokenWithClaims

func GenerateRefreshTokenWithClaims(claims map[string]interface{}) (string, error)

func GenerateToken

func GenerateToken(identityID string, identityUsername string) (string, error)

GenerateToken generates a JWT token and signs it using the default private key

func GenerateTokenWithClaims

func GenerateTokenWithClaims(claims map[string]interface{}) (string, error)

GenerateTokenWithClaims generates a JWT token with additional claims

func GenerateUserTokenForIdentity

func GenerateUserTokenForIdentity(ctx context.Context, identity account.Identity, offlineToken bool) (*oauth2.Token, error)

func UpdateToken

func UpdateToken(tokenString string, claims map[string]interface{}) (string, error)

UpdateToken generates a new token based on the existing one with additional claims

Types

This section is empty.

Jump to

Keyboard shortcuts

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