mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-01 10:09:41 -06:00
Remove server config user check
This commit is contained in:
@@ -16,7 +16,6 @@ package sqlserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/subtle"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -258,7 +257,7 @@ func Serve(
|
||||
})
|
||||
|
||||
ctxFactory := func() (*sql.Context, error) { return sqlEngine.NewDefaultContext(ctx) }
|
||||
authenticator := newAuthenticator(ctxFactory, serverConfig, sqlEngine.GetUnderlyingEngine().Analyzer.Catalog.MySQLDb)
|
||||
authenticator := newAuthenticator(ctxFactory, sqlEngine.GetUnderlyingEngine().Analyzer.Catalog.MySQLDb)
|
||||
args = sqle.WithUserPasswordAuth(args, authenticator)
|
||||
|
||||
args.TLSConfig = serverConf.TLSConfig
|
||||
@@ -367,21 +366,15 @@ func Serve(
|
||||
}
|
||||
|
||||
type remotesapiAuth struct {
|
||||
ctxFactory func() (*sql.Context, error)
|
||||
serverConfig ServerConfig
|
||||
rawDb *mysql_db.MySQLDb
|
||||
ctxFactory func() (*sql.Context, error)
|
||||
rawDb *mysql_db.MySQLDb
|
||||
}
|
||||
|
||||
func newAuthenticator(ctxFactory func() (*sql.Context, error), serverConfig ServerConfig, rawDb *mysql_db.MySQLDb) remotesrv.Authenticator {
|
||||
return &remotesapiAuth{ctxFactory, serverConfig, rawDb}
|
||||
func newAuthenticator(ctxFactory func() (*sql.Context, error), rawDb *mysql_db.MySQLDb) remotesrv.Authenticator {
|
||||
return &remotesapiAuth{ctxFactory, rawDb}
|
||||
}
|
||||
|
||||
func (r *remotesapiAuth) Authenticate(creds *remotesrv.RequestCredentials) bool {
|
||||
if r.serverConfig.User() == creds.Username {
|
||||
compare := subtle.ConstantTimeCompare([]byte(r.serverConfig.Password()), []byte(creds.Password))
|
||||
return compare != 0
|
||||
}
|
||||
|
||||
user := r.rawDb.GetUser(creds.Username, "%", false)
|
||||
if user == nil {
|
||||
return false
|
||||
|
||||
@@ -165,6 +165,7 @@ SQL
|
||||
mkdir remote
|
||||
cd remote
|
||||
dolt init
|
||||
dolt --privilege-file=privs.json sql -q "CREATE USER user IDENTIFIED BY 'pass0'"
|
||||
dolt sql -q 'create table vals (i int);'
|
||||
dolt sql -q 'insert into vals (i) values (1), (2), (3), (4), (5);'
|
||||
dolt add vals
|
||||
|
||||
Reference in New Issue
Block a user