auth_method_password

package
v0.51.5 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package auth_method_password implements password-based entity key derivation using scrypt with a blake3-derived deterministic salt from the username.

Index

Constants

View Source
const ConfigID = ControllerID

ConfigID is the string used to identify this config object.

View Source
const ControllerID = "auth/method/" + MethodID

ControllerID is the auth method controller ID.

View Source
const DefaultScryptN = 20

DefaultScryptN is the default scrypt N parameter (2^20).

View Source
const DefaultScryptP = 1

DefaultScryptP is the default scrypt p parameter.

View Source
const DefaultScryptR = 8

DefaultScryptR is the default scrypt r parameter.

View Source
const MethodID = "password"

MethodID is the auth method ID.

Variables

View Source
var Version = semver.MustParse("0.1.0")

Version is the version of the password method implementation.

Functions

func NewMethod

func NewMethod(
	ctx context.Context,
	le *logrus.Entry,
	handler auth_method.Handler,
) (auth_method.Method, error)

NewMethod constructs the password method as an auth method.

Types

type Config

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

Config is configuration for the auth method.

func (*Config) CloneMessageVT

func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Config) CloneVT

func (m *Config) CloneVT() *Config

func (*Config) EqualMessageVT

func (this *Config) EqualMessageVT(thatMsg any) bool

func (*Config) EqualVT

func (this *Config) EqualVT(that *Config) bool

func (*Config) EqualsConfig

func (c *Config) EqualsConfig(other config.Config) bool

EqualsConfig checks if the other config is equal.

func (*Config) GetConfigID

func (c *Config) GetConfigID() string

GetConfigID returns the unique string for this configuration type.

func (*Config) MarshalJSON

func (x *Config) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Config to JSON.

func (*Config) MarshalProtoJSON

func (x *Config) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Config message to JSON.

func (*Config) MarshalProtoText

func (x *Config) MarshalProtoText() string

func (*Config) MarshalToSizedBufferVT

func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Config) MarshalToVT

func (m *Config) MarshalToVT(dAtA []byte) (int, error)

func (*Config) MarshalVT

func (m *Config) MarshalVT() (dAtA []byte, err error)

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) Reset

func (x *Config) Reset()

func (*Config) SizeVT

func (m *Config) SizeVT() (n int)

func (*Config) String

func (x *Config) String() string

func (*Config) UnmarshalJSON

func (x *Config) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Config from JSON.

func (*Config) UnmarshalProtoJSON

func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Config message from JSON.

func (*Config) UnmarshalVT

func (m *Config) UnmarshalVT(dAtA []byte) error

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

type Factory

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

Factory constructs a password auth handler.

func NewFactory

func NewFactory(bus bus.Bus) *Factory

NewFactory builds a password auth factory.

func (*Factory) Construct

func (t *Factory) Construct(
	ctx context.Context,
	conf config.Config,
	opts controller.ConstructOpts,
) (controller.Controller, error)

Construct constructs the associated controller given configuration.

func (*Factory) ConstructConfig

func (t *Factory) ConstructConfig() config.Config

ConstructConfig constructs an instance of the controller configuration.

func (*Factory) GetConfigID

func (t *Factory) GetConfigID() string

GetConfigID returns the configuration ID for the controller.

func (*Factory) GetControllerID

func (t *Factory) GetControllerID() string

GetControllerID returns the unique ID for the controller.

func (*Factory) GetVersion

func (t *Factory) GetVersion() semver.Version

GetVersion returns the version of this controller.

type Parameters

type Parameters struct {

	// Salt is the salt used for key derivation.
	// 16 bytes, derived deterministically from the username via blake3.
	Salt []byte `protobuf:"bytes,1,opt,name=salt,proto3" json:"salt,omitempty"`
	// ScryptN is the scrypt N parameter (cost factor as a power of 2).
	// Default: 20 (2^20 = 1048576).
	ScryptN uint32 `protobuf:"varint,2,opt,name=scrypt_n,json=scryptN,proto3" json:"scryptN,omitempty"`
	// ScryptR is the scrypt r parameter (block size).
	// Default: 8.
	ScryptR uint32 `protobuf:"varint,3,opt,name=scrypt_r,json=scryptR,proto3" json:"scryptR,omitempty"`
	// ScryptP is the scrypt p parameter (parallelization).
	// Default: 1.
	ScryptP uint32 `protobuf:"varint,4,opt,name=scrypt_p,json=scryptP,proto3" json:"scryptP,omitempty"`
	// contains filtered or unexported fields
}

Parameters are stored with the user record.

func BuildParametersWithUsernamePassword

func BuildParametersWithUsernamePassword(username string, password []byte) (*Parameters, crypto.PrivKey, error)

BuildParametersWithUsernamePassword builds Parameters and derives an Ed25519 private key from a username and password.

The salt is derived deterministically: blake3.DeriveKey(context, username). No server-stored salt is needed.

func (*Parameters) CloneMessageVT

func (m *Parameters) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Parameters) CloneVT

func (m *Parameters) CloneVT() *Parameters

func (*Parameters) EqualMessageVT

func (this *Parameters) EqualMessageVT(thatMsg any) bool

func (*Parameters) EqualVT

func (this *Parameters) EqualVT(that *Parameters) bool

func (*Parameters) GetSalt

func (x *Parameters) GetSalt() []byte

func (*Parameters) GetScryptN

func (x *Parameters) GetScryptN() uint32

func (*Parameters) GetScryptP

func (x *Parameters) GetScryptP() uint32

func (*Parameters) GetScryptR

func (x *Parameters) GetScryptR() uint32

func (*Parameters) MarshalBlock

func (p *Parameters) MarshalBlock() ([]byte, error)

MarshalBlock marshals the parameters to binary.

func (*Parameters) MarshalJSON

func (x *Parameters) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Parameters to JSON.

func (*Parameters) MarshalProtoJSON

func (x *Parameters) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Parameters message to JSON.

func (*Parameters) MarshalProtoText

func (x *Parameters) MarshalProtoText() string

func (*Parameters) MarshalToSizedBufferVT

func (m *Parameters) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Parameters) MarshalToVT

func (m *Parameters) MarshalToVT(dAtA []byte) (int, error)

func (*Parameters) MarshalVT

func (m *Parameters) MarshalVT() (dAtA []byte, err error)

func (*Parameters) ProtoMessage

func (*Parameters) ProtoMessage()

func (*Parameters) Reset

func (x *Parameters) Reset()

func (*Parameters) SizeVT

func (m *Parameters) SizeVT() (n int)

func (*Parameters) String

func (x *Parameters) String() string

func (*Parameters) UnmarshalJSON

func (x *Parameters) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Parameters from JSON.

func (*Parameters) UnmarshalProtoJSON

func (x *Parameters) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Parameters message from JSON.

func (*Parameters) UnmarshalVT

func (m *Parameters) UnmarshalVT(dAtA []byte) error

func (*Parameters) Validate

func (p *Parameters) Validate() error

Validate validates the parameters.

type PasswordMethod

type PasswordMethod struct{}

PasswordMethod implements password-based auth via scrypt+blake3 KDF.

func NewPasswordMethod

func NewPasswordMethod() *PasswordMethod

NewPasswordMethod constructs the PasswordMethod.

func (*PasswordMethod) Authenticate

func (p *PasswordMethod) Authenticate(paramsi auth_method.Parameters, authSecretData []byte) (crypto.PrivKey, error)

Authenticate authenticates with existing auth parameters. authSecretData is the password bytes.

func (*PasswordMethod) Close

func (p *PasswordMethod) Close()

Close closes all resources related to the auth method.

func (*PasswordMethod) Execute

func (p *PasswordMethod) Execute(ctx context.Context) error

Execute executes the auth method.

func (*PasswordMethod) GetMethodID

func (p *PasswordMethod) GetMethodID() string

GetMethodID returns the auth method ID.

func (*PasswordMethod) UnmarshalParameters

func (p *PasswordMethod) UnmarshalParameters(data []byte) (auth_method.Parameters, error)

UnmarshalParameters unmarshals+validates parameters from binary.

Jump to

Keyboard shortcuts

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