sasl

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package sasl is based on code from the github.com/emersion/go-sasl package at commit 4132e15e133dd337ee91a3b320fa6c0596caa819. Specifically, code was copied from these files:

https://github.com/emersion/go-sasl/blob/4132e15e133dd337ee91a3b320fa6c0596caa819/xoauth2.go https://github.com/emersion/go-sasl/blob/4132e15e133dd337ee91a3b320fa6c0596caa819/sasl.go

This package restores support for the XOAUTH2 authentication mechanism that was removed from the upstream project per https://github.com/emersion/go-sasl/issues/18.

Index

Constants

View Source
const Xoauth2 = "XOAUTH2"

Xoauth2 is the IMAP authentication mechanism name.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Begins SASL authentication with the server. It returns the
	// authentication mechanism name and "initial response" data (if required by
	// the selected mechanism). A non-nil error causes the client to abort the
	// authentication attempt.
	//
	// A nil ir value is different from a zero-length value. The nil value
	// indicates that the selected mechanism does not use an initial response,
	// while a zero-length value indicates an empty initial response, which must
	// be sent to the server.
	Start() (mech string, ir []byte, err error)

	// Continues challenge-response authentication. A non-nil error causes
	// the client to abort the authentication attempt.
	Next(challenge []byte) (response []byte, err error)
}

Client interface to perform challenge-response authentication.

func NewXoauth2Client

func NewXoauth2Client(username, token string) Client

NewXoauth2Client provides an implementation of the XOAUTH2 authentication mechanism, as described in https://developers.google.com/gmail/xoauth2_protocol and https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth#sasl-xoauth2

NOTE: The required base64 encoding of the XOAUTH2 string is performed by the emersion/go-imap library as part of submitting the AUTHENTICATE command.

type Xoauth2Error

type Xoauth2Error struct {
	Status  string `json:"status"`
	Schemes string `json:"schemes"`
	Scope   string `json:"scope"`
}

Xoauth2Error represents an error encountered during an XOAUTH2 authentication attempt.

func (*Xoauth2Error) Error

func (err *Xoauth2Error) Error() string

Error implements the stdlib error interface.

Jump to

Keyboard shortcuts

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