callback

package
v7.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Overview

Package callback provides types for handling authentication callbacks. Use the predefined callback handlers to process callbacks received from Access Management's authentication framework or use the Handler interface to provide your own handler.

This is an example of how to create your own callback handler:

type ThingHandler struct {
    ThingInput string
}

func (h ThingHandler) Handle(cb callback.Callback) (bool, error) {
    if cb.Type != "ThingCallback" {
        return false, nil
    }
    cb.Input[0].Value = h.ThingInput
    return true, nil
}

The handler can then be used during the authentication process of a thing or session:

builder.Thing().HandleCallbacksWith(ThingHandler{ThingInput: "value"})

Index

Constants

View Source
const (
	// Authentication callback names
	TypeNameCallback        = "NameCallback"
	TypePasswordCallback    = "PasswordCallback"
	TypeTextInputCallback   = "TextInputCallback"
	TypeHiddenValueCallback = "HiddenValueCallback"

	// Thing types used with registration callback
	TypeDevice  ThingType = "device"
	TypeService ThingType = "service"
	TypeGateway ThingType = "gateway"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticateHandler

type AuthenticateHandler struct {
	Audience string
	ThingID  string
	KeyID    string
	Key      crypto.Signer
	Claims   func() interface{}
}

AuthenticateHandler handles the callback received from the Authenticate Thing tree node.

func (AuthenticateHandler) Handle

func (h AuthenticateHandler) Handle(cb Callback) (bool, error)

type Callback

type Callback struct {
	Type   string  `json:"type,omitempty"`
	Output []Entry `json:"output,omitempty"`
	Input  []Entry `json:"input,omitempty"`
}

Callback describes an AM callback request and response structure.

func (Callback) ID

func (c Callback) ID() string

ID will verify that the callback is a HiddenValueCallback and return the ID value if one exists.

func (Callback) String

func (c Callback) String() string

type Entry

type Entry struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
}

Entry represents an Input or Output Entry in a Callback.

func (Entry) String

func (e Entry) String() string

type Handler

type Handler interface {
	// Handle the callback by modifying it. Return true if the callback was handled.
	Handle(cb Callback) (bool, error)
}

Handler is an interface for an AM callback handler.

func SoftwareStatementHandler added in v7.2.0

func SoftwareStatementHandler(softwareStatement string) Handler

SoftwareStatementHandler creates a callback handler capable of handling Software Statement registration callbacks.

type JWTPoPHandler added in v7.2.0

type JWTPoPHandler struct {
	AuthenticateHandler
	RegisterHandler
}

JWTPoPHandler handles the JWT Proof of Possession callbacks received from the Register and Authenticate Thing tree nodes.

func ProofOfPossessionHandler added in v7.2.0

func ProofOfPossessionHandler(thingID, audience, keyID string, key crypto.Signer) JWTPoPHandler

ProofOfPossessionHandler creates a callback handler capable of handling JWT Proof of Possession registration and authentication callbacks.

func (JWTPoPHandler) Handle added in v7.2.0

func (h JWTPoPHandler) Handle(cb Callback) (bool, error)

func (JWTPoPHandler) WithCertificate added in v7.2.0

func (h JWTPoPHandler) WithCertificate(certificates []*x509.Certificate) JWTPoPHandler

WithCertificate adds a certificate chain to the JWTPoPHandler.

func (JWTPoPHandler) WithClaims added in v7.2.0

func (h JWTPoPHandler) WithClaims(claims func() interface{}) JWTPoPHandler

WithClaims adds additional claims to the JWTPoPHandler.

type NameHandler

type NameHandler struct {
	// Name\Username\ID for the identity
	Name string
}

NameHandler handles an AM Username Collector callback.

func (NameHandler) Handle

func (h NameHandler) Handle(cb Callback) (bool, error)

type PasswordHandler

type PasswordHandler struct {
	// Password for the identity
	Password string
}

PasswordHandler handles an AM Password Collector callback.

func (PasswordHandler) Handle

func (h PasswordHandler) Handle(cb Callback) (bool, error)

type RegisterHandler

type RegisterHandler struct {
	Audience          string
	ThingID           string
	ThingType         ThingType
	KeyID             string
	Key               crypto.Signer
	Certificates      []*x509.Certificate
	Claims            func() interface{}
	SoftwareStatement string
}

RegisterHandler handles the callback received from the Register Thing tree node.

func (RegisterHandler) Handle

func (h RegisterHandler) Handle(cb Callback) (bool, error)

type ThingType

type ThingType string

ThingType describes the type of thing and is stored with the digital identity during registration.

Jump to

Keyboard shortcuts

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