Documentation
¶
Overview ¶
Package tacplus is a library for creating client and/or server TACACS+ applications.
Index ¶
- Constants
- type AcctReply
- type AcctRequest
- type AuthenContinue
- type AuthenReply
- type AuthenStart
- type AuthorRequest
- type AuthorResponse
- type Client
- func (c *Client) Close()
- func (c *Client) SendAcctRequest(ctx context.Context, req *AcctRequest) (*AcctReply, error)
- func (c *Client) SendAuthenStart(ctx context.Context, as *AuthenStart) (*AuthenReply, *ClientSession, error)
- func (c *Client) SendAuthorRequest(ctx context.Context, req *AuthorRequest) (*AuthorResponse, error)
- type ClientSession
- type ConnConfig
- type RequestHandler
- type Server
- type ServerConnHandler
- type ServerSession
- func (s *ServerSession) GetData(ctx context.Context, message string, noEcho bool) (*AuthenContinue, error)
- func (s *ServerSession) GetPass(ctx context.Context, message string) (*AuthenContinue, error)
- func (s *ServerSession) GetUser(ctx context.Context, message string) (*AuthenContinue, error)
- func (s *ServerSession) LocalAddr() net.Addr
- func (s *ServerSession) Log(v ...interface{})
- func (s *ServerSession) RemoteAddr() net.Addr
Constants ¶
const ( AuthenMethodNotSet = 0x00 AuthenMethodNone = 0x01 AuthenMethodKRB5 = 0x02 AuthenMethodLine = 0x03 AuthenMethodEnable = 0x04 AuthenMethodLocal = 0x05 AuthenMethodTACACSPlus = 0x06 AuthenMethodGuest = 0x08 AuthenMethodRADIUS = 0x10 AuthenMethodKRB4 = 0x11 AuthenMethodRCMD = 0x20 )
AuthenMethod field values
const ( AuthenServiceNone = 0x0 AuthenServiceLogin = 0x1 AuthenServiceEnable = 0x2 AuthenServicePPP = 0x3 AuthenServiceARAP = 0x4 AuthenServicePT = 0x5 AuthenServiceRCMD = 0x6 AuthenServiceX25 = 0x7 AuthenServiceNASI = 0x8 AuthenServiceFWProxy = 0x9 )
AuthenService field values
const ( AuthenTypeASCII = 0x1 AuthenTypePAP = 0x2 AuthenTypeCHAP = 0x3 AuthenTypeARAP = 0x4 AuthenTypeMSCHAP = 0x5 )
AuthenType field values
const ( AuthenActionLogin = 0x1 AuthenActionChangePass = 0x2 AuthenActionSendPass = 0x3 AuthenActionSendAuth = 0x4 )
AuthenStart Action field values
const ( AuthenStatusPass = 0x1 AuthenStatusFail = 0x2 AuthenStatusGetData = 0x3 AuthenStatusGetUser = 0x4 AuthenStatusGetPass = 0x5 AuthenStatusRestart = 0x6 AuthenStatusError = 0x7 AuthenStatusFollow = 0x21 )
AuthenReply Status field values
const ( AuthorStatusPassAdd = 0x1 AuthorStatusPassRepl = 0x2 AuthorStatusFail = 0x10 AuthorStatusError = 0x11 AuthorStatusFollow = 0x21 )
AuthorResponse Status field values
const ( AcctFlagMore = 0x1 AcctFlagStart = 0x2 AcctFlagStop = 0x4 AcctFlagWatchdog = 0x8 )
AcctRequest Flags field values
const ( AcctStatusSuccess = 0x1 AcctStatusError = 0x2 AcctStatusFollow = 0x21 )
AcctReply Status field values
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcctRequest ¶
type AcctRequest struct { Flags uint8 AuthenMethod uint8 PrivLvl uint8 AuthenType uint8 AuthenService uint8 User string Port string RemAddr string Arg []string }
AcctRequest is a TACACS+ accounting request packet.
type AuthenContinue ¶
type AuthenContinue struct { Abort bool // session aborted Message string // reply from user or abort reason if Abort set }
AuthenContinue represents a TACACS+ authentication continue packet.
type AuthenReply ¶
AuthenReply is a TACACS+ authentication reply packet.
type AuthenStart ¶
type AuthenStart struct { Action uint8 PrivLvl uint8 AuthenType uint8 AuthenService uint8 User string Port string RemAddr string Data []byte }
AuthenStart is a TACACS+ authentication start packet.
type AuthorRequest ¶
type AuthorRequest struct { AuthenMethod uint8 PrivLvl uint8 AuthenType uint8 AuthenService uint8 User string Port string RemAddr string Arg []string }
AuthorRequest is a TACACS+ authorization request packet.
type AuthorResponse ¶
AuthorResponse is a TACACS+ authorization response packet.
type Client ¶
type Client struct { Addr string // TCP address of tacacs server. ConnConfig ConnConfig // TACACS+ connection configuration. // Optional DialContext function used to create the network connection. DialContext func(ctx context.Context, net, addr string) (net.Conn, error) // contains filtered or unexported fields }
Client is a TACACS+ client that connects to a single TACACS+ server.
If the Client's ConnConfig enables session multiplexing, the client will cache a single open connection for this purpose.
func (*Client) SendAcctRequest ¶
SendAcctRequest sends an AcctRequest to the server returning an AcctReply or error.
func (*Client) SendAuthenStart ¶
func (c *Client) SendAuthenStart(ctx context.Context, as *AuthenStart) (*AuthenReply, *ClientSession, error)
SendAuthenStart sends an AuthenStart to the server returning an AuthenReply and optional ClientSession or an error. If ClientSession is set it should be used to complete the current interactive authentication session.
func (*Client) SendAuthorRequest ¶
func (c *Client) SendAuthorRequest(ctx context.Context, req *AuthorRequest) (*AuthorResponse, error)
SendAuthorRequest sends an AuthorRequest to the server returning an AuthorResponse or error.
type ClientSession ¶
type ClientSession struct {
// contains filtered or unexported fields
}
ClientSession is a TACACS+ client session.
func (*ClientSession) Abort ¶
func (c *ClientSession) Abort(ctx context.Context, reason string) error
Abort sends a message back to the server aborting the session with the supplied reason.
func (*ClientSession) Continue ¶
func (c *ClientSession) Continue(ctx context.Context, msg string) (*AuthenReply, error)
Continue is used to send msg in response to a previous AuthenReply. A new AuthenReply or error is returned.
type ConnConfig ¶
type ConnConfig struct { Mux bool // Allow sessions to be multiplexed over a single connection LegacyMux bool // Allow session multiplexing without setting the single-connection header flag Secret []byte // Shared secret key IdleTimeout time.Duration // Time before closing an idle multiplexed connection with no sessions ReadTimeout time.Duration // Maximum time to read a packet (not including waiting for first byte) WriteTimeout time.Duration // Maximum time to write a packet // Optional function to log errors. If not defined log.Print will be used. Log func(v ...interface{}) }
ConnConfig specifies configuration parameters for a TACACS+ connection.
Setting Mux or LegacyMux allows multiplexing multiple sessions over a single network connection.
Mux allows mutliplexing only if the client and server set the single-connection header flag, as described in https://tools.ietf.org/html/draft-grant-tacacs-02.
LegacyMux assumes both ends allow multiplexing and doesn't set the single-connection header flag. LegacyMux overrides Mux if both are set.
A mismatch between the client and server on the multiplex type can cause problems. This software tries to deal gracefully with some of these situations. A server connection will accept multiplexed sessions even if multiplexing was not set or negotiated, but will close the connection immediately when there are no more sessions. A LegacyMux server connection will set the single-connection header flag if the client does, allowing a Mux client to multiplex to a LegacyMux server.
Timeout's are ignored if zero.
type RequestHandler ¶
type RequestHandler interface { HandleAuthenStart(ctx context.Context, a *AuthenStart, s *ServerSession) *AuthenReply HandleAuthorRequest(ctx context.Context, a *AuthorRequest, s *ServerSession) *AuthorResponse HandleAcctRequest(ctx context.Context, a *AcctRequest, s *ServerSession) *AcctReply }
A RequestHandler is used for processing the three different types of TACACS+ requests.
Each handle function takes a context and a request/start packet and returns a reply/response packet to be sent back to the client. A nil reply will close the session with no reply packet being sent. The supplied context is canceled if the underlying TACACS+ session or connection is closed.
HandleAuthenStart processes an authentication start, returning an optional reply. The ServerSession can be used by interactive sessions to prompt the user for more information before the final reply is returned.
HandleAuthorRequest processes an authorization request, returning an optional response.
HandleAcctRequest processes an accounting request, returning an optional reply.
type Server ¶
type Server struct { // ServeConn is run on incoming network connections. It must close the // supplied net.Conn when finsihed with it. ServeConn func(net.Conn) // Optional function to log errors. If not defined log.Print will be used. Log func(...interface{}) }
Server is a generic network server.
type ServerConnHandler ¶
type ServerConnHandler struct { Handler RequestHandler // TACACS+ request handler ConnConfig ConnConfig // TACACS+ connection config }
A ServerConnHandler serves TACACS+ requests on a network connection.
func (*ServerConnHandler) Serve ¶
func (h *ServerConnHandler) Serve(nc net.Conn)
Serve processes incoming TACACS+ requests on the network connection nc. A nil ServerConnHandler will close the connection without any processing.
type ServerSession ¶
type ServerSession struct {
// contains filtered or unexported fields
}
ServerSession is a TACACS+ Server Session.
func (*ServerSession) GetData ¶
func (s *ServerSession) GetData(ctx context.Context, message string, noEcho bool) (*AuthenContinue, error)
GetData requests the TACACS+ client prompt the user for data with the given message. If noEcho is set the client will not echo the users response as it is entered.
func (*ServerSession) GetPass ¶
func (s *ServerSession) GetPass(ctx context.Context, message string) (*AuthenContinue, error)
GetPass requests the TACACS+ client prompt the user for a password with the given message.
func (*ServerSession) GetUser ¶
func (s *ServerSession) GetUser(ctx context.Context, message string) (*AuthenContinue, error)
GetUser requests the TACACS+ client prompt the user for a username with the given message.
func (*ServerSession) LocalAddr ¶ added in v0.0.2
func (s *ServerSession) LocalAddr() net.Addr
LocalAddr returns the local network address for the session.
func (*ServerSession) Log ¶
func (s *ServerSession) Log(v ...interface{})
Log output using the connections ConnConfig Log function.
func (*ServerSession) RemoteAddr ¶ added in v0.0.2
func (s *ServerSession) RemoteAddr() net.Addr
RemoteAddr returns the remote network address (NAS IP Address) for the session.