utils

package
v0.2.73 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiKey

func ApiKey(expected string) gin.HandlerFunc

ApiKey returns a Gin middleware that accepts X-API-Key and keeps the legacy ?key= query parameter for compatibility.

func ParseRSAPrivateKey

func ParseRSAPrivateKey(pem string) (*rsa.PrivateKey, error)

ParseRSAPrivateKey loads an RSA private key from PEM.

func ParseToken

func ParseToken(tokenString, secret string) (jwt.MapClaims, error)

ParseToken validates a JWT string, defaulting the secret when empty, and returns claims.

func RequiredApiKeyHeader added in v0.2.57

func RequiredApiKeyHeader(expected string) gin.HandlerFunc

RequiredApiKeyHeader protects high-privilege routes without placing the key in URLs, access logs, browser history, or proxy query-string telemetry. An empty configured key fails closed.

func ValidatePasswordHash added in v0.2.60

func ValidatePasswordHash(encoded string) error

ValidatePasswordHash accepts Tikti's native bcrypt hashes and the bounded Argon2id PHC format used by the Code Foundry production bootstrap.

func ValidateRS256

func ValidateRS256(tokenString string, pub *rsa.PublicKey, issuer string, audience string) (jwt.MapClaims, error)

ValidateRS256 validates an RS256 JWT using a provided RSA public key.

func VerifyPassword added in v0.2.60

func VerifyPassword(encoded string, password string) bool

VerifyPassword compares a password against a supported bounded hash.

Types

type JWK

type JWK struct {
	Kty string `json:"kty"`
	Kid string `json:"kid"`
	Use string `json:"use"`
	Alg string `json:"alg"`
	N   string `json:"n"`
	E   string `json:"e"`
}

type JWKS

type JWKS struct {
	Keys []JWK `json:"keys"`
}

func BuildJWKS

func BuildJWKS(key *rsa.PrivateKey, kid string) (*JWKS, error)

func (*JWKS) Marshal

func (j *JWKS) Marshal() ([]byte, error)

Jump to

Keyboard shortcuts

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