authutils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package authutils provides authentication utilities for apps using golang-jwt/v4

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSignedJWT

func GetSignedJWT(ttl int, secret string, customClaims jwt.MapClaims) (string, error)

GetSignedJWT creates a JWT token with the provided customClaims and returns a string signed using HMAC SHA-256

  • ttl: Time To Live in minutes
  • secret: Signing secret key
  • customClaims

func GetTokenClaims

func GetTokenClaims(token *jwt.Token) jwt.MapClaims

GetTokenClaims returns token's associated claims

func IsTokenExpiring

func IsTokenExpiring(token *jwt.Token, timeLeft int) bool

IsTokenExpiring returns true if the provided token is expiring in the next timeLeft minutes

func ParseToken

func ParseToken(signedString, secret string) (*jwt.Token, error)

ParseToken parses and validates a signed string and returns it's token object

  • signedString
  • secret: Signing secret key used to generate the signedString

It always returns an error, which is nil when the parsing is successful

Types

This section is empty.

Jump to

Keyboard shortcuts

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