util

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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