util

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CryptoRandomBytes

func CryptoRandomBytes(length int64) ([]byte, error)

CryptoRandomBytes generates cryptographically secure random bytes

func CryptoRandomString

func CryptoRandomString(length int) (string, error)

CryptoRandomString generates a random hex string for salts

func GetIPFromContext

func GetIPFromContext(ctx context.Context) string

GetIPFromContext extracts the client IP address from the context

func GetUsernameFromContext

func GetUsernameFromContext(ctx context.Context) string

GetUsernameFromContext extracts the username from the user object in context

func HashToken

func HashToken(token, salt string) string

HashToken returns PBKDF2 hash of token with salt Parameters match Gitea's implementation for security consistency

func IPMiddleware

func IPMiddleware() gin.HandlerFunc

IPMiddleware extracts client IP and stores it in the context

Types

This section is empty.

Jump to

Keyboard shortcuts

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