sessioninit

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
var CacheEnabledSettingName = "server.authentication_cache.enabled"

CacheEnabledSettingName is the name of the CacheEnabled cluster setting.

View Source
var DatabaseRoleSettingsTableName = tree.NewTableNameWithSchema("system", tree.PublicSchemaName, "database_role_settings")

DatabaseRoleSettingsTableName represents system.database_role_settings.

View Source
var RoleOptionsTableName = tree.NewTableNameWithSchema("system", tree.PublicSchemaName, "role_options")

RoleOptionsTableName represents system.role_options.

View Source
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

type Cache struct {
	syncutil.Mutex
	// contains filtered or unexported fields
}

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.

Jump to

Keyboard shortcuts

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