Documentation
¶
Index ¶
- func CryptoRandomBytes(length int64) ([]byte, error)
- func CryptoRandomString(length int) (string, error)
- func GetIPFromContext(ctx context.Context) string
- func HashToken(token, salt string) string
- func IsRedirectSafe(redirectURL, baseURL string) bool
- func SHA256Hex(s string) string
- func SetIPContext(ctx context.Context, ip string) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CryptoRandomBytes ¶
CryptoRandomBytes generates cryptographically secure random bytes
func CryptoRandomString ¶
CryptoRandomString generates a random hex string for salts
func GetIPFromContext ¶
GetIPFromContext extracts the client IP address from the context. Returns empty string if IP cannot be determined.
func HashToken ¶
HashToken returns PBKDF2 hash of token with salt Parameters match Gitea's implementation for security consistency
func IsRedirectSafe ¶ added in v0.14.0
IsRedirectSafe validates that a redirect URL is safe to use. It only allows: 1. Relative paths starting with "/" but not "//" 2. Absolute URLs that match the baseURL host
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.