Remove server config user check

This commit is contained in:
Taylor Bantle
2023-07-24 14:16:02 -07:00
parent 7f77fe132a
commit c0d27320db
2 changed files with 6 additions and 12 deletions

View File

@@ -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

View File

@@ -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