sasl

package
v0.0.0-...-53904ab Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package sasl implements the authentication protocol as used by salsauthd. saslauthd is part of the cyrus imap project: http://cyrusimap.org/

Index

Constants

View Source
const (
	// MaxRequestLength is the maximum length allowed for login, password
	// service and realm
	MaxRequestLength = 256
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthCB

type AuthCB func(login, password, service, realm string) (ok bool, msg string, err error)

AuthCB is the function signature of callbacks as used by the server to handle authentication requests.

type Client

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

Client holds all information needed to send and authentication request as well as to receive responses from saslauthd compatible servers. Use NewClient to create the socket.

func NewClient

func NewClient(socketpath string) (c *Client)

NewClient creates a client struct.

func (*Client) Auth

func (c *Client) Auth(login, password, service, realm string) (ok bool, msg string, err error)

Auth connects to the server socket and sends an authentication request.

type Request

type Request struct {
	Login    string
	Password string
	Service  string
	Realm    string
}

Request contains all values for a saslauthd authentication request.

func (*Request) Decode

func (r *Request) Decode(reader io.Reader) (err error)

Decode reads a request from reader and decodes it.

func (*Request) Encode

func (r *Request) Encode(writer io.Writer) error

Encode encodes and writes a request to writer.

func (*Request) Marshal

func (r *Request) Marshal() (data []byte, err error)

Marshal encodes the request values into a byte slice. The format is compatible to the requests as expected by salsauthd.

func (*Request) Unmarshal

func (r *Request) Unmarshal(data []byte) (err error)

Unmarshal decodes the request values from it's byte representation.

type Response

type Response struct {
	Result  bool
	Message string
}

Response holds the result as well as the message as returned by the authentication provider.

func (*Response) Decode

func (r *Response) Decode(reader io.Reader) (err error)

Decode reads a response from reader and decodes it.

func (*Response) Encode

func (r *Response) Encode(writer io.Writer) error

Encode encodes and writes a response to writer.

func (*Response) Marshal

func (r *Response) Marshal() (data []byte, err error)

Marshal encodes the response into a byte slice. The format is the same as used by salsauthd.

func (*Response) Unmarshal

func (r *Response) Unmarshal(data []byte) (err error)

Unmarshal decodes the response from the it's byte representation.

type Server

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

Server holds all information needed to run the server. Use NewServer to create the struct.

func NewServer

func NewServer(socketpath string, cb AuthCB) (s *Server, err error)

NewServer creates a server struct and starts listening on the unix socket as specified by socketpath. cb is the callback function which will get called for any authentication request.

func NewServerFromListener

func NewServerFromListener(ln *net.UnixListener, cb AuthCB) (s *Server, err error)

NewServerFromListener creates a server struct using a UnixListener specified by ln. cb is the callback function which will get called for any authentication request.

func (*Server) Run

func (s *Server) Run() error

Run actually runs the server. In calls Accept() on the server socket and runs go-routines for new connections.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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