Documentation
¶
Overview ¶
Package tmplfunc holds the functions of vlatte's Go template engine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEnvNotAllowed = errors.New("is not allowed")
ErrEnvNotAllowed says a template read an environment variable its Env doesn't allow.
var ErrUnknownKey = errors.New("is not a signing key of the server")
ErrUnknownKey says a template named a signing key its Keys doesn't hold.
Functions ¶
func CheckKeySpecs ¶
CheckKeySpecs returns the error of the first spec ParseKeySpec refuses.
Types ¶
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env is the env function of templates: it reads the environment variables it allows, by exact, case-sensitive name, and no other. The zero Env allows none.
func (*Env) Allow ¶
Allow adds names to the variables e allows. A name that is empty or holds "=" or NUL is an error.
type KeySpec ¶
KeySpec is a signing key as a setting gives it: "kid=ALG", a key generated when it loads, or "kid=ALG:path", one read from a PEM file. It holds a path, never key material, so a configuration that shows it holds no secret.
func ParseKeySpec ¶
ParseKeySpec parses s. An empty kid, a missing or unsupported algorithm, such as HS256, or an empty path after ":" is an error.
type Keys ¶
type Keys struct {
// contains filtered or unexported fields
}
Keys is the jwt and jwks functions of templates: they sign with, and publish the public half of, the keys added to it, by kid. The zero Keys holds none. Nothing reads a private key back out of it.
func (*Keys) Add ¶
Add adds key as kid, to sign with alg. An empty or repeated kid, an algorithm the jose package refuses, such as HS256, or a key that doesn't fit alg is an error, which never holds key material.
func (*Keys) Check ¶
Check returns the error jwt or jwks would fail with when t runs, for the first kid given them as a literal that k doesn't hold, so a template can fail when it compiles. A kid read from data is checked when it runs.
func (*Keys) JWKS ¶
JWKS returns the JWK Set of the public halves of the keys kids, in that order, as JSON text.
func (*Keys) JWT ¶
JWT returns claims signed with the key kid, as a compact JWS whose header has the key's alg, the kid and typ JWT. claims is JSON text, such as a template wrote, or a value that marshals to a JSON object, such as fromJSON returns. The token holds those claims and no other: no exp or iat is added.