auth

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpected = errors.New("unexpected call to auth provider")

Functions

This section is empty.

Types

type AIOServiceAccountToken

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

AIOServiceAccountToken impelements an enhanced authentication provider that reads a Kubernetes Service Account Token for the AIO Broker.

func NewAIOServiceAccountToken

func NewAIOServiceAccountToken(
	filename string,
) (*AIOServiceAccountToken, error)

NewAIOServiceAccountToken creates a new AIO SAT auth provider from the given filename.

func (*AIOServiceAccountToken) AuthSuccess

func (sat *AIOServiceAccountToken) AuthSuccess(requestReauth func())

func (*AIOServiceAccountToken) Close

func (sat *AIOServiceAccountToken) Close() error

func (*AIOServiceAccountToken) ContinueAuth

func (*AIOServiceAccountToken) ContinueAuth(*Values) (*Values, error)

func (*AIOServiceAccountToken) InitiateAuth

func (sat *AIOServiceAccountToken) InitiateAuth(bool) (*Values, error)

type Provider

type Provider interface {
	// InitiateAuth is called by the session client when an enhanced auth
	// exchange is initiated. An enhanced auth exchange is initiated when a new
	// MQTT connection is being created or when the Provider implementation
	// calls the requestReauth callback passed to it via AuthSuccess.
	//
	// `reauth` is true if this is a reauthentication on a live MQTT connection
	// and false it is on new MQTT connection.
	//
	// The return value is a pointer to a Values struct that contains values
	// that will be sent to the server via a CONNECT or AUTH packet.
	InitiateAuth(reauth bool) (*Values, error)

	// ContinueAuth is called by the session client when it receives an AUTH
	// packet from the server with reason code 0x18 (continue authentication).
	//
	// `values` contains the the values from the aforementioned AUTH packet.
	//
	// The return value is a pointer to to an Values struct that contains
	// values that will be sent to the server via an AUTH packet for this round
	// of the enhanced auth exchange.
	ContinueAuth(values *Values) (*Values, error)

	// AuthSuccess is called by the session client when it receives a CONNACK
	// or AUTH packet with a success reason code (0x00) after an enhanced auth
	// exchange was initiated.
	//
	// `requestReauth` is a callback that the Provider implementation may call
	// to tell the session client to initiate a reauthentication on the live
	// MQTT connection. Note that this function is valid for use for the entire
	// lifetime of the session client.
	AuthSuccess(requestReauth func())
}

Provider implements an MQTT enhanced authentication exchange. The provider may also implement io.Closer in order to clean up any resources when the client is shut down.

type Values

type Values struct {
	AuthMethod string
	AuthData   []byte
}

Values from AUTH packets sent to and received from the MQTT server.

Jump to

Keyboard shortcuts

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