fix lint
This commit is contained in:
parent
a48f4238e7
commit
4e31b0b4c3
3 changed files with 7 additions and 9 deletions
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a authyClient) findAuthyId(user string) (string, error) {
|
func (a authyClient) findAuthyID(user string) (string, error) {
|
||||||
// TODO a better way to handle large database
|
// TODO a better way to handle large database
|
||||||
|
|
||||||
file, err := os.Open(a.Config.File)
|
file, err := os.Open(a.Config.File)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ hook 789
|
||||||
`), os.ModePerm)
|
`), os.ModePerm)
|
||||||
|
|
||||||
{
|
{
|
||||||
id, err := a.findAuthyId("piper")
|
id, err := a.findAuthyID("piper")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("findId failed %v", err)
|
t.Fatalf("findId failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -36,7 +36,7 @@ hook 789
|
||||||
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
id, err := a.findAuthyId("hook")
|
id, err := a.findAuthyID("hook")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("findId failed %v", err)
|
t.Fatalf("findId failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ type authyClient struct {
|
||||||
Config struct {
|
Config struct {
|
||||||
APIKey string `long:"challenger-authy-apikey" description:"Authy API Key" env:"SSHPIPERD_CHALLENGER_AUTHY_APIKEY" ini-name:"challenger-authy-apikey"`
|
APIKey string `long:"challenger-authy-apikey" description:"Authy API Key" env:"SSHPIPERD_CHALLENGER_AUTHY_APIKEY" ini-name:"challenger-authy-apikey"`
|
||||||
Method string `long:"challenger-authy-method" default:"token" description:"Authy authentication method" env:"SSHPIPERD_CHALLENGER_AUTHY_METHOD" ini-name:"challenger-authy-method" choice:"token" choice:"onetouch"`
|
Method string `long:"challenger-authy-method" default:"token" description:"Authy authentication method" env:"SSHPIPERD_CHALLENGER_AUTHY_METHOD" ini-name:"challenger-authy-method" choice:"token" choice:"onetouch"`
|
||||||
File string `long:"challenger-authy-idfile" description:"Path to a file with ssh_name [space] authy_id per line (first line win if duplicate)" env:"SSHPIPERD_CHALLENGER_AUTHY_IDFILE" ini-name:"challenger-authy-idfile"`
|
File string `long:"challenger-authy-idfile" description:"Path to a file with ssh_name [space] authy_id per line (first line win if duplicate)" env:"SSHPIPERD_CHALLENGER_AUTHY_IDFILE" ini-name:"challenger-authy-idfile"`
|
||||||
}
|
}
|
||||||
|
|
||||||
authyAPI *authy.Authy
|
authyAPI *authy.Authy
|
||||||
|
|
@ -32,7 +32,7 @@ func (a *authyClient) Init(logger *log.Logger) error {
|
||||||
func (a *authyClient) challenge(conn ssh.ConnMetadata, client ssh.KeyboardInteractiveChallenge) (ssh.AdditionalChallengeContext, error) {
|
func (a *authyClient) challenge(conn ssh.ConnMetadata, client ssh.KeyboardInteractiveChallenge) (ssh.AdditionalChallengeContext, error) {
|
||||||
user := conn.User()
|
user := conn.User()
|
||||||
|
|
||||||
authyId, err := a.findAuthyId(user)
|
authyID, err := a.findAuthyID(user)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -46,7 +46,7 @@ func (a *authyClient) challenge(conn ssh.ConnMetadata, client ssh.KeyboardIntera
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
verification, err := a.authyAPI.VerifyToken(authyId, ans[0], url.Values{})
|
verification, err := a.authyAPI.VerifyToken(authyID, ans[0], url.Values{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -67,7 +67,7 @@ func (a *authyClient) challenge(conn ssh.ConnMetadata, client ssh.KeyboardIntera
|
||||||
"ClientIP": conn.RemoteAddr().String(),
|
"ClientIP": conn.RemoteAddr().String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
approvalRequest, err := a.authyAPI.SendApprovalRequest(authyId, "Log to SSH server", details, url.Values{})
|
approvalRequest, err := a.authyAPI.SendApprovalRequest(authyID, "Log to SSH server", details, url.Values{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -92,5 +92,3 @@ func (a *authyClient) challenge(conn ssh.ConnMetadata, client ssh.KeyboardIntera
|
||||||
return nil, fmt.Errorf("unsupported authy method")
|
return nil, fmt.Errorf("unsupported authy method")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue