Skip to content

Commit

Permalink
Merge pull request #10 from trimble-oss/super_flex_v2
Browse files Browse the repository at this point in the history
Blanket check for super if host validation fails.
  • Loading branch information
joel-rieke authored Mar 6, 2024
2 parents 2f33f4c + 402b186 commit 6bc5051
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions sql/mysql_db/mysql_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,6 @@ func (db *MySQLDb) GetUser(user string, host string, roleSearch bool) *User {
if len(userEntries) == 1 {
readUserEntry := userEntries[0].(*User)

if host == readUserEntry.Host ||
(host == "127.0.0.1" && readUserEntry.Host == "localhost") ||
(host == "localhost" && readUserEntry.Host == "127.0.0.1") ||
(readUserEntry.Host == "%" && (!roleSearch || host == "")) {
if readUserEntry.IsSuperUser {
return readUserEntry
}
}

if lockTime, isLocked := lockUserMap.GetUser(readUserEntry); isLocked {
if time.Since(lockTime) > time.Hour {
readUserEntry.Locked = false
Expand All @@ -330,6 +321,9 @@ func (db *MySQLDb) GetUser(user string, host string, roleSearch bool) *User {
if hostIp != nil && network.Contains(hostIp) {
return readUserEntry
} else {
if readUserEntry.IsSuperUser {
return readUserEntry
}
return nil
}
} else {
Expand Down

0 comments on commit 6bc5051

Please sign in to comment.