finish OTP code
This commit is contained in:
16
otp.go
16
otp.go
@@ -14,11 +14,19 @@ func (s *OpenVpnMgt) GenerateOTP(user string) ([]string, error) {
|
||||
// }
|
||||
|
||||
func (s *OpenVpnMgt) TokenPassword(c *vpnSession) (bool, string) {
|
||||
//TODO implement that correcly
|
||||
if c.password == "maith1wiePuw3ieb4heiNie5y" {
|
||||
return true, "maith1wiePuw3ieb4heiNie5y"
|
||||
now := time.Now().Unix()
|
||||
if len(c.password) > 40 {
|
||||
salt := c.password[:4]
|
||||
for i := 0; i < 3; i++ {
|
||||
test := encode64(ComputeHmac256(c.baseHash(salt, now/30-int64(i)), s.otpMasterSecrets[0]))
|
||||
if salt+test == c.password {
|
||||
return true, c.password
|
||||
}
|
||||
}
|
||||
}
|
||||
return false, "maith1wiePuw3ieb4heiNie5y"
|
||||
|
||||
salt := NewSalt()
|
||||
return false, salt + encode64(ComputeHmac256(c.baseHash(salt, now/30), s.otpMasterSecrets[0]))
|
||||
}
|
||||
|
||||
func (s *OpenVpnMgt) GenerateOTPGeneric(user string, period int, algo string, secretLen int, digits int) ([]string, error) {
|
||||
|
||||
Reference in New Issue
Block a user