azuresql

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ServerPort = 1433

ServerPort is the default server port for sql server

Variables

This section is empty.

Functions

func ConnectToDB

func ConnectToDB(
	ctx context.Context,
	serverAddress string,
	database string,
	port int,
	user string,
	password string,
) (*sql.DB, error)

func ConnectToDBUsingAAD

func ConnectToDBUsingAAD(
	ctx context.Context,
	serverAddress string,
	database string,
	port int,
	tokenProvider func() (string, error),
) (*sql.DB, error)

ConnectToDBUsingAAD connects to the Azure SQL database using the specified token provider. TODO: Does this work for any form of user? Don't need a username at all?

func CreateOrUpdateAADUser

func CreateOrUpdateAADUser(ctx context.Context, db *sql.DB, username string) error

CreateOrUpdateAADUser creates or updates an AAD user. See https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-configure for details on how to create AAD users. username can be either the actual AAD username (for real AAD users), the group name for groups, or the managed identity name (app) for managed identities.

func CreateOrUpdateUser

func CreateOrUpdateUser(ctx context.Context, db *sql.DB, username string, password string) error

func DoesUserExist

func DoesUserExist(ctx context.Context, db *sql.DB, username string) (bool, error)

DoesUserExist checks if db contains user

func DropUser

func DropUser(ctx context.Context, db *sql.DB, username string) error

DropUser drops a user from db

func GetUserRoles

func GetUserRoles(ctx context.Context, db *sql.DB, user string) (set.Set[string], error)

GetUserRoles gets the roles assigned t othe user

func ReconcileUserRoles

func ReconcileUserRoles(ctx context.Context, db *sql.DB, user string, roles []string) error

ReconcileUserRoles revokes and grants roles as needed so the roles for the user match those passed in.

Types

type SQLRoleDelta

type SQLRoleDelta struct {
	AddedRoles   set.Set[string]
	DeletedRoles set.Set[string]
}

func DiffCurrentAndExpectedSQLRoles

func DiffCurrentAndExpectedSQLRoles(currentRoles set.Set[string], expectedRoles set.Set[string]) SQLRoleDelta

Jump to

Keyboard shortcuts

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