mysql_db

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2022 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPrivilegedDatabase

func NewPrivilegedDatabase(grantTables *MySQLDb, db sql.Database) sql.Database

NewPrivilegedDatabase returns a new PrivilegedDatabase.

func NewPrivilegedDatabaseProvider

func NewPrivilegedDatabaseProvider(grantTables *MySQLDb, p sql.DatabaseProvider) sql.DatabaseProvider

NewPrivilegedDatabaseProvider returns a new PrivilegedDatabaseProvider. As a sql.DatabaseProvider may be added to an analyzer when Grant Tables are disabled (and Grant Tables may be enabled or disabled at any time), a new PrivilegedDatabaseProvider is returned whenever the sql.DatabaseProvider is needed (as long as Grant Tables are enabled) rather than wrapping a sql.DatabaseProvider when it is provided to the analyzer.

Types

type DbConverter

type DbConverter struct{}

DbConverter handles the conversion between a stored *User entry and the faux "db" Grant Table.

func (DbConverter) AddRowToEntry

func (conv DbConverter) AddRowToEntry(ctx *sql.Context, row sql.Row, entry in_mem_table.Entry) (in_mem_table.Entry, error)

AddRowToEntry implements the interface in_mem_table.DataEditorConverter.

func (DbConverter) EntryToRows

func (conv DbConverter) EntryToRows(ctx *sql.Context, entry in_mem_table.Entry) ([]sql.Row, error)

EntryToRows implements the interface in_mem_table.DataEditorConverter.

func (DbConverter) RemoveRowFromEntry

func (conv DbConverter) RemoveRowFromEntry(ctx *sql.Context, row sql.Row, entry in_mem_table.Entry) (in_mem_table.Entry, error)

RemoveRowFromEntry implements the interface in_mem_table.DataEditorConverter.

func (DbConverter) RowToKey

func (conv DbConverter) RowToKey(ctx *sql.Context, row sql.Row) (in_mem_table.Key, error)

RowToKey implements the interface in_mem_table.DataEditorConverter.

type MySQLDb

type MySQLDb struct {
	Enabled bool
	// contains filtered or unexported fields
}

MySQLDb are the collection of tables that are in the MySQL database

func CreateEmptyMySQLDb

func CreateEmptyMySQLDb() *MySQLDb

CreateEmptyMySQLDb returns a collection of MySQL Tables that do not contain any data.

func (*MySQLDb) AddRootAccount

func (db *MySQLDb) AddRootAccount()

AddRootAccount adds the root account to the list of accounts.

func (*MySQLDb) AddSuperUser

func (db *MySQLDb) AddSuperUser(username string, host string, password string)

AddSuperUser adds the given username and password to the list of accounts. This is a temporary function, which is meant to replace the "auth.New..." functions while the remaining functions are added.

func (*MySQLDb) AuthMethod

func (db *MySQLDb) AuthMethod(user, addr string) (string, error)

AuthMethod implements the interface mysql.AuthServer.

func (*MySQLDb) GetTableInsensitive

func (db *MySQLDb) GetTableInsensitive(ctx *sql.Context, tblName string) (sql.Table, bool, error)

GetTableInsensitive implements the interface sql.Database.

func (*MySQLDb) GetTableNames

func (db *MySQLDb) GetTableNames(ctx *sql.Context) ([]string, error)

GetTableNames implements the interface sql.Database.

func (*MySQLDb) GetUser

func (db *MySQLDb) GetUser(user string, host string, roleSearch bool) *User

GetUser returns a user matching the given user and host if it exists. Due to the slight difference between users and roles, roleSearch changes whether the search matches against user or role rules.

func (*MySQLDb) LoadData

func (db *MySQLDb) LoadData(ctx *sql.Context, buf []byte) (err error)

LoadData adds the given data to the MySQL Tables. It does not remove any current data, but will overwrite any pre-existing data.

func (*MySQLDb) LoadPrivilegeData

func (db *MySQLDb) LoadPrivilegeData(ctx *sql.Context, users []*User, roleConnections []*RoleEdge) error

LoadPrivilegeData adds the given data to the MySQL Tables. It does not remove any current data, but will overwrite any pre-existing data.

func (*MySQLDb) Name

func (db *MySQLDb) Name() string

Name implements the interface sql.Database.

func (*MySQLDb) Negotiate

func (db *MySQLDb) Negotiate(c *mysql.Conn, user string, addr net.Addr) (mysql.Getter, error)

Negotiate implements the interface mysql.AuthServer. This is called when the method used is not "mysql_native_password".

func (*MySQLDb) Persist

func (db *MySQLDb) Persist(ctx *sql.Context) error

Persist passes along all changes to the integrator.

func (*MySQLDb) RoleEdgesTable

func (db *MySQLDb) RoleEdgesTable() *mysqlTable

RoleEdgesTable returns the "role_edges" table.

func (*MySQLDb) Salt

func (db *MySQLDb) Salt() ([]byte, error)

Salt implements the interface mysql.AuthServer.

func (*MySQLDb) SetPersister

func (db *MySQLDb) SetPersister(persister MySQLDbPersistence)

SetPersister sets the custom persister to be used when the MySQL Db tables have been updated and need to be persisted.

func (*MySQLDb) SetPlugins added in v0.14.0

func (db *MySQLDb) SetPlugins(plugins map[string]PlaintextAuthPlugin)

func (*MySQLDb) UserActivePrivilegeSet

func (db *MySQLDb) UserActivePrivilegeSet(ctx *sql.Context) PrivilegeSet

UserActivePrivilegeSet fetches the User, and returns their entire active privilege set. This takes into account the active roles, which are set in the context, therefore the user is also pulled from the context.

func (*MySQLDb) UserHasPrivileges

func (db *MySQLDb) UserHasPrivileges(ctx *sql.Context, operations ...sql.PrivilegedOperation) bool

UserHasPrivileges fetches the User, and returns whether they have the desired privileges necessary to perform the privileged operation. This takes into account the active roles, which are set in the context, therefore the user is also pulled from the context.

func (*MySQLDb) UserTable

func (db *MySQLDb) UserTable() *mysqlTable

UserTable returns the "user" table.

func (*MySQLDb) ValidateHash

func (db *MySQLDb) ValidateHash(salt []byte, user string, authResponse []byte, addr net.Addr) (mysql.Getter, error)

ValidateHash implements the interface mysql.AuthServer. This is called when the method used is "mysql_native_password".

func (*MySQLDb) VerifyPlugin added in v0.14.0

func (db *MySQLDb) VerifyPlugin(plugin string) error

type MySQLDbPersistence

type MySQLDbPersistence interface {
	Persist(ctx *sql.Context, data []byte) error
}

MySQLDbPersistence is used to determine the behavior of how certain tables in MySQLDb will be persisted.

type MysqlConnectionUser

type MysqlConnectionUser struct {
	User string
	Host string
}

MysqlConnectionUser is stored in mysql's connection as UserData once a connection has been authenticated.

func (MysqlConnectionUser) Get

Get implements the interface mysql.Getter.

type NoopPersister

type NoopPersister struct{}

NoopPersister is used when nothing in mysql db should be persisted

func (*NoopPersister) Persist

func (p *NoopPersister) Persist(ctx *sql.Context, data []byte) error

Persist implements the MySQLDbPersistence interface

type PlaintextAuthPlugin added in v0.14.0

type PlaintextAuthPlugin interface {
	Authenticate(db *MySQLDb, user string, userEntry *User, pass string) (bool, error)
}

type PrivilegeSet

type PrivilegeSet struct {
	// contains filtered or unexported fields
}

PrivilegeSet is a set containing privileges. Due to the nested sets potentially returning empty sets, this also acts as the singular location to modify all nested sets.

func NewPrivilegeSet

func NewPrivilegeSet() PrivilegeSet

NewPrivilegeSet returns a new PrivilegeSet.

func (PrivilegeSet) AddColumn

func (ps PrivilegeSet) AddColumn(dbName string, tblName string, colName string, privileges ...sql.PrivilegeType)

AddColumn adds the given column privilege(s).

func (PrivilegeSet) AddDatabase

func (ps PrivilegeSet) AddDatabase(dbName string, privileges ...sql.PrivilegeType)

AddDatabase adds the given database privilege(s).

func (PrivilegeSet) AddGlobalDynamic

func (ps PrivilegeSet) AddGlobalDynamic(privileges ...string)

AddGlobalDynamic adds the given global dynamic privilege(s).

func (PrivilegeSet) AddGlobalStatic

func (ps PrivilegeSet) AddGlobalStatic(privileges ...sql.PrivilegeType)

AddGlobalStatic adds the given global static privilege(s).

func (PrivilegeSet) AddTable

func (ps PrivilegeSet) AddTable(dbName string, tblName string, privileges ...sql.PrivilegeType)

AddTable adds the given table privilege(s).

func (*PrivilegeSet) ClearAll

func (ps *PrivilegeSet) ClearAll()

ClearAll removes all privileges.

func (PrivilegeSet) ClearColumn

func (ps PrivilegeSet) ClearColumn(dbName string, tblName string, colName string)

ClearColumn removes all privileges for the given column.

func (PrivilegeSet) ClearDatabase

func (ps PrivilegeSet) ClearDatabase(dbName string)

ClearDatabase removes all privileges for the given database.

func (*PrivilegeSet) ClearGlobal

func (ps *PrivilegeSet) ClearGlobal()

ClearGlobal removes all global privileges.

func (PrivilegeSet) ClearTable

func (ps PrivilegeSet) ClearTable(dbName string, tblName string)

ClearTable removes all privileges for the given table.

func (PrivilegeSet) Copy

func (ps PrivilegeSet) Copy() PrivilegeSet

Copy returns a duplicate of the calling PrivilegeSet.

func (PrivilegeSet) Database

func (ps PrivilegeSet) Database(dbName string) PrivilegeSetDatabase

Database returns the set of privileges for the given database. Returns an empty set if the database does not exist.

func (PrivilegeSet) Equals

func (ps PrivilegeSet) Equals(otherPs PrivilegeSet) bool

Equals returns whether the given set of privileges is equivalent to the calling set.

func (PrivilegeSet) GetDatabases

func (ps PrivilegeSet) GetDatabases() []PrivilegeSetDatabase

GetDatabases returns all databases.

func (PrivilegeSet) GlobalCount

func (ps PrivilegeSet) GlobalCount() int

GlobalCount returns the combined number of global static and global dynamic privileges.

func (PrivilegeSet) Has

func (ps PrivilegeSet) Has(privileges ...sql.PrivilegeType) bool

Has returns whether the given global static privilege(s) exists.

func (PrivilegeSet) HasPrivileges

func (ps PrivilegeSet) HasPrivileges() bool

HasPrivileges returns whether this PrivilegeSet has any privileges at any level.

func (PrivilegeSet) MarshalJSON

func (ps PrivilegeSet) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface json.Marshaler.

func (PrivilegeSet) RemoveColumn

func (ps PrivilegeSet) RemoveColumn(dbName string, tblName string, colName string, privileges ...sql.PrivilegeType)

RemoveColumn removes the given column privilege(s).

func (PrivilegeSet) RemoveDatabase

func (ps PrivilegeSet) RemoveDatabase(dbName string, privileges ...sql.PrivilegeType)

RemoveDatabase removes the given database privilege(s).

func (PrivilegeSet) RemoveGlobalDynamic

func (ps PrivilegeSet) RemoveGlobalDynamic(privileges ...string)

RemoveGlobalDynamic removes the given global dynamic privilege(s).

func (PrivilegeSet) RemoveGlobalStatic

func (ps PrivilegeSet) RemoveGlobalStatic(privileges ...sql.PrivilegeType)

RemoveGlobalStatic removes the given global static privilege(s).

func (PrivilegeSet) RemoveTable

func (ps PrivilegeSet) RemoveTable(dbName string, tblName string, privileges ...sql.PrivilegeType)

RemoveTable removes the given table privilege(s).

func (PrivilegeSet) StaticCount

func (ps PrivilegeSet) StaticCount() int

StaticCount returns the number of global static privileges, while not including global dynamic privileges.

func (PrivilegeSet) ToSlice

func (ps PrivilegeSet) ToSlice() []sql.PrivilegeType

ToSlice returns all of the global static privileges contained as a slice. Some operations do not care about sort order, therefore this is presented as an alternative to skip the unnecessary sort operation.

func (PrivilegeSet) ToSortedSlice

func (ps PrivilegeSet) ToSortedSlice() []sql.PrivilegeType

ToSortedSlice returns all of the global static privileges contained as a slice, sorted by their internal ID.

func (PrivilegeSet) UnionWith

func (ps PrivilegeSet) UnionWith(other PrivilegeSet)

UnionWith merges the given set of privileges to the calling set of privileges.

func (*PrivilegeSet) UnmarshalJSON

func (ps *PrivilegeSet) UnmarshalJSON(jsonData []byte) error

UnmarshalJSON implements the interface json.Unmarshaler.

type PrivilegeSetColumn

type PrivilegeSetColumn struct {
	// contains filtered or unexported fields
}

PrivilegeSetColumn is a set containing column privileges.

func (PrivilegeSetColumn) Count

func (ps PrivilegeSetColumn) Count() int

Count returns the number of column privileges.

func (PrivilegeSetColumn) Equals

func (ps PrivilegeSetColumn) Equals(otherPs PrivilegeSetColumn) bool

Equals returns whether the given set of privileges is equivalent to the calling set.

func (PrivilegeSetColumn) Has

func (ps PrivilegeSetColumn) Has(privileges ...sql.PrivilegeType) bool

Has returns whether the given column privilege(s) exists.

func (PrivilegeSetColumn) Name

func (ps PrivilegeSetColumn) Name() string

Name returns the name of the column that this privilege set belongs to.

func (PrivilegeSetColumn) ToSlice

func (ps PrivilegeSetColumn) ToSlice() []sql.PrivilegeType

ToSlice returns all of the column privileges contained as a slice. Some operations do not care about sort order, therefore this is presented as an alternative to skip the unnecessary sort operation.

func (PrivilegeSetColumn) ToSortedSlice

func (ps PrivilegeSetColumn) ToSortedSlice() []sql.PrivilegeType

ToSortedSlice returns all of the column privileges contained as a slice, sorted by their internal ID.

type PrivilegeSetDatabase

type PrivilegeSetDatabase struct {
	// contains filtered or unexported fields
}

PrivilegeSetDatabase is a set containing database-level privileges.

func (PrivilegeSetDatabase) Count

func (ps PrivilegeSetDatabase) Count() int

Count returns the number of database privileges.

func (PrivilegeSetDatabase) Equals

func (ps PrivilegeSetDatabase) Equals(otherPs PrivilegeSetDatabase) bool

Equals returns whether the given set of privileges is equivalent to the calling set.

func (PrivilegeSetDatabase) GetTables

func (ps PrivilegeSetDatabase) GetTables() []PrivilegeSetTable

GetTables returns all tables.

func (PrivilegeSetDatabase) Has

func (ps PrivilegeSetDatabase) Has(privileges ...sql.PrivilegeType) bool

Has returns whether the given database privilege(s) exists.

func (PrivilegeSetDatabase) HasPrivileges

func (ps PrivilegeSetDatabase) HasPrivileges() bool

HasPrivileges returns whether this database has either database-level privileges, or privileges on a table or column contained within this database.

func (PrivilegeSetDatabase) Name

func (ps PrivilegeSetDatabase) Name() string

Name returns the name of the database that this privilege set belongs to.

func (PrivilegeSetDatabase) Table

func (ps PrivilegeSetDatabase) Table(tblName string) PrivilegeSetTable

Table returns the set of privileges for the given table. Returns an empty set if the table does not exist.

func (PrivilegeSetDatabase) ToSlice

func (ps PrivilegeSetDatabase) ToSlice() []sql.PrivilegeType

ToSlice returns all of the database privileges contained as a slice. Some operations do not care about sort order, therefore this is presented as an alternative to skip the unnecessary sort operation.

func (PrivilegeSetDatabase) ToSortedSlice

func (ps PrivilegeSetDatabase) ToSortedSlice() []sql.PrivilegeType

ToSortedSlice returns all of the database privileges contained as a slice, sorted by their internal ID.

type PrivilegeSetTable

type PrivilegeSetTable struct {
	// contains filtered or unexported fields
}

PrivilegeSetTable is a set containing table-level privileges.

func (PrivilegeSetTable) Column

func (ps PrivilegeSetTable) Column(colName string) PrivilegeSetColumn

Column returns the set of privileges for the given column. Returns an empty set if the column does not exist.

func (PrivilegeSetTable) Count

func (ps PrivilegeSetTable) Count() int

Count returns the number of table privileges.

func (PrivilegeSetTable) Equals

func (ps PrivilegeSetTable) Equals(otherPs PrivilegeSetTable) bool

Equals returns whether the given set of privileges is equivalent to the calling set.

func (PrivilegeSetTable) GetColumns

func (ps PrivilegeSetTable) GetColumns() []PrivilegeSetColumn

GetColumns returns all columns.

func (PrivilegeSetTable) Has

func (ps PrivilegeSetTable) Has(privileges ...sql.PrivilegeType) bool

Has returns whether the given table privilege(s) exists.

func (PrivilegeSetTable) HasPrivileges

func (ps PrivilegeSetTable) HasPrivileges() bool

HasPrivileges returns whether this table has either table-level privileges, or privileges on a column contained within this table.

func (PrivilegeSetTable) Name

func (ps PrivilegeSetTable) Name() string

Name returns the name of the table that this privilege set belongs to.

func (PrivilegeSetTable) ToSlice

func (ps PrivilegeSetTable) ToSlice() []sql.PrivilegeType

ToSlice returns all of the table privileges contained as a slice. Some operations do not care about sort order, therefore this is presented as an alternative to skip the unnecessary sort operation.

func (PrivilegeSetTable) ToSortedSlice

func (ps PrivilegeSetTable) ToSortedSlice() []sql.PrivilegeType

ToSortedSlice returns all of the table privileges contained as a slice, sorted by their internal ID.

type PrivilegedDatabase

type PrivilegedDatabase struct {
	// contains filtered or unexported fields
}

PrivilegedDatabase is a wrapper around a normal sql.Database that takes a context's client's privileges into consideration when returning a sql.Table.

func (PrivilegedDatabase) CopyTableData

func (pdb PrivilegedDatabase) CopyTableData(ctx *sql.Context, sourceTable string, destinationTable string) (uint64, error)

CopyTableData implements the interface sql.TableCopierDatabase.

func (PrivilegedDatabase) CreateTable

func (pdb PrivilegedDatabase) CreateTable(ctx *sql.Context, name string, schema sql.PrimaryKeySchema, collation sql.CollationID) error

CreateTable implements the interface sql.TableCreator.

func (PrivilegedDatabase) CreateTrigger

func (pdb PrivilegedDatabase) CreateTrigger(ctx *sql.Context, definition sql.TriggerDefinition) error

CreateTrigger implements the interface sql.TriggerDatabase.

func (PrivilegedDatabase) DropStoredProcedure

func (pdb PrivilegedDatabase) DropStoredProcedure(ctx *sql.Context, name string) error

DropStoredProcedure implements the interface sql.StoredProcedureDatabase.

func (PrivilegedDatabase) DropTable

func (pdb PrivilegedDatabase) DropTable(ctx *sql.Context, name string) error

DropTable implements the interface sql.TableDropper.

func (PrivilegedDatabase) DropTrigger

func (pdb PrivilegedDatabase) DropTrigger(ctx *sql.Context, name string) error

DropTrigger implements the interface sql.TriggerDatabase.

func (PrivilegedDatabase) GetAllTemporaryTables

func (pdb PrivilegedDatabase) GetAllTemporaryTables(ctx *sql.Context) ([]sql.Table, error)

GetAllTemporaryTables implements the interface sql.TemporaryTableDatabase.

func (PrivilegedDatabase) GetCollation added in v0.14.0

func (pdb PrivilegedDatabase) GetCollation(ctx *sql.Context) sql.CollationID

GetCollation implements the interface sql.CollatedDatabase.

func (PrivilegedDatabase) GetStoredProcedures

func (pdb PrivilegedDatabase) GetStoredProcedures(ctx *sql.Context) ([]sql.StoredProcedureDetails, error)

GetStoredProcedures implements the interface sql.StoredProcedureDatabase.

func (PrivilegedDatabase) GetTableInsensitive

func (pdb PrivilegedDatabase) GetTableInsensitive(ctx *sql.Context, tblName string) (sql.Table, bool, error)

GetTableInsensitive implements the interface sql.Database.

func (PrivilegedDatabase) GetTableInsensitiveAsOf

func (pdb PrivilegedDatabase) GetTableInsensitiveAsOf(ctx *sql.Context, tblName string, asOf interface{}) (sql.Table, bool, error)

GetTableInsensitiveAsOf returns a new sql.VersionedDatabase.

func (PrivilegedDatabase) GetTableNames

func (pdb PrivilegedDatabase) GetTableNames(ctx *sql.Context) ([]string, error)

GetTableNames implements the interface sql.Database.

func (PrivilegedDatabase) GetTableNamesAsOf

func (pdb PrivilegedDatabase) GetTableNamesAsOf(ctx *sql.Context, asOf interface{}) ([]string, error)

GetTableNamesAsOf returns a new sql.VersionedDatabase.

func (PrivilegedDatabase) GetTriggers

func (pdb PrivilegedDatabase) GetTriggers(ctx *sql.Context) ([]sql.TriggerDefinition, error)

GetTriggers implements the interface sql.TriggerDatabase.

func (PrivilegedDatabase) IsReadOnly

func (pdb PrivilegedDatabase) IsReadOnly() bool

IsReadOnly implements the interface sql.ReadOnlyDatabase.

func (PrivilegedDatabase) Name

func (pdb PrivilegedDatabase) Name() string

Name implements the interface sql.Database.

func (PrivilegedDatabase) RenameTable

func (pdb PrivilegedDatabase) RenameTable(ctx *sql.Context, oldName, newName string) error

RenameTable implements the interface sql.TableRenamer.

func (PrivilegedDatabase) SaveStoredProcedure

func (pdb PrivilegedDatabase) SaveStoredProcedure(ctx *sql.Context, spd sql.StoredProcedureDetails) error

SaveStoredProcedure implements the interface sql.StoredProcedureDatabase.

func (PrivilegedDatabase) SetCollation added in v0.14.0

func (pdb PrivilegedDatabase) SetCollation(ctx *sql.Context, collation sql.CollationID) error

SetCollation implements the interface sql.CollatedDatabase.

func (PrivilegedDatabase) Unwrap

func (pdb PrivilegedDatabase) Unwrap() sql.Database

Unwrap returns the wrapped sql.Database.

type PrivilegedDatabaseProvider

type PrivilegedDatabaseProvider struct {
	// contains filtered or unexported fields
}

PrivilegedDatabaseProvider is a wrapper around a normal sql.DatabaseProvider that takes a context's client's privileges into consideration when returning a sql.Database. In addition, any returned databases are wrapped with PrivilegedDatabase.

func (PrivilegedDatabaseProvider) AllDatabases

func (pdp PrivilegedDatabaseProvider) AllDatabases(ctx *sql.Context) []sql.Database

AllDatabases implements the interface sql.DatabaseProvider.

func (PrivilegedDatabaseProvider) Database

func (pdp PrivilegedDatabaseProvider) Database(ctx *sql.Context, name string) (sql.Database, error)

Database implements the interface sql.DatabaseProvider.

func (PrivilegedDatabaseProvider) HasDatabase

func (pdp PrivilegedDatabaseProvider) HasDatabase(ctx *sql.Context, name string) bool

HasDatabase implements the interface sql.DatabaseProvider.

type RoleEdge

type RoleEdge struct {
	FromHost        string
	FromUser        string
	ToHost          string
	ToUser          string
	WithAdminOption bool
}

RoleEdge represents a role to user mapping from the roles_edges Grant Table.

func LoadRoleEdge

func LoadRoleEdge(serialRoleEdge *serial.RoleEdge) *RoleEdge

func (*RoleEdge) Copy

func (r *RoleEdge) Copy(ctx *sql.Context) in_mem_table.Entry

Copy implements the interface in_mem_table.Entry.

func (*RoleEdge) Equals

func (r *RoleEdge) Equals(ctx *sql.Context, otherEntry in_mem_table.Entry) bool

Equals implements the interface in_mem_table.Entry.

func (RoleEdge) FromJson

func (r RoleEdge) FromJson(ctx *sql.Context, jsonStr string) (in_mem_table.Entry, error)

FromJson implements the interface in_mem_table.Entry.

func (*RoleEdge) FromString

func (r *RoleEdge) FromString(quote string) string

FromString returns the "FROM" user as a formatted string using the quotes given. Using the default root account with the backtick as the quote, root@localhost would become `root`@`localhost`. Different quotes are used in different places in MySQL. In addition, if the quote is used in a section as part of the name, it is escaped by doubling the quote (which also mimics MySQL behavior).

func (*RoleEdge) NewFromRow

func (r *RoleEdge) NewFromRow(ctx *sql.Context, row sql.Row) (in_mem_table.Entry, error)

NewFromRow implements the interface in_mem_table.Entry.

func (*RoleEdge) ToJson

func (r *RoleEdge) ToJson(ctx *sql.Context) (string, error)

ToJson implements the interface in_mem_table.Entry.

func (*RoleEdge) ToRow

func (r *RoleEdge) ToRow(ctx *sql.Context) sql.Row

ToRow implements the interface in_mem_table.Entry.

func (*RoleEdge) ToString

func (r *RoleEdge) ToString(quote string) string

ToString returns the "TO" user as a formatted string using the quotes given. Using the default root account with the backtick as the quote, root@localhost would become `root`@`localhost`. Different quotes are used in different places in MySQL. In addition, if the quote is used in a section as part of the name, it is escaped by doubling the quote (which also mimics MySQL behavior).

func (*RoleEdge) UpdateFromRow

func (r *RoleEdge) UpdateFromRow(ctx *sql.Context, row sql.Row) (in_mem_table.Entry, error)

UpdateFromRow implements the interface in_mem_table.Entry.

type RoleEdgesFromKey

type RoleEdgesFromKey struct {
	FromHost string
	FromUser string
}

RoleEdgesFromKey is a secondary key that represents the "from" columns on the "role_edges" Grant Table.

func (RoleEdgesFromKey) KeyFromEntry

func (k RoleEdgesFromKey) KeyFromEntry(ctx *sql.Context, entry in_mem_table.Entry) (in_mem_table.Key, error)

KeyFromEntry implements the interface in_mem_table.Key.

func (RoleEdgesFromKey) KeyFromRow

func (k RoleEdgesFromKey) KeyFromRow(ctx *sql.Context, row sql.Row) (in_mem_table.Key, error)

KeyFromRow implements the interface in_mem_table.Key.

type RoleEdgesPrimaryKey

type RoleEdgesPrimaryKey struct {
	FromHost string
	FromUser string
	ToHost   string
	ToUser   string
}

RoleEdgesPrimaryKey is a key that represents the primary key for the "role_edges" Grant Table.

func (RoleEdgesPrimaryKey) KeyFromEntry

func (k RoleEdgesPrimaryKey) KeyFromEntry(ctx *sql.Context, entry in_mem_table.Entry) (in_mem_table.Key, error)

KeyFromEntry implements the interface in_mem_table.Key.

func (RoleEdgesPrimaryKey) KeyFromRow

func (k RoleEdgesPrimaryKey) KeyFromRow(ctx *sql.Context, row sql.Row) (in_mem_table.Key, error)

KeyFromRow implements the interface in_mem_table.Key.

type RoleEdgesToKey

type RoleEdgesToKey struct {
	ToHost string
	ToUser string
}

RoleEdgesToKey is a secondary key that represents the "to" columns on the "role_edges" Grant Table.

func (RoleEdgesToKey) KeyFromEntry

func (k RoleEdgesToKey) KeyFromEntry(ctx *sql.Context, entry in_mem_table.Entry) (in_mem_table.Key, error)

KeyFromEntry implements the interface in_mem_table.Key.

func (RoleEdgesToKey) KeyFromRow

func (k RoleEdgesToKey) KeyFromRow(ctx *sql.Context, row sql.Row) (in_mem_table.Key, error)

KeyFromRow implements the interface in_mem_table.Key.

type TablesPrivConverter

type TablesPrivConverter struct{}

TablesPrivConverter handles the conversion between a stored *User entry and the faux "tables_priv" Grant Table.

func (TablesPrivConverter) AddRowToEntry

func (conv TablesPrivConverter) AddRowToEntry(ctx *sql.Context, row sql.Row, entry in_mem_table.Entry) (in_mem_table.Entry, error)

AddRowToEntry implements the interface in_mem_table.DataEditorConverter.

func (TablesPrivConverter) EntryToRows

func (conv TablesPrivConverter) EntryToRows(ctx *sql.Context, entry in_mem_table.Entry) ([]sql.Row, error)

EntryToRows implements the interface in_mem_table.DataEditorConverter.

func (TablesPrivConverter) RemoveRowFromEntry

func (conv TablesPrivConverter) RemoveRowFromEntry(ctx *sql.Context, row sql.Row, entry in_mem_table.Entry) (in_mem_table.Entry, error)

RemoveRowFromEntry implements the interface in_mem_table.DataEditorConverter.

func (TablesPrivConverter) RowToKey

func (conv TablesPrivConverter) RowToKey(ctx *sql.Context, row sql.Row) (in_mem_table.Key, error)

RowToKey implements the interface in_mem_table.DataEditorConverter.

type User

type User struct {
	User                string
	Host                string
	PrivilegeSet        PrivilegeSet
	Plugin              string
	Password            string
	PasswordLastChanged time.Time
	Locked              bool
	Attributes          *string
	Identity            string
	IsSuperUser         bool

	// IsRole is an additional field that states whether the User represents a role or user. In MySQL this must be a
	// hidden column, therefore it's represented here as an additional field.
	IsRole bool
}

User represents a user from the user Grant Table.

func LoadUser

func LoadUser(serialUser *serial.User) *User

func (*User) Copy

func (u *User) Copy(ctx *sql.Context) in_mem_table.Entry

Copy implements the interface in_mem_table.Entry.

func (*User) Equals

func (u *User) Equals(ctx *sql.Context, otherEntry in_mem_table.Entry) bool

Equals implements the interface in_mem_table.Entry.

func (User) FromJson

func (u User) FromJson(ctx *sql.Context, jsonStr string) (in_mem_table.Entry, error)

FromJson implements the interface in_mem_table.Entry.

func (*User) NewFromRow

func (u *User) NewFromRow(ctx *sql.Context, row sql.Row) (in_mem_table.Entry, error)

NewFromRow implements the interface in_mem_table.Entry.

func (*User) ToJson

func (u *User) ToJson(ctx *sql.Context) (string, error)

ToJson implements the interface in_mem_table.Entry.

func (*User) ToRow

func (u *User) ToRow(ctx *sql.Context) sql.Row

ToRow implements the interface in_mem_table.Entry.

func (*User) UpdateFromRow

func (u *User) UpdateFromRow(ctx *sql.Context, row sql.Row) (in_mem_table.Entry, error)

UpdateFromRow implements the interface in_mem_table.Entry.

func (User) UserHostToString

func (u User) UserHostToString(quote string) string

UserHostToString returns the user and host as a formatted string using the quotes given. Using the default root account with the backtick as the quote, root@localhost would become `root`@`localhost`. Different quotes are used in different places in MySQL. In addition, if the quote is used in a section as part of the name, it is escaped by doubling the quote (which also mimics MySQL behavior).

type UserPrimaryKey

type UserPrimaryKey struct {
	Host string
	User string
}

UserPrimaryKey is a key that represents the primary key for the "user" Grant Table.

func (UserPrimaryKey) KeyFromEntry

func (u UserPrimaryKey) KeyFromEntry(ctx *sql.Context, entry in_mem_table.Entry) (in_mem_table.Key, error)

KeyFromEntry implements the interface in_mem_table.Key.

func (UserPrimaryKey) KeyFromRow

func (u UserPrimaryKey) KeyFromRow(ctx *sql.Context, row sql.Row) (in_mem_table.Key, error)

KeyFromRow implements the interface in_mem_table.Key.

type UserSecondaryKey

type UserSecondaryKey struct {
	User string
}

UserSecondaryKey is a key that represents the secondary key for the "user" Grant Table, which contains only usernames.

func (UserSecondaryKey) KeyFromEntry

func (u UserSecondaryKey) KeyFromEntry(ctx *sql.Context, entry in_mem_table.Entry) (in_mem_table.Key, error)

KeyFromEntry implements the interface in_mem_table.Key.

func (UserSecondaryKey) KeyFromRow

func (u UserSecondaryKey) KeyFromRow(ctx *sql.Context, row sql.Row) (in_mem_table.Key, error)

KeyFromRow implements the interface in_mem_table.Key.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL