Movatterモバイル変換


[0]ホーム

URL:


dovecotsasl

packagemodule
v0.0.0-...-c4699d7Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License:MITImports:15Imported by:1

Details

Repository

github.com/foxcpp/go-dovecot-sasl

Links

README

go-dovecot-sasl

go.dev reference

Go library implementing Dovecot authentication protocol 1.1.The library is based onemersion/go-sasl.

Examples

Client
s, err := net.Dial("unix", "/var/lib/dovecot/sasl.sock")if err != nil {    // Handle error.}cl := dovecotsasl.NewClient(s)err := cl.Do("SMTP",     sasl.NewPlainClient("", "foxcpp", "1234"),     dovecotsasl.RemoteIP(net.IPv4(1,2,3,4)),    dovecotsasl.Secured,)if err != nil {    // Nope!}// Authenticated!
Server
l, err := net.Listen("unix", "/var/lib/maddy/sasl.sock")if err != nil {    // Handle error.}var authenticator sasl.PlainAuthenticator = func(_, user, pass string) error {    if user == "foxcpp" && pass == "1234" {        return nil    }    return errors.New("nope!")}s := NewServer()s.AddMechanism("PLAIN", dovecotsasl.Mechanism{},     func(*dovecotsasl.AuthReq) sasl.Server {        return sasl.NewPlainServer(authenticator)    })go s.Serve(l)

License

MIT.

Documentation

Index

Constants

View Source
const (TempFail     = "temp_fail"AuthzFail    = "authz_fail"UserDisabled = "user_disabled"PassExpired  = "pass_expired")
View Source
const (Secured         = "secured"CertUsername    = "cert_username"ValidClientCert = "valid-client-cert"NoPenalty       = "no-penalty")

Constants for Client.Do params.Seehttps://wiki.dovecot.org/Design/AuthProtocol for description.

Variables

This section is empty.

Functions

funcLocalIP

func LocalIP(ipnet.IP)string

LocalIP formats local server IP for use in Client.Do params.

funcLocalPort

func LocalPort(iuint16)string

LocalIP formats local port for use in Client.Do params.

funcRemoteIP

func RemoteIP(ipnet.IP)string

LocalIP formats remote IP for use in Client.Do params.

funcRemotePort

func RemotePort(iuint16)string

LocalIP formats remote port for use in Client.Do params.

Types

typeAuthFail

type AuthFail struct {RequestIDstringCodeFailCodeReasonstring}

func (AuthFail)Error

func (afAuthFail) Error()string

typeAuthReq

type AuthReq struct {RequestIDstringMechanismstringServicestringLocalIPnet.IPLocalPortuint16RemoteIPnet.IPRemotePortuint16SecuredboolValidClientCertboolNoPenaltyboolCertUsernameboolIR []byte}

typeClient

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

funcNewClient

func NewClient(netConnnet.Conn) (*Client,error)

func (*Client)Close

func (cl *Client) Close()error

func (*Client)ConnInfo

func (c *Client) ConnInfo()ConnInfo

func (*Client)Do

func (c *Client) Do(servicestring, cl sasl.Client, extraParams ...string)error

Do performs SASL authentication using Dovecot SASL server and providedsasl.Client implementation.

typeConnInfo

type ConnInfo struct {CPID, SPIDstringCUIDstringCookiestringMechs map[string]Mechanism}

typeFailCode

type FailCodestring

typeMechanism

type Mechanism struct {AnonymousboolPlaintextboolDictonaryboolActiveboolForwardSecrecyboolMutualAuthboolPrivatebool}

typeServer

type Server struct {Log *log.Logger// contains filtered or unexported fields}

funcNewServer

func NewServer() *Server

func (*Server)AddMechanism

func (s *Server) AddMechanism(namestring, infoMechanism, handler func(*AuthReq) sasl.Server)

func (*Server)Close

func (s *Server) Close()error

func (*Server)Serve

func (s *Server) Serve(lnet.Listener)error

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp