userstore

package
v0.0.0-...-f1188b4 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIncorrectPassword = fmt.Errorf("%w (incorrect password)", ErrInvalidLogin)
View Source
var ErrInvalidLDAPAttributeMapping = errors.New("invalid LDAP attribute mapping")
View Source
var ErrInvalidLogin = errors.New("invalid login")
View Source
var ErrUserNotFound = fmt.Errorf("%w (user not found)", ErrInvalidLogin)
View Source
var StaticUpdateTime time.Time = time.Now()

Functions

This section is empty.

Types

type Backend

type Backend interface {
	LookupUser(subject string) (*User, error)
	CheckPassword(email string, password string) error
	Ping(ctx context.Context) error
}

func NewLDAPBackend

func NewLDAPBackend(config *LDAPConfig, logger *slog.Logger) (Backend, error)

func NewStaticBackend

func NewStaticBackend(users []StaticUser, logger *slog.Logger) (Backend, error)

type LDAPAttributeMapping

type LDAPAttributeMapping struct {
	User struct {
		Subject string `toml:"subject"`
		Profile struct {
			Name              string `toml:"name"`
			GivenName         string `toml:"given_name"`
			FamilyName        string `toml:"family_name"`
			MiddleName        string `toml:"middle_name"`
			Nickname          string `toml:"nickname"`
			Profile           string `toml:"profile"`
			Picture           string `toml:"picture"`
			Website           string `toml:"website"`
			Birthdate         string `toml:"birthdate"`
			Zoneinfo          string `toml:"zoneinfo"`
			Locale            string `toml:"locale"`
			PreferredUsername string `toml:"preferred_username"`
			UpdatedAt         string `toml:"update_at"`
		} `toml:"profile"`
		Address struct {
			Formatted  string `toml:"formatted"`
			Street     string `toml:"street"`
			Locality   string `toml:"locality"`
			Region     string `toml:"region"`
			PostalCode string `toml:"postal_code"`
			Country    string `toml:"country"`
		} `toml:"address"`
		Phone struct {
			Number string `toml:"number"`
		} `toml:"phone"`
		Email struct {
			Address string `toml:"address"`
		} `toml:"email"`
		Groups string `toml:"groups"`
	} `toml:"user"`
	Group struct {
		Name    string `toml:"name"`
		Members string `toml:"members"`
	} `toml:"group"`
}

func LDAPActiveDirectoryMapping

func LDAPActiveDirectoryMapping() *LDAPAttributeMapping

func LDAPOpenLDAPMapping

func LDAPOpenLDAPMapping() *LDAPAttributeMapping

func (*LDAPAttributeMapping) Validate

func (mapping *LDAPAttributeMapping) Validate() error

type LDAPConfig

type LDAPConfig struct {
	URLs         []string
	BindDN       string
	BindPassword string
	UserSearch   LDAPSearchConfig
	GroupSearch  LDAPSearchConfig
	Mapping      *LDAPAttributeMapping
}

type LDAPSearchConfig

type LDAPSearchConfig struct {
	BaseDN       string
	Scope        int
	DerefAliases int
	Filter       string
}

type StaticUser

type StaticUser struct {
	Subject  string
	Password string
	Profile  StaticUserProfile
	Address  StaticUserAddress
	Phone    StaticUserPhone
	Email    StaticUserEmail
	Groups   []string
}

type StaticUserAddress

type StaticUserAddress struct {
	Formatted  string
	Street     string
	Locality   string
	Region     string
	PostalCode string
	Country    string
}

type StaticUserEmail

type StaticUserEmail struct {
	Address string
}

type StaticUserPhone

type StaticUserPhone struct {
	Number string
}

type StaticUserProfile

type StaticUserProfile struct {
	Name              string
	GivenName         string
	FamilyName        string
	MiddleName        string
	Nickname          string
	Profile           string
	Picture           string
	Website           string
	Birthdate         string
	Zoneinfo          string
	Locale            string
	PreferredUsername string
}

type User

type User struct {
	Subject string
	Profile UserProfile
	Address UserAddress
	Phone   UserPhone
	Email   UserEmail
	Groups  []string
}

func (*User) SetUserInfo

func (user *User) SetUserInfo(userInfo *oidc.UserInfo, scopes []string)

type UserAddress

type UserAddress struct {
	Formatted  string
	Street     string
	Locality   string
	Region     string
	PostalCode string
	Country    string
}

type UserEmail

type UserEmail struct {
	Address  string
	Verified bool
}

type UserPhone

type UserPhone struct {
	Number   string
	Verified bool
}

type UserProfile

type UserProfile struct {
	Name              string
	GivenName         string
	FamilyName        string
	MiddleName        string
	Nickname          string
	Profile           string
	Picture           string
	Website           string
	Birthdate         string
	Zoneinfo          string
	Locale            language.Tag
	PreferredUsername string
	UpdatedAt         time.Time
}

Jump to

Keyboard shortcuts

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