callback

package
v0.0.0-...-ee64981 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

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 string `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.

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{}
}

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