mirror of https://gogs.blitter.com/RLabs/xs
Added validation user actually exists on system
This commit is contained in:
parent
420e0319ca
commit
cb7a79063e
15
hkexauth.go
15
hkexauth.go
|
@ -22,6 +22,15 @@ import (
|
||||||
"github.com/jameskeane/bcrypt"
|
"github.com/jameskeane/bcrypt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func userExistsOnSystem(who string) bool {
|
||||||
|
_, userErr := user.Lookup(who)
|
||||||
|
if userErr != nil {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func AuthUserByPasswd(username string, auth string, fname string) (valid bool, allowedCmds string) {
|
func AuthUserByPasswd(username string, auth string, fname string) (valid bool, allowedCmds string) {
|
||||||
b, e := ioutil.ReadFile(fname)
|
b, e := ioutil.ReadFile(fname)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
@ -66,6 +75,9 @@ func AuthUserByPasswd(username string, auth string, fname string) (valid bool, a
|
||||||
r = nil
|
r = nil
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
|
|
||||||
|
if !userExistsOnSystem(username) {
|
||||||
|
valid = false
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,5 +114,8 @@ func AuthUserByToken(username string, connhostname string, auth string) (valid b
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !userExistsOnSystem(username) {
|
||||||
|
valid = false
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue