pam

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package pam provides a wrapper for the PAM application API.

Index

Constants

View Source
const (
	// PromptEchoOff indicates the conversation handler should obtain a
	// string without echoing any text.
	PromptEchoOff ConvResponse = C.PAM_PROMPT_ECHO_OFF
	// PromptEchoOn indicates the conversation handler should obtain a
	// string while echoing text.
	PromptEchoOn = C.PAM_PROMPT_ECHO_ON
	// ErrorMsg indicates the conversation handler should display an
	// error message.
	ErrorMsg = C.PAM_ERROR_MSG
	// TextInfo indicates the conversation handler should display some
	// text.
	TextInfo = C.PAM_TEXT_INFO
)

Conversation handler style types.

View Source
const (
	// No Flags.
	NoFlag Flags = 0
	// Silent indicates that no messages should be emitted.
	Silent = C.PAM_SILENT
	// DisallowNullAuthtok indicates that authorization should fail
	// if the user does not have a registered authentication token.
	DisallowNullAuthtok = C.PAM_DISALLOW_NULL_AUTHTOK
	// EstablishCred indicates that credentials should be established
	// for the user.
	EstablishCred = C.PAM_ESTABLISH_CRED
	// DeleteCred inidicates that credentials should be deleted.
	DeleteCred = C.PAM_DELETE_CRED
	// ReinitializeCred indicates that credentials should be fully
	// reinitialized.
	ReinitializeCred = C.PAM_REINITIALIZE_CRED
	// RefreshCred indicates that the lifetime of existing credentials
	// should be extended.
	RefreshCred = C.PAM_REFRESH_CRED
	// ChangeExpiredAuthtok indicates that the authentication token
	// should be changed if it has expired.
	ChangeExpiredAuthtok = C.PAM_CHANGE_EXPIRED_AUTHTOK
)

PAM Flag types.

Variables

This section is empty.

Functions

func EndTransaction

func EndTransaction(t *Transaction)

EndTransaction cleans up the PAM handle and deletes the callback

Types

type ConvResponse

type ConvResponse int

ConvResponse is the type of message that the conversation handler should display.

type ConversationFunc

type ConversationFunc func(ConvResponse, string) (string, error)

ConversationFunc is an adapter to allow the use of ordinary functions as conversation callbacks.

func (ConversationFunc) PromptPassword

func (f ConversationFunc) PromptPassword(flag ConvResponse, msg string) (string, error)

PromptPassword is a conversation callback adapter.

type ConversationHandler

type ConversationHandler interface {
	// PromptPassword receives a message ConvResponse and a message string. If the
	// message ConvResponse is PromptEchoOff or PromptEchoOn then the function
	// should return a response string.
	PromptPassword(ConvResponse, string) (string, error)
}

ConversationHandler is an interface for objects that can be used as conversation callbacks during PAM authentication.

type Credential

type Credential struct {
	Username string
	Password string
}

Credential represents user provided credential

func (Credential) PAMAuthenticate

func (c Credential) PAMAuthenticate() error

PAMAuthenticate performs PAM authentication for the user credentials provided

func (Credential) PAMResponseHandler

func (c Credential) PAMResponseHandler(s ConvResponse, msg string) (string, error)

PAMResponseHandler handles the communication between PAM client and PAM module

func (Credential) PAMStartFunc

func (c Credential) PAMStartFunc() (*Transaction, error)

PAMStartFunc establishes the connection to PAM module

type Flags

type Flags int

Flags are inputs to various PAM functions than be combined with a bitwise or. Refer to the official PAM documentation for which flags are accepted by which functions.

type Transaction

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

Transaction is the application's handle for a PAM transaction.

func StartFunc

func StartFunc(service, user string, handler func(ConvResponse, string) (string, error)) (*Transaction, error)

StartFunc registers the handler func as a conversation handler.

func StartTransaction

func StartTransaction(service, user string, handler ConversationHandler) (*Transaction, error)

StartTransaction initiates a new PAM transaction. Returned transaction provides an interface to the remainder of the API.

func (*Transaction) Authenticate

func (t *Transaction) Authenticate(f Flags) error

Authenticate is used to authenticate the user. Valid flags: Silent, DisallowNullAuthtok

func (*Transaction) Error

func (t *Transaction) Error() string

Called when returning a transaction object for the return type as error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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