Documentation
¶
Index ¶
- Variables
- type AuthInfo
- type Cache
- func (a *Cache) GetAuthInfo(ctx context.Context, settings *cluster.Settings, ie sqlutil.InternalExecutor, ...) (aInfo AuthInfo, err error)
- func (a *Cache) GetDefaultSettings(ctx context.Context, settings *cluster.Settings, ie sqlutil.InternalExecutor, ...) (settingsEntries []SettingsCacheEntry, err error)
- type SettingsCacheEntry
- type SettingsCacheKey
Constants ¶
This section is empty.
Variables ¶
var CacheEnabled = settings.RegisterBoolSetting( settings.TenantWritable, CacheEnabledSettingName, "enables a cache used during authentication to avoid lookups to system tables "+ "when retrieving per-user authentication-related information", true, ).WithPublic()
CacheEnabled is a cluster setting that determines if the sessioninit.Cache and associated logic is enabled.
var CacheEnabledSettingName = "server.authentication_cache.enabled"
CacheEnabledSettingName is the name of the CacheEnabled cluster setting.
var DatabaseRoleSettingsTableName = tree.NewTableNameWithSchema("system", tree.PublicSchemaName, "database_role_settings")
DatabaseRoleSettingsTableName represents system.database_role_settings.
var RoleOptionsTableName = tree.NewTableNameWithSchema("system", tree.PublicSchemaName, "role_options")
RoleOptionsTableName represents system.role_options.
var UsersTableName = tree.NewTableNameWithSchema("system", tree.PublicSchemaName, "users")
UsersTableName represents system.users.
Functions ¶
This section is empty.
Types ¶
type AuthInfo ¶
type AuthInfo struct {
// UserExists is set to true if the user has a row in system.users.
UserExists bool
// CanLoginSQL is set to false if the user has the NOLOGIN or NOSQLLOGIN role option.
CanLoginSQL bool
// CanLoginDBConsole is set to false if the user has NOLOGIN role option.
CanLoginDBConsole bool
// HashedPassword is the hashed password and can be nil.
HashedPassword security.PasswordHash
// ValidUntil is the VALID UNTIL role option.
ValidUntil *tree.DTimestamp
}
AuthInfo contains data that is used to perform an authentication attempt.
type Cache ¶
Cache is a shared cache for hashed passwords and other information used during user authentication and session initialization.
func NewCache ¶
func NewCache(account mon.BoundAccount, stopper *stop.Stopper) *Cache
NewCache initializes a new sessioninit.Cache.
func (*Cache) GetAuthInfo ¶
func (a *Cache) GetAuthInfo( ctx context.Context, settings *cluster.Settings, ie sqlutil.InternalExecutor, db *kv.DB, f *descs.CollectionFactory, username security.SQLUsername, readFromSystemTables func( ctx context.Context, txn *kv.Txn, ie sqlutil.InternalExecutor, username security.SQLUsername, ) (AuthInfo, error), ) (aInfo AuthInfo, err error)
GetAuthInfo consults the sessioninit.Cache and returns the AuthInfo for the provided username and databaseName. If the information is not in the cache, or if the underlying tables have changed since the cache was populated, then the readFromSystemTables callback is used to load new data.
func (*Cache) GetDefaultSettings ¶
func (a *Cache) GetDefaultSettings( ctx context.Context, settings *cluster.Settings, ie sqlutil.InternalExecutor, db *kv.DB, f *descs.CollectionFactory, username security.SQLUsername, databaseName string, readFromSystemTables func( ctx context.Context, txn *kv.Txn, ie sqlutil.InternalExecutor, username security.SQLUsername, databaseID descpb.ID, ) ([]SettingsCacheEntry, error), ) (settingsEntries []SettingsCacheEntry, err error)
GetDefaultSettings consults the sessioninit.Cache and returns the list of SettingsCacheEntry for the provided username and databaseName. If the information is not in the cache, or if the underlying tables have changed since the cache was populated, then the readFromSystemTables callback is used to load new data.
type SettingsCacheEntry ¶
type SettingsCacheEntry struct {
SettingsCacheKey
Settings []string
}
SettingsCacheEntry represents an entry in the settingsCache. It is used so that the entries can be returned in a stable order.
type SettingsCacheKey ¶
type SettingsCacheKey struct {
DatabaseID descpb.ID
Username security.SQLUsername
}
SettingsCacheKey is the key used for the settingsCache.
func GenerateSettingsCacheKeys ¶
func GenerateSettingsCacheKeys( databaseID descpb.ID, username security.SQLUsername, ) []SettingsCacheKey
GenerateSettingsCacheKeys returns a slice of all the SettingsCacheKey that are relevant for the given databaseID and username. The slice is ordered in descending order of precedence.