oauthgoutils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeJSON = "application/json; charset=utf-8"
)

Variables

This section is empty.

Functions

func FirstNonEmpty

func FirstNonEmpty(vals ...string) string

FirstNonEmpty returns the first non-empty string from the provided values.

func Get

func Get(key, def string) string

Get by default.

func MustRandom

func MustRandom(n int) string

MustRandom panics on error; for places where we already handle outer errors.

func ParseECKey

func ParseECKey(pemBytes []byte) (*ecdsa.PrivateKey, error)

ParseECKey parses PKCS8 or EC private key from PEM bytes.

func RandomStringURLSafe

func RandomStringURLSafe(n int) (string, error)

RandomStringURLSafe returns a URL-safe base64 string (no padding).

func WriteError

func WriteError(w http.ResponseWriter, status int, msg string, err error)

WriteError writes an error response as JSON.

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, v any)

WriteJSON writes a JSON response.

Types

type ApiError

type ApiError struct {
	Message string `json:"message"`
	Detail  string `json:"detail,omitempty"`
}

ApiError represents an error response.

type PKCE

type PKCE struct {
	// Verifier is a random string used to prove the client is the same that requested the authorization code.
	Verifier string
	// Challenge is the code challenge.
	Challenge string
	// Method is the code challenge method.
	Method string // S256
}

PKCE is a Proof Key for Code Exchange (RFC 7636)

func NewPKCE

func NewPKCE() (*PKCE, error)

NewPKCE creates a new PKCE.

Jump to

Keyboard shortcuts

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