auth: github.com/whawty/auth/sasl Index | Files

package sasl

import "github.com/whawty/auth/sasl"

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

Index

Package Files

sasl.go sasl_encoding.go

Constants

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

type AuthCB Uses

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 Uses

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 Uses

func NewClient(socketpath string) (c *Client)

NewClient creates a client struct.

func (*Client) Auth Uses

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 Uses

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

Request contains all values for a saslauthd authentication request.

func (*Request) Decode Uses

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

Decode reads a request from reader and decodes it.

func (*Request) Encode Uses

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

Encode encodes and writes a request to writer.

func (*Request) Marshal Uses

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 Uses

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

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

type Response Uses

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 Uses

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

Decode reads a response from reader and decodes it.

func (*Response) Encode Uses

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

Encode encodes and writes a response to writer.

func (*Response) Marshal Uses

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 Uses

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

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

type Server Uses

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 Uses

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 Uses

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 Uses

func (s *Server) Run() error

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

Package sasl imports 8 packages (graph) and is imported by 1 packages. Updated 2017-07-08. Refresh now. Tools for package owners.