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 ¶
GetCADataSource returns a datasource with a unqiue database name
func GetNewAttributes ¶
GetNewAttributes updates existing attribute, or add attribute if it does not already exist
func MaskDBCred ¶
MaskDBCred hides DB credentials in connection string
Types ¶
type DB ¶
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 ¶
func (db *DB) BeginTx() FabricCATx
BeginTx implements BeginTx method of FabricCADB interface
func (*DB) IsInitialized ¶
IsInitialized returns true if db is intialized, else false
type FabricCADB ¶
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 ¶
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 ¶
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 ¶
CurrentDBLevels returns current levels from the database
type User ¶
User is the databases representation of a user
func NewDBUser ¶
func NewDBUser(userRec *UserRecord, db *DB) *User
NewDBUser creates a DBUser object from the DB user record
func (*User) GetAffiliationPath ¶
GetAffiliationPath returns the complete path for the user's affiliation.
func (*User) GetAttribute ¶
GetAttribute returns the value for an attribute name
func (*User) GetAttributes ¶
GetAttributes returns the requested attributes. Return all the user's attributes if nil is passed in
func (*User) GetFailedLoginAttempts ¶
GetFailedLoginAttempts returns the number of times the user has entered an incorrect password
func (*User) GetMaxEnrollments ¶
GetMaxEnrollments returns the max enrollments of the user
func (*User) IncrementIncorrectPasswordAttempts ¶
IncrementIncorrectPasswordAttempts updates the incorrect password count of user
func (*User) LoginComplete ¶
LoginComplete completes the login process by incrementing the state of the user
func (*User) ModifyAttributes ¶
ModifyAttributes adds a new attribute, modifies existing attribute, or delete attribute
func (*User) ModifyAttributesTx ¶
func (u *User) ModifyAttributesTx(tx FabricCATx, newAttrs []api.Attribute) error
ModifyAttributesTx adds a new attribute, modifies existing attribute, or delete attribute
func (*User) SetLevelTx ¶
func (u *User) SetLevelTx(tx FabricCATx, level int) error
SetLevelTx sets the level of the user
type UserRecord ¶
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