Help us shape the future of Go! Take the 2026 Go Developer Survey

jwtmint

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package jwtmint turns function results of one composite type into signed JWTs (PostGraphile's pgJwtType): a function returning schema.type yields an HS256 token string whose claims are the composite's fields; an exp field becomes the token expiry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mint

func Mint(o Options, raw json.RawMessage, set bool) (json.RawMessage, error)

Mint signs one claims object (or, with set, each element of an array of them) rendered as JSON, returning the JSON string(s). JSON null stays null.

func Sign

func Sign(o Options, claims map[string]any) (string, error)

Sign builds the HS256 token for one claims map: nil-valued claims are dropped and Issuer/Audience are added when set.

Types

type Options

type Options struct {
	Schema   string // pg schema of the composite, e.g. "public"
	Type     string // composite type name, e.g. "jwt"
	Secret   string
	Issuer   string
	Audience string
}

Options selects the composite type and the signing parameters.

func (Options) Enabled

func (o Options) Enabled() bool

Enabled reports whether minting is configured.

func (Options) MintsFunction

func (o Options) MintsFunction(f *introspect.Function) bool

MintsFunction reports whether f's return type is the mint composite (or SETOF it).

Jump to

Keyboard shortcuts

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