challenges

package
v0.0.0-...-0ad28a9 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2020 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

* Copyright 2013–2020 Kullo GmbH * * This source code is licensed under the 3-clause BSD license. See LICENSE.txt * in the root directory of this source tree for details.

* Copyright 2013–2020 Kullo GmbH * * This source code is licensed under the 3-clause BSD license. See LICENSE.txt * in the root directory of this source tree for details.

* Copyright 2013–2020 Kullo GmbH * * This source code is licensed under the 3-clause BSD license. See LICENSE.txt * in the root directory of this source tree for details.

* Copyright 2013–2020 Kullo GmbH * * This source code is licensed under the 3-clause BSD license. See LICENSE.txt * in the root directory of this source tree for details.

* Copyright 2013–2020 Kullo GmbH * * This source code is licensed under the 3-clause BSD license. See LICENSE.txt * in the root directory of this source tree for details.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoApplicableChallengeTypeFound = errors.New("No applicable challenge type has been found")
View Source
var ErrNotApplicable = errors.New("Challenge is not applicable to given user")
View Source
var ErrReservationListIntegrity = errors.New("Data integrity error in CSV: code must not be empty.")
View Source
var ErrUserExists = errors.New("User already exists")
View Source
var ErrWrongOkmLength = errors.New("challenges: wrong OKM length")

Functions

func CheckChallenge

func CheckChallenge(clientAnswer *ChallengeClientAnswer, userExists bool, isLocalAddress bool) (bool, error)

Types

type BlockedChallenge

type BlockedChallenge struct {
}

func NewBlockedChallenge

func NewBlockedChallenge() BlockedChallenge

func (*BlockedChallenge) ChallengeNecessary

func (self *BlockedChallenge) ChallengeNecessary(address string) (bool, error)

func (*BlockedChallenge) CheckChallenge

func (self *BlockedChallenge) CheckChallenge(clientAnswer *ChallengeClientAnswer,
	userExists bool, isLocalAddress bool) (bool, error)

func (*BlockedChallenge) FillChallenge

func (self *BlockedChallenge) FillChallenge(challenge *Challenge, address string,
	userExists bool, isLocalAddress bool) error

func (*BlockedChallenge) Name

func (self *BlockedChallenge) Name() string

type Challenge

type Challenge struct {
	Type      string `json:"type"`
	User      string `json:"user"`
	Timestamp uint64 `json:"timestamp"`
	Text      string `json:"text"`
}

type ChallengeClientAnswer

type ChallengeClientAnswer struct {
	Address         string    `json:"address"`
	Challenge       Challenge `json:"challenge"`
	ChallengeAuth   string    `json:"challengeAuth"`
	ChallengeAnswer string    `json:"challengeAnswer"`
}

type ChallengeReply

type ChallengeReply struct {
	Challenge     Challenge `json:"challenge"`
	ChallengeAuth string    `json:"challengeAuth"`
}

func CreateChallenge

func CreateChallenge(address string, userExists bool, isLocalAddress bool) (*ChallengeReply, error)

type ChallengeType

type ChallengeType interface {
	// Returns the challenge name as used in Challenge.Type
	Name() string

	// Is this challenge required under the assumption that the address doesn't
	// exist and challenges are optional?
	ChallengeNecessary(address string) (bool, error)

	// Fill the fields of the challenge being passed in
	FillChallenge(challenge *Challenge, address string, userExists bool, isLocalAddress bool) error

	// Check the validity of the ChallengeAnswer field
	CheckChallenge(clientAnswer *ChallengeClientAnswer, userExists bool, isLocalAddress bool) (bool, error)
}

type CodeChallenge

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

func NewCodeChallenge

func NewCodeChallenge() CodeChallenge

func (*CodeChallenge) ChallengeNecessary

func (self *CodeChallenge) ChallengeNecessary(address string) (bool, error)

func (*CodeChallenge) CheckChallenge

func (self *CodeChallenge) CheckChallenge(clientAnswer *ChallengeClientAnswer,
	userExists bool, isLocalAddress bool) (bool, error)

func (*CodeChallenge) FillChallenge

func (self *CodeChallenge) FillChallenge(challenge *Challenge, address string,
	userExists bool, isLocalAddress bool) error

func (*CodeChallenge) Name

func (self *CodeChallenge) Name() string

type ReservationChallenge

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

func NewReservationChallenge

func NewReservationChallenge() ReservationChallenge

func (*ReservationChallenge) ChallengeNecessary

func (self *ReservationChallenge) ChallengeNecessary(address string) (bool, error)

func (*ReservationChallenge) CheckChallenge

func (self *ReservationChallenge) CheckChallenge(clientAnswer *ChallengeClientAnswer,
	userExists bool, isLocalAddress bool) (bool, error)

func (*ReservationChallenge) FillChallenge

func (self *ReservationChallenge) FillChallenge(challenge *Challenge, address string,
	userExists bool, isLocalAddress bool) error

func (*ReservationChallenge) Name

func (self *ReservationChallenge) Name() string

type ResetChallenge

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

func NewResetChallenge

func NewResetChallenge() ResetChallenge

func (*ResetChallenge) ChallengeNecessary

func (self *ResetChallenge) ChallengeNecessary(address string) (bool, error)

func (*ResetChallenge) CheckChallenge

func (self *ResetChallenge) CheckChallenge(clientAnswer *ChallengeClientAnswer,
	userExists bool, isLocalAddress bool) (bool, error)

func (*ResetChallenge) FillChallenge

func (self *ResetChallenge) FillChallenge(challenge *Challenge, address string,
	userExists bool, isLocalAddress bool) error

func (*ResetChallenge) Name

func (self *ResetChallenge) Name() string

Jump to

Keyboard shortcuts

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