util

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicKeyFile       = "./data/token/public/jwtRS256.key.pub"
	PrivateKeyFile      = "./data/token/privat/jwtRS256.key"
	WrongPublicKeyFile  = "./data/token/public/jwtRS256_wrong.key.pub"
	WrongPrivateKeyFile = "./data/token/privat/jwtRS256_wrong.key"
)
View Source
const (
	Url           = "http://localhost:1203"
	CorrelationId = "X-Correlation-ID"
)
View Source
const (
	DefaultPassword = "SomeDefaultPassowrd"
)

Variables

This section is empty.

Functions

func CreateCustomJWTToken

func CreateCustomJWTToken(userId string, expirationTime int64, signKey *rsa.PrivateKey) string

func CreateUser

func CreateUser(id string, password string) int

func CreateUserForFurtherTesting

func CreateUserForFurtherTesting(t *testing.T) string

func CreateUserId

func CreateUserId() (string, int)

func DeleteUser

func DeleteUser(userId string, tokenString string) int

func LoadPrivateKeyFile added in v0.3.0

func LoadPrivateKeyFile(fileName string) *rsa.PrivateKey

func UpdatePassword

func UpdatePassword(userId string, password string, tokenString string) int

Types

type Authenticate

type Authenticate struct {
	Password string `json:"password" validate:"required"`
}

type Claims

type Claims struct {
	UserId string `json:"user_id"`
	jwt.StandardClaims
}

type TokenResponseDTO

type TokenResponseDTO struct {
	AccessToken      string `json:"access_token"`
	ExpiresIn        int    `json:"expires_in"`
	RefreshToken     string `json:"refresh_token"`
	RefreshExpiresIn int    `json:"refresh_expires_in"`
}

func Login

func Login(userId string, password string) (*TokenResponseDTO, int)

func ObtainToken

func ObtainToken(t *testing.T) (*TokenResponseDTO, string)

func RefreshToken

func RefreshToken(userId string, token string, refreshToken string) (*TokenResponseDTO, int)

Jump to

Keyboard shortcuts

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