Documentation ¶
Index ¶
- Constants
- Variables
- func CCrypt(key, salt string) string
- func IsTransactionIsolationLevel(level string) bool
- type AuthenticationInterface
- type CredentialsInterface
- type DefaultSalter
- type ParserInterface
- type Passworder
- func (passworder *Passworder) ChangePassword(plain string) (e error)
- func (passworder *Passworder) GetCost() int
- func (passworder *Passworder) GetHashType() string
- func (passworder *Passworder) GetPasswordHash() string
- func (passworder *Passworder) GetSalt() string
- func (passworder *Passworder) GetSalter() SalterInterface
- func (passworder *Passworder) HasChanged() bool
- func (passworder *Passworder) SetCost(to int)
- func (passworder *Passworder) SetSalter(to SalterInterface)
- func (passworder *Passworder) TestPassword(plain string) bool
- type PassworderInterface
- type SalterInterface
- type Sql
- func (sql *Sql) Add(user UserInterface) (e error)
- func (sql *Sql) Begin()
- func (sql *Sql) Close() error
- func (sql *Sql) Commit()
- func (sql *Sql) Get(name string) (bool, UserInterface)
- func (sql *Sql) IsAuthenticated(name, password string) bool
- func (sql *Sql) Modify(user UserInterface) (e error)
- func (sql *Sql) New(user, password string) (UserInterface, error)
- func (sql *Sql) Next() (UserInterface, error)
- func (sql *Sql) Remove(user UserInterface) (e error)
- func (sql *Sql) Reset()
- func (sql *Sql) Rollback()
- func (sql *Sql) SetTransactionIsolationLevel(to string)
- type SqlConfig
- type TransactionInterface
- type Unix
- func (unix *Unix) Add(user UserInterface) (e error)
- func (unix *Unix) Close() (e error)
- func (unix *Unix) Get(name string) (found bool, user UserInterface)
- func (unix *Unix) IsAuthenticated(name, password string) bool
- func (unix *Unix) Modify(user UserInterface) (e error)
- func (unix *Unix) New(user, password string) (UserInterface, error)
- func (unix *Unix) Next() (user UserInterface, e error)
- func (unix *Unix) Remove(user UserInterface) (e error)
- func (unix *Unix) Reset()
- type UnixPassworder
- type UnixUser
- type User
- type UserInterface
Constants ¶
View Source
const ( // DEBUG = true DEBUG = false DEFAULT_SALT_LENGTH = 12 BCRYPT_DEFAULT_COST = 10 TRANSACTION_READ_UNCOMMITTED = "READ UNCOMMITTED" TRANSACTION_READ_COMMITTED = "READ COMMITTED" TRANSACTION_REPEATABLE_READ = "REPEATABLE READ" TRANSACTION_SERIALIZE = "SERIALIZE" )
Variables ¶
View Source
var EOFError = io.EOF
View Source
var EmptyError = errors.New("empty argument!")
View Source
var FileNotExistsError = errors.New("File doesn't exists!")
View Source
var InvalidHashFormatError = errors.New("Invalid Hash Format!")
View Source
var InvalidUnixFormatError = errors.New("Invalid Unix password Format!")
View Source
var PasswordEmptyError = errors.New("Password is empty!")
View Source
var PlainPasswordNotAvailableError = errors.New("Plain Password wasn't saved!")
View Source
var TransactionAbortedError = errors.New("Transaction aborted!")
View Source
var UnexpectedFileFormatError = errors.New("Unexpected file format!")
View Source
var UnknownHashError = errors.New("Hash unknown!")
View Source
var UserDoesntExistError = errors.New("User does not exist!")
View Source
var UserExistsError = errors.New("User exists!")
Functions ¶
Types ¶
type AuthenticationInterface ¶
type CredentialsInterface ¶
type CredentialsInterface interface { AuthenticationInterface // Get a user by string Get(user string) (bool, UserInterface) // create a new user, but do not commit that user yet New(user, password string) (UserInterface, error) // add a new user // see New() Add(user UserInterface) error // modify existing user // get the user via Get() and change that user Modify(user UserInterface) error // remove a user // take the user from Get() Remove(user UserInterface) error // read next user // always call Reset() before // always call Reset() after finished Next() (UserInterface, error) // must be called when finished with Next() Reset() // close it Close() error }
type DefaultSalter ¶
type DefaultSalter struct {
// contains filtered or unexported fields
}
func NewDefaultSalter ¶
func NewDefaultSalter() *DefaultSalter
func (*DefaultSalter) GetSalt ¶
func (salt *DefaultSalter) GetSalt() string
func (*DefaultSalter) NewSalt ¶
func (salt *DefaultSalter) NewSalt() (random string, e error)
func (*DefaultSalter) SetSalt ¶
func (salt *DefaultSalter) SetSalt(to string)
func (*DefaultSalter) SetSaltLength ¶
func (salt *DefaultSalter) SetSaltLength(to uint8)
type ParserInterface ¶
type ParserInterface interface {
// contains filtered or unexported methods
}
type Passworder ¶
type Passworder struct {
// contains filtered or unexported fields
}
default Passworder uses Bcrypt, cant do nothing else
func NewPassworder ¶
func NewPassworder() *Passworder
func NewPassworderParse ¶
func NewPassworderParse(from string) (*Passworder, error)
func NewPassworderParsed ¶
func NewPassworderParsed(hash, hashType, salt string) *Passworder
func (*Passworder) ChangePassword ¶
func (passworder *Passworder) ChangePassword(plain string) (e error)
func (*Passworder) GetCost ¶
func (passworder *Passworder) GetCost() int
func (*Passworder) GetHashType ¶
func (passworder *Passworder) GetHashType() string
func (*Passworder) GetPasswordHash ¶
func (passworder *Passworder) GetPasswordHash() string
func (*Passworder) GetSalt ¶
func (passworder *Passworder) GetSalt() string
func (*Passworder) GetSalter ¶
func (passworder *Passworder) GetSalter() SalterInterface
func (*Passworder) HasChanged ¶
func (passworder *Passworder) HasChanged() bool
func (*Passworder) SetCost ¶
func (passworder *Passworder) SetCost(to int)
func (*Passworder) SetSalter ¶
func (passworder *Passworder) SetSalter(to SalterInterface)
func (*Passworder) TestPassword ¶
func (passworder *Passworder) TestPassword(plain string) bool
type PassworderInterface ¶
type PassworderInterface interface { // test current password hash against plain string TestPassword(plain string) bool // change password // remeber to use salt! ChangePassword(to string) error // has this passworder changed HasChanged() bool // get current password hash GetPasswordHash() string // get current salt GetSalt() string // get hash type GetHashType() string // contains filtered or unexported methods }
type SalterInterface ¶
type Sql ¶
type Sql struct {
// contains filtered or unexported fields
}
func (*Sql) Add ¶
func (sql *Sql) Add(user UserInterface) (e error)
func (*Sql) IsAuthenticated ¶
func (*Sql) Modify ¶
func (sql *Sql) Modify(user UserInterface) (e error)
func (*Sql) Next ¶
func (sql *Sql) Next() (UserInterface, error)
func (*Sql) Remove ¶
func (sql *Sql) Remove(user UserInterface) (e error)
func (*Sql) SetTransactionIsolationLevel ¶
type TransactionInterface ¶
type TransactionInterface interface { Begin() SetTransactionIsolationLevel(to string) Commit() Rollback() }
type Unix ¶
type Unix struct {
// contains filtered or unexported fields
}
reads and modifys /etc/shadow format rewrites entire file on Add(), Modify() and Remove() calls writes are done to a temp file which is then moved
func (*Unix) Add ¶
func (unix *Unix) Add(user UserInterface) (e error)
writes to a temp file and then trys to move that temp file
func (*Unix) IsAuthenticated ¶
func (*Unix) Modify ¶
func (unix *Unix) Modify(user UserInterface) (e error)
func (*Unix) Next ¶
func (unix *Unix) Next() (user UserInterface, e error)
func (*Unix) Remove ¶
func (unix *Unix) Remove(user UserInterface) (e error)
type UnixPassworder ¶
type UnixPassworder struct { Passworder // contains filtered or unexported fields }
reads and creates passwords used in /etc/shadow only supports md5, sha256 and sha512 while parsing requires salt
func NewUnixPassworder ¶
func NewUnixPassworder() *UnixPassworder
func NewUnixPassworderFromString ¶
func NewUnixPassworderFromString(from string) *UnixPassworder
func NewUnixPassworderParse ¶
func NewUnixPassworderParse(from string) (*UnixPassworder, error)
func (*UnixPassworder) ChangePassword ¶
func (passworder *UnixPassworder) ChangePassword(to string) (e error)
func (*UnixPassworder) TestPassword ¶
func (passworder *UnixPassworder) TestPassword(plain string) bool
type UnixUser ¶
type UnixUser struct { User // contains filtered or unexported fields }
func CreateUnixUser ¶
func NewUnixUser ¶
type User ¶
type User struct {
// contains filtered or unexported fields
}
func CreateUser ¶
func (*User) ChangePassword ¶
func (*User) GetPasswordHash ¶
func (*User) GetPassworder ¶
func (user *User) GetPassworder() PassworderInterface
func (*User) HasChanged ¶
type UserInterface ¶
type UserInterface interface { // get user name GetName() string // get passworder GetPassworder() PassworderInterface // change password // set hasChanged ChangePassword(to string) error // get current password hash // shortcut for user.GetPassworder().GetPasswordHash() GetPasswordHash() string // has this user been changed HasChanged() bool // contains filtered or unexported methods }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.