Documentation
¶
Index ¶
- func GetCADataSource(dbtype, datasource string, cacount int) string
- func GetNewAttributes(modifyAttrs, newAttrs []api.Attribute) []api.Attribute
- func MaskDBCred(str string) string
- func Migrate(db *DB, srvLevels *Levels) error
- type DB
- type FabricCADB
- type FabricCATx
- type Levels
- type User
- func (u *User) GetAffiliationPath() []string
- func (u *User) GetAttribute(name string) (*api.Attribute, error)
- func (u *User) GetAttributes(attrNames []string) ([]api.Attribute, error)
- func (u *User) GetFailedLoginAttempts() int
- func (u *User) GetLevel() int
- func (u *User) GetMaxEnrollments() int
- func (u *User) GetName() string
- func (u *User) GetPass() []byte
- func (u *User) GetType() string
- func (u *User) IncrementIncorrectPasswordAttempts() error
- func (u *User) IsRevoked() bool
- func (u *User) Login(pass string, caMaxEnrollments int) error
- func (u *User) LoginComplete() error
- func (u *User) ModifyAttributes(newAttrs []api.Attribute) error
- func (u *User) ModifyAttributesTx(tx FabricCATx, newAttrs []api.Attribute) error
- func (u *User) Revoke() error
- func (u *User) SetLevel(level int) error
- func (u *User) SetLevelTx(tx FabricCATx, level int) error
- type UserRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCADataSource ¶ added in v1.1.0
GetCADataSource returns a datasource with a unqiue database name
func GetNewAttributes ¶ added in v1.4.0
GetNewAttributes updates existing attribute, or add attribute if it does not already exist
func MaskDBCred ¶ added in v1.0.5
MaskDBCred hides DB credentials in connection string
Types ¶
type DB ¶ added in v1.2.0
type DB struct {
*sqlx.DB
// Indicates if database was successfully initialized
IsDBInitialized bool
}
DB is an adapter for sqlx.DB and implements FabricCADB interface
func NewUserRegistryMySQL ¶
func NewUserRegistryMySQL(datasource string, clientTLSConfig *tls.ClientTLSConfig, csp bccsp.BCCSP) (*DB, error)
NewUserRegistryMySQL opens a connection to a postgres database
func NewUserRegistryPostgres ¶
func NewUserRegistryPostgres(datasource string, clientTLSConfig *tls.ClientTLSConfig) (*DB, error)
NewUserRegistryPostgres opens a connection to a postgres database
func NewUserRegistrySQLLite3 ¶
NewUserRegistrySQLLite3 returns a pointer to a sqlite database
func (*DB) BeginTx ¶ added in v1.2.0
func (db *DB) BeginTx() FabricCATx
BeginTx implements BeginTx method of FabricCADB interface
func (*DB) IsInitialized ¶ added in v1.2.0
IsInitialized returns true if db is intialized, else false
type FabricCADB ¶ added in v1.2.0
type FabricCADB interface {
IsInitialized() bool
Select(dest interface{}, query string, args ...interface{}) error
Exec(query string, args ...interface{}) (sql.Result, error)
NamedExec(query string, arg interface{}) (sql.Result, error)
Rebind(query string) string
MustBegin() *sqlx.Tx
// BeginTx has same behavior as MustBegin except it returns FabricCATx
// instead of *sqlx.Tx
BeginTx() FabricCATx
}
FabricCADB is the interface with functions implemented by sqlx.DB object that are used by Fabric CA server
type FabricCATx ¶ added in v1.2.0
type FabricCATx interface {
Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
Select(dest interface{}, query string, args ...interface{}) error
Rebind(query string) string
Exec(query string, args ...interface{}) (sql.Result, error)
Commit() error
Rollback() error
}
FabricCATx is the interface with functions implemented by sqlx.Tx object that are used by Fabric CA server
type Levels ¶ added in v1.1.0
type Levels struct {
Identity int
Affiliation int
Certificate int
Credential int
RAInfo int
Nonce int
}
Levels contains the levels of identities, affiliations, and certificates
func CurrentDBLevels ¶ added in v1.4.0
CurrentDBLevels returns current levels from the database
type User ¶ added in v1.4.0
User is the databases representation of a user
func NewDBUser ¶ added in v1.4.0
func NewDBUser(userRec *UserRecord, db *DB) *User
NewDBUser creates a DBUser object from the DB user record
func (*User) GetAffiliationPath ¶ added in v1.4.0
GetAffiliationPath returns the complete path for the user's affiliation.
func (*User) GetAttribute ¶ added in v1.4.0
GetAttribute returns the value for an attribute name
func (*User) GetAttributes ¶ added in v1.4.0
GetAttributes returns the requested attributes. Return all the user's attributes if nil is passed in
func (*User) GetFailedLoginAttempts ¶ added in v1.4.0
GetFailedLoginAttempts returns the number of times the user has entered an incorrect password
func (*User) GetMaxEnrollments ¶ added in v1.4.0
GetMaxEnrollments returns the max enrollments of the user
func (*User) IncrementIncorrectPasswordAttempts ¶ added in v1.4.0
IncrementIncorrectPasswordAttempts updates the incorrect password count of user
func (*User) LoginComplete ¶ added in v1.4.0
LoginComplete completes the login process by incrementing the state of the user
func (*User) ModifyAttributes ¶ added in v1.4.0
ModifyAttributes adds a new attribute, modifies existing attribute, or delete attribute
func (*User) ModifyAttributesTx ¶ added in v1.4.0
func (u *User) ModifyAttributesTx(tx FabricCATx, newAttrs []api.Attribute) error
ModifyAttributesTx adds a new attribute, modifies existing attribute, or delete attribute
func (*User) Revoke ¶ added in v1.4.0
Revoke will revoke the user, setting the state of the user to be -1
func (*User) SetLevelTx ¶ added in v1.4.0
func (u *User) SetLevelTx(tx FabricCATx, level int) error
SetLevelTx sets the level of the user
type UserRecord ¶ added in v1.4.0
type UserRecord struct {
Name string `db:"id"`
Pass []byte `db:"token"`
Type string `db:"type"`
Affiliation string `db:"affiliation"`
Attributes string `db:"attributes"`
State int `db:"state"`
MaxEnrollments int `db:"max_enrollments"`
Level int `db:"level"`
IncorrectPasswordAttempts int `db:"incorrect_password_attempts"`
}
UserRecord defines the properties of a user