Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AuthifyDB ¶
type AuthifyDB struct {
// contains filtered or unexported fields
}
func NewAuthifyDB ¶
func NewAuthifyDB(connString string, cfg StoreConfig) (*AuthifyDB, error)
This function takes in a connection string and a table name. It initializes a connection with the database, and sets its context as context.Background() After that, it attempts to create table if it does not exist with the passed tablename and config in the store.yml file. Documentation for pgx package: https://pkg.go.dev/github.com/jackc/pgx/v5
func (*AuthifyDB) CreateUser ¶
This function takes in username and password It creates the username with hashed password and provided information, as per config in database Noteworthy that the cost passed to GenerateFromPassword function is the default cost (10) Documentation for bcrypt: https://pkg.go.dev/golang.org/x/crypto/bcrypt
func (*AuthifyDB) GetUserInfo ¶
This function takes in the user identifier and password and returns info of user after password validation uses bcrypt's CompareHashAndPassword function for password validation
func (*AuthifyDB) StoreConfig ¶
func (db *AuthifyDB) StoreConfig() StoreConfig
type ColumnConfig ¶
type InMemoryUserStore ¶
type InMemoryUserStore struct {
// contains filtered or unexported fields
}
InMemoryUserStore is a config-driven, in-memory implementation of Store
func NewInMemoryUserStore ¶
func NewInMemoryUserStore(cfg StoreConfig) *InMemoryUserStore
NewInMemoryUserStore initializes a new in-memory store using table config
func (*InMemoryUserStore) CreateUser ¶
func (m *InMemoryUserStore) CreateUser(data map[string]any) error
CreateUser creates a user using dynamic fields defined in config
func (*InMemoryUserStore) GetUserInfo ¶
func (m *InMemoryUserStore) GetUserInfo(username, password string) (map[string]any, error)
GetUserInfo authenticates and returns non-hidden user fields
func (*InMemoryUserStore) StoreConfig ¶
func (m *InMemoryUserStore) StoreConfig() StoreConfig
StoreConfig exposes the schema config
type StoreConfig ¶
type StoreConfig struct {
Name string `yaml:"name"`
AutoCreate bool `yaml:"auto_create"`
Columns map[string]ColumnConfig `yaml:"columns"`
}