Skip to content

Commit

Permalink
more privilege changes (#3810)
Browse files Browse the repository at this point in the history
  • Loading branch information
jycor committed Jul 28, 2022
1 parent 9103241 commit 9623166
Show file tree
Hide file tree
Showing 18 changed files with 532 additions and 413 deletions.
18 changes: 7 additions & 11 deletions go/cmd/dolt/commands/engine/sqlengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ type SqlEngineConfig struct {
InitialDb string
IsReadOnly bool
IsServerLocked bool
DoltCfgDirPath string
PrivFilePath string
ServerUser string
ServerPass string
ServerHost string
Autocommit bool
Bulk bool
JwksConfig []JwksConfig
Expand Down Expand Up @@ -91,24 +93,16 @@ func NewSqlEngine(
pro := dsqle.NewDoltDatabaseProvider(b, mrEnv.FileSystem(), all...).WithRemoteDialer(mrEnv.RemoteDialProvider())

// Load in privileges from file, if it exists
persister := mysql_file_handler.NewPersister(config.PrivFilePath)
persister := mysql_file_handler.NewPersister(config.PrivFilePath, config.DoltCfgDirPath)
data, err := persister.LoadData()
if err != nil {
return nil, err
}

// Create temporary users if no privileges in config
var tempUsers []gms.TemporaryUser
if len(data) == 0 && len(config.ServerUser) > 0 {
tempUsers = append(tempUsers, gms.TemporaryUser{
Username: config.ServerUser,
Password: config.ServerPass,
})
}

// Set up engine
engine := gms.New(analyzer.NewBuilder(pro).WithParallelism(parallelism).Build(), &gms.Config{IsReadOnly: config.IsReadOnly, TemporaryUsers: tempUsers, IsServerLocked: config.IsServerLocked}).WithBackgroundThreads(bThreads)
engine := gms.New(analyzer.NewBuilder(pro).WithParallelism(parallelism).Build(), &gms.Config{IsReadOnly: config.IsReadOnly, IsServerLocked: config.IsServerLocked}).WithBackgroundThreads(bThreads)
engine.Analyzer.Catalog.MySQLDb.SetPersister(persister)

engine.Analyzer.Catalog.MySQLDb.SetPlugins(map[string]mysql_db.PlaintextAuthPlugin{
"authentication_dolt_jwt": NewAuthenticateDoltJWTPlugin(config.JwksConfig),
})
Expand Down Expand Up @@ -400,6 +394,8 @@ func NewSqlEngineForEnv(ctx context.Context, dEnv *env.DoltEnv) (*SqlEngine, err
InitialDb: dbName,
IsReadOnly: false,
ServerUser: "root",
ServerPass: "",
ServerHost: "localhost",
Autocommit: false,
},
)
Expand Down

0 comments on commit 9623166

Please sign in to comment.