subjectpass

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 14 Imported by: 2

Documentation

Overview

Package subjectpass implements a mechanism for reject an incoming message with a challenge to include a token in a next delivery attempt.

An SMTP server can reject a message with instructions to send another message, this time including a special token. The sender will receive a DSN, which will include the error message with instructions. By sending the message again with the token, as instructed, the SMTP server can recognize the token, verify it, and accept the message.

Index

Constants

This section is empty.

Variables

View Source
var (
	MetricGenerate stub.Counter    = stub.CounterIgnore{}
	MetricVerify   stub.CounterVec = stub.CounterVecIgnore{}
)
View Source
var (
	ErrMessage = errors.New("subjectpass: malformed message")
	ErrAbsent  = errors.New("subjectpass: no token found")
	ErrFrom    = errors.New("subjectpass: bad From")
	ErrInvalid = errors.New("subjectpass: malformed token")
	ErrVerify  = errors.New("subjectpass: verification failed")
	ErrExpired = errors.New("subjectpass: token expired")
)
View Source
var Explanation = "" /* 134-byte string literal not displayed */

Functions

func Generate

func Generate(elog *slog.Logger, mailFrom smtp.Address, key []byte, tm time.Time) string

Generate generates a token that is valid for "mailFrom", starting from "tm" and signed with "key".

The token is of the form: (pass:<signeddata>). Instructions to the sender should be to include this token in the Subject header of a new message.

func Verify

func Verify(elog *slog.Logger, r io.ReaderAt, key []byte, period time.Duration) (rerr error)

Verify parses "message" and checks if it includes a subjectpass token in its Subject header that is still valid (within "period") and signed with "key".

Types

This section is empty.

Jump to

Keyboard shortcuts

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