Documentation ¶
Index ¶
- Constants
- func GetRandomChallenge() string
- type PasswordRegister
- func (reg *PasswordRegister) FulfilIntent(challenge, password string) bool
- func (reg *PasswordRegister) GetOutstandingIntents() map[string]*UnlockAttemptRPCClientInfo
- func (reg *PasswordRegister) GetUnlockPassword(ctx context.Context, req *unlocksvc.GetUnlockPasswordRequest) (*unlocksvc.GetUnlockPasswordResponse, error)
- func (reg *PasswordRegister) PostUnlockIntent(ctx context.Context, req *unlocksvc.PostUnlockIntentRequest) (*unlocksvc.PostUnlockIntentResponse, error)
- type UnlockAttemptRPCClientInfo
Constants ¶
const (
// MaxRandomChallengeLen is the maximum length accepted for a client-generated random challenge string.
MaxRandomChallengeLen = 64
)
Variables ¶
This section is empty.
Functions ¶
func GetRandomChallenge ¶
func GetRandomChallenge() string
GetRandomChallenge returns a randomly generated string that an RPC client may use as challenge string to identify its intent. The function uses the default PRNG source internally.
Types ¶
type PasswordRegister ¶
type PasswordRegister struct { unlocksvc.UnimplementedPasswordUnlockServiceServer // IntentsChallenge record the random string challenge generated by the client. They reside in an in-memory buffer, hence the capacity is // sufficient for a limited number of entries. // The identification of these challenge strings are stored in IntentIdentifications and kept in-sync. IntentsChallenge *datastruct.LeastRecentlyUsedBuffer // IntentIdentifications is a mapping between client's random string challenge and the identification information. The map is kept in-sync // with the elements stored in IntentsChallenge. IntentIdentifications map[string]*UnlockAttemptRPCClientInfo // FulfilledIntents is a mapping between client's random string challenge and the corresponding unlocking password in plain text. FulfilledIntents map[string]string // contains filtered or unexported fields }
PasswordRegister provides facilities for an instance of laitos program to register an intent of obtaining unlocking password for its config/data files, and then obtain the password after a user has honoured the intent.
func NewPasswordRegister ¶
func NewPasswordRegister(maxIntents, maxCallsPerSec int, logger *lalog.Logger) *PasswordRegister
NewPasswordRegister returns an initialised PasswordRegister.
func (*PasswordRegister) FulfilIntent ¶
func (reg *PasswordRegister) FulfilIntent(challenge, password string) bool
FulfilIntent memorises an unlocking password corresponding to a client generated challenge. The function returns true if an outstanding intent corresponds to the challenge, otherwise, it returns false and the password will be not be memorised.
func (*PasswordRegister) GetOutstandingIntents ¶
func (reg *PasswordRegister) GetOutstandingIntents() map[string]*UnlockAttemptRPCClientInfo
GetOutstandingIntents returns the identification records of outstanding unlocking intents that are yet to be fulfilled.
func (*PasswordRegister) GetUnlockPassword ¶
func (reg *PasswordRegister) GetUnlockPassword(ctx context.Context, req *unlocksvc.GetUnlockPasswordRequest) (*unlocksvc.GetUnlockPasswordResponse, error)
GetUnlockPassword retrieves an unlocking password a user has offered.
func (*PasswordRegister) PostUnlockIntent ¶
func (reg *PasswordRegister) PostUnlockIntent(ctx context.Context, req *unlocksvc.PostUnlockIntentRequest) (*unlocksvc.PostUnlockIntentResponse, error)
PostUnlockIntent registers an intent of obtaining unlocking password from a user.
type UnlockAttemptRPCClientInfo ¶
type UnlockAttemptRPCClientInfo struct { *unlocksvc.UnlockAttemptIdentification ClientIP string Time time.Time }
UnlockAttemptRPCClientInfo contains the identification information from an unlocking request along with network transport information about the client.