client

package
v1.99.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package client implements the yarilo-auth TAB-delimited client protocol. All public methods are safe for use from a single goroutine; do not share a Client across goroutines without external synchronization.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthFailed   = errors.New("auth/client: authentication failed")
	ErrTempFail     = errors.New("auth/client: temporary backend failure")
	ErrUserNotFound = errors.New("auth/client: user not found")
)

Sentinel errors returned by Authenticate, Verify, and LookupUser.

Functions

This section is empty.

Types

type AuthResult

type AuthResult struct {
	Username  string
	Nologin   bool
	AllowNets string
	Token     string
}

AuthResult carries the fields from a successful AUTH OK response.

type Client

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

Client is a single persistent connection to yarilo-auth.

func Dial

func Dial(addr string, tlsCfg *tls.Config) (*Client, error)

Dial connects to addr (TCP or Unix socket) and performs the VERSION handshake. tlsCfg may be nil for plain (non-TLS) connections.

func (*Client) Authenticate

func (c *Client) Authenticate(username, password, service, remoteIP, sessionID string) (*AuthResult, error)

Authenticate sends an AUTH command for the given credentials and returns the result. remoteIP and sessionID may be empty strings (omitted from request).

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying connection.

func (*Client) LookupUser added in v1.57.0

func (c *Client) LookupUser(username string) (bool, error)

LookupUser sends a USER command to yarilo-auth and returns whether the user exists in the userdb. Returns ErrUserNotFound when the user is unknown, ErrTempFail on a transient backend error.

func (*Client) Verify

func (c *Client) Verify(token, username, sessionID string) (string, string, string, error)

Verify sends a VERIFY command and returns the username, session ID, and service bound to the token. username and sessionID are sent as binding claims — the server rejects the token if they don't match what was stored at issue time. Returns ErrAuthFailed when the token is unknown, expired, or the claims don't match.

Jump to

Keyboard shortcuts

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