auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package auth implements the small bits of PostgreSQL's authentication flow that we support: cleartext password and MD5. SCRAM is intentionally stubbed out; see scram_todo.go.

Index

Constants

View Source
const (
	MechSCRAMSHA256     = "SCRAM-SHA-256"
	MechSCRAMSHA256Plus = "SCRAM-SHA-256-PLUS" // channel binding; not implemented
)

Variables

This section is empty.

Functions

func MD5Password

func MD5Password(user, password string, salt []byte) string

MD5Password returns the "md5"+hex(md5(hex(md5(password+user))+salt)) form expected by the server for AuthRequestMD5. See the comment in src/backend/libpq/crypt.c for the canonical recipe.

func PickMechanism

func PickMechanism(body []byte) (string, error)

PickMechanism scans the NUL-terminated mechanism list from the server's AuthSASL message and picks the strongest one we support.

Types

type SCRAM

type SCRAM struct {
	// contains filtered or unexported fields
}

SCRAM holds the per-handshake state.

func NewSCRAM

func NewSCRAM(password string) (*SCRAM, error)

NewSCRAM seeds a SCRAM handshake. The caller drives it via Step1/Step2/Verify.

func (*SCRAM) ClientFinal

func (s *SCRAM) ClientFinal(serverFirst []byte) ([]byte, error)

ClientFinal consumes the server-first-message and returns the client-final-message. After this, Verify() must be called with the server-final-message body.

func (*SCRAM) ClientFirst

func (s *SCRAM) ClientFirst() []byte

ClientFirst returns the client-first-message body (no GS2 channel binding).

func (*SCRAM) Verify

func (s *SCRAM) Verify(serverFinal []byte) error

Verify checks the server-final-message ("v=<base64(ServerSignature)>").

Jump to

Keyboard shortcuts

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