Documentation ¶
Index ¶
- Variables
- func MockInitPrivilegeN(fakedbs *fakedb.DB)
- func MockInitPrivilegeNotSuper(fakedbs *fakedb.DB)
- func MockInitPrivilegeUserNDatabaseY(fakedbs *fakedb.DB)
- func MockInitPrivilegeUsers(fakedbs *fakedb.DB)
- func MockInitPrivilegeY(fakedbs *fakedb.DB)
- type Privilege
- func (p *Privilege) Check(database string, user string, node sqlparser.Statement) error
- func (p *Privilege) CheckDBinUserPrivilege(user string, db string) bool
- func (p *Privilege) CheckPrivilege(db string, user string, node sqlparser.Statement) bool
- func (p *Privilege) CheckUserPrivilegeIsSet(user string) bool
- func (p *Privilege) Close() error
- func (p *Privilege) GetUserPrivilegeDBS(user string) (dbMap map[string]struct{})
- func (p *Privilege) Init() error
- func (p *Privilege) IsSuperPriv(user string) bool
- func (p *Privilege) UpdatePrivileges() error
- type PrivilegeHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( UserRs = &sqltypes.Result{ Fields: []*querypb.Field{ { Name: "Host", Type: querypb.Type_VARCHAR, }, { Name: "User", Type: querypb.Type_VARCHAR, }, { Name: "Select_priv", Type: querypb.Type_ENUM, }, { Name: "Insert_priv", Type: querypb.Type_ENUM, }, { Name: "Update_priv", Type: querypb.Type_ENUM, }, { Name: "Delete_priv", Type: querypb.Type_ENUM, }, { Name: "Create_priv", Type: querypb.Type_ENUM, }, { Name: "Drop_priv", Type: querypb.Type_ENUM, }, { Name: "Alter_priv", Type: querypb.Type_ENUM, }, { Name: "Index_priv", Type: querypb.Type_ENUM, }, { Name: "Show_db_priv", Type: querypb.Type_ENUM, }, { Name: "Super_priv", Type: querypb.Type_ENUM, }, }, Rows: [][]sqltypes.Value{ { sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("%")), sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("mock")), }, }, } DbRs = &sqltypes.Result{ Fields: []*querypb.Field{ { Name: "Host", Type: querypb.Type_VARCHAR, }, { Name: "User", Type: querypb.Type_VARCHAR, }, { Name: "Select_priv", Type: querypb.Type_ENUM, }, { Name: "Insert_priv", Type: querypb.Type_ENUM, }, { Name: "Update_priv", Type: querypb.Type_ENUM, }, { Name: "Delete_priv", Type: querypb.Type_ENUM, }, { Name: "Create_priv", Type: querypb.Type_ENUM, }, { Name: "Drop_priv", Type: querypb.Type_ENUM, }, { Name: "Grant_priv", Type: querypb.Type_ENUM, }, { Name: "Alter_priv", Type: querypb.Type_ENUM, }, { Name: "Index_priv", Type: querypb.Type_ENUM, }, { Name: "Db", Type: querypb.Type_VARCHAR, }, }, Rows: [][]sqltypes.Value{ { sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("%")), sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("mock")), }, }, } UserRs1 = &sqltypes.Result{ Fields: []*querypb.Field{ { Name: "Host", Type: querypb.Type_VARCHAR, }, { Name: "User", Type: querypb.Type_VARCHAR, }, { Name: "Select_priv", Type: querypb.Type_ENUM, }, { Name: "Insert_priv", Type: querypb.Type_ENUM, }, { Name: "Update_priv", Type: querypb.Type_ENUM, }, { Name: "Delete_priv", Type: querypb.Type_ENUM, }, { Name: "Create_priv", Type: querypb.Type_ENUM, }, { Name: "Drop_priv", Type: querypb.Type_ENUM, }, { Name: "Alter_priv", Type: querypb.Type_ENUM, }, { Name: "Index_priv", Type: querypb.Type_ENUM, }, { Name: "Show_db_priv", Type: querypb.Type_ENUM, }, { Name: "Super_priv", Type: querypb.Type_ENUM, }, }, Rows: [][]sqltypes.Value{ { sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("%")), sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("mock")), }, { sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("%")), sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("mock1")), }, }, } DbRs1 = &sqltypes.Result{ Fields: []*querypb.Field{ { Name: "Host", Type: querypb.Type_VARCHAR, }, { Name: "User", Type: querypb.Type_VARCHAR, }, { Name: "Select_priv", Type: querypb.Type_ENUM, }, { Name: "Insert_priv", Type: querypb.Type_ENUM, }, { Name: "Update_priv", Type: querypb.Type_ENUM, }, { Name: "Delete_priv", Type: querypb.Type_ENUM, }, { Name: "Create_priv", Type: querypb.Type_ENUM, }, { Name: "Drop_priv", Type: querypb.Type_ENUM, }, { Name: "Grant_priv", Type: querypb.Type_ENUM, }, { Name: "Alter_priv", Type: querypb.Type_ENUM, }, { Name: "Index_priv", Type: querypb.Type_ENUM, }, { Name: "Db", Type: querypb.Type_VARCHAR, }, }, Rows: [][]sqltypes.Value{ { sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("%")), sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("mock")), }, { sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("%")), sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("mock")), }, }, } )
Functions ¶
func MockInitPrivilegeN ¶
MockInitPrivilegeN init the Rows with N.
func MockInitPrivilegeNotSuper ¶
MockInitPrivilegeNotSuper init the Rows with N to Super_priv.
func MockInitPrivilegeUserNDatabaseY ¶
MockInitPrivilegeUserNDatabaseY init the Rows with user priv N and db priv Y.
func MockInitPrivilegeUsers ¶
MockInitPrivilegeUsers init the Rows with multiple users.
func MockInitPrivilegeY ¶
MockInitPrivilegeY init the Rows with Y.
Types ¶
type Privilege ¶
type Privilege struct {
// contains filtered or unexported fields
}
Privilege struct.
func (*Privilege) CheckDBinUserPrivilege ¶
CheckDBinUserPrivilege ...
func (*Privilege) CheckPrivilege ¶
https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html
func (*Privilege) CheckUserPrivilegeIsSet ¶
CheckUserPrivilegeIsSet ...
func (*Privilege) GetUserPrivilegeDBS ¶
GetUserPrivilegeDBS get the dbmap with dbPrivs in the user.
func (*Privilege) UpdatePrivileges ¶
UpdatePrivileges -- used to update the privileges map to latest.
type PrivilegeHandler ¶
type PrivilegeHandler interface { Init() error Check(db string, user string, node sqlparser.Statement) error CheckPrivilege(db string, user string, node sqlparser.Statement) bool CheckUserPrivilegeIsSet(user string) bool IsSuperPriv(user string) bool GetUserPrivilegeDBS(user string) (dbs map[string]struct{}) CheckDBinUserPrivilege(user string, db string) bool Close() error }
func NewPrivilege ¶
NewPrivilege -- creates new Privilege.
Click to show internal directories.
Click to hide internal directories.