Skip to content

Commit

Permalink
fix(ui): fixed scroll on qr code page
Browse files Browse the repository at this point in the history
This commit is aimed to maximize the user experience and responsiveness
within the second page of the MFA enable dialog.
  • Loading branch information
luannmoreira authored and gustavosbarreto committed Dec 18, 2023
1 parent 79fe03b commit 6d6572f
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 348 deletions.
15 changes: 0 additions & 15 deletions .vscode/launch.json

This file was deleted.

17 changes: 12 additions & 5 deletions agent/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ require (
github.com/spf13/cobra v1.8.0
)

require (
github.com/labstack/gommon v0.4.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
)

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/GehirnInc/crypt v0.0.0-20230320061759-8cc1b52080c5 // indirect
Expand All @@ -30,23 +38,22 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/labstack/echo/v4 v4.10.2 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/leodido/go-urn v1.2.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-shellwords v1.0.12 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/sftp v1.13.5 // indirect
github.com/sethvargo/go-envconfig v0.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.6.0 // indirect
)

replace github.com/shellhub-io/shellhub => ../

replace github.com/gliderlabs/ssh => github.com/shellhub-io/ssh v0.0.0-20230224143412-edd48dfd6eea
12 changes: 6 additions & 6 deletions agent/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKoh
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
Expand All @@ -42,6 +40,7 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
Expand All @@ -57,8 +56,8 @@ github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxec
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
Expand All @@ -77,8 +76,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/rwtodd/Go.Sed v0.0.0-20210816025313-55464686f9ef/go.mod h1:8AEUvGVi2uQ5b24BIhcr0GCcpd/RNAFWaN2CJFrWIIQ=
github.com/sethvargo/go-envconfig v0.9.0 h1:Q6FQ6hVEeTECULvkJZakq3dZMeBQ3JUpcKMfPQbKMDE=
github.com/sethvargo/go-envconfig v0.9.0/go.mod h1:Iz1Gy1Sf3T64TQlJSvee81qDhf7YIlt8GMUX6yyNFs0=
github.com/shellhub-io/shellhub v0.13.4 h1:0fq+byvbMonlzVxh86cATv9sImvRj9UxDxN7+AWEriE=
github.com/shellhub-io/shellhub v0.13.4/go.mod h1:3pyZlaOgPZXZQumSA7B3IsA0O0Ppxgcec1zW1APLhXI=
github.com/shellhub-io/ssh v0.0.0-20230224143412-edd48dfd6eea h1:7tEI9nukSYZViCjdVMYyCM67hh4mcKfEEbraWmd9xGQ=
github.com/shellhub-io/ssh v0.0.0-20230224143412-edd48dfd6eea/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
Expand Down Expand Up @@ -140,6 +139,7 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down
Binary file removed api/routes/__debug_bin224019535
Binary file not shown.
84 changes: 28 additions & 56 deletions api/store/mongo/mfa_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,28 @@ func TestDeleteCodes(t *testing.T) {
defer db.Stop()

mongostore := NewStore(db.Client().Database("test"), cache.NewNullCache())
fixtures.Configure(&db)
fixtures.Init(db.Host, "test")

cases := []struct {
description string
username string
setup func() error
fixtures []string
expected error
}{
{
description: "success when try to delete codes",
username: "username",
setup: func() error {
return mongotest.UseFixture(fixtures.User)
},
expected: nil,
fixtures: []string{fixtures.FixtureUsers},
expected: nil,
},
}

for _, tc := range cases {
t.Run(tc.description, func(t *testing.T) {
err := tc.setup()
assert.NoError(t, err)
assert.NoError(t, fixtures.Apply(tc.fixtures...))
defer fixtures.Teardown() // nolint: errcheck

err = mongostore.DeleteCodes(ctx, tc.username)
err := mongostore.DeleteCodes(ctx, tc.username)
assert.Equal(t, tc.expected, err)

err = mongotest.DropDatabase()
Expand All @@ -57,52 +55,30 @@ func TestAddStatusMFA(t *testing.T) {
defer db.Stop()

mongostore := NewStore(db.Client().Database("test"), cache.NewNullCache())
fixtures.Configure(&db)
fixtures.Init(db.Host, "test")

cases := []struct {
description string
username string
status bool
setup func() error
fixtures []string
expected error
}{
{
description: "success when try to add status MFA",
username: "username",
status: true,
setup: func() error {
return mongotest.UseFixture(fixtures.User)
},
expected: nil,
fixtures: []string{fixtures.FixtureUsers},
expected: nil,
},
// {
// description: "fails when public key is not found due to tenant",
// fingerprint: "fingerprint",
// tenant: "nonexistent",
// tag: "tag0",
// setup: func() error {
// return mongotest.UseFixture(fixtures.PublicKey)
// },
// expected: store.ErrNoDocuments,
// },
// {
// description: "succeeds when public key is found",
// fingerprint: "fingerprint",
// tenant: "00000000-0000-4000-0000-000000000000",
// tag: "tag0",
// setup: func() error {
// return mongotest.UseFixture(fixtures.PublicKey)
// },
// expected: nil,
// },
}

for _, tc := range cases {
t.Run(tc.description, func(t *testing.T) {
err := tc.setup()
assert.NoError(t, err)
assert.NoError(t, fixtures.Apply(tc.fixtures...))
defer fixtures.Teardown() // nolint: errcheck

err = mongostore.AddStatusMFA(ctx, tc.username, tc.status)
err := mongostore.AddStatusMFA(ctx, tc.username, tc.status)
assert.Equal(t, tc.expected, err)

err = mongotest.DropDatabase()
Expand All @@ -118,32 +94,30 @@ func TestAddSecret(t *testing.T) {
defer db.Stop()

mongostore := NewStore(db.Client().Database("test"), cache.NewNullCache())
fixtures.Configure(&db)
fixtures.Init(db.Host, "test")

cases := []struct {
description string
username string
secret string
setup func() error
fixtures []string
expected error
}{
{
description: "success when try to add status MFA",
username: "username",
secret: "IOJDSFIAWMKXskdlmawOSDMCALWC",
setup: func() error {
return mongotest.UseFixture(fixtures.User)
},
expected: nil,
fixtures: []string{fixtures.FixtureUsers},
expected: nil,
},
}

for _, tc := range cases {
t.Run(tc.description, func(t *testing.T) {
err := tc.setup()
assert.NoError(t, err)
assert.NoError(t, fixtures.Apply(tc.fixtures...))
defer fixtures.Teardown() // nolint: errcheck

err = mongostore.AddSecret(ctx, tc.username, tc.secret)
err := mongostore.AddSecret(ctx, tc.username, tc.secret)
assert.Equal(t, tc.expected, err)

err = mongotest.DropDatabase()
Expand All @@ -159,30 +133,28 @@ func TestDeleteSecret(t *testing.T) {
defer db.Stop()

mongostore := NewStore(db.Client().Database("test"), cache.NewNullCache())
fixtures.Configure(&db)
fixtures.Init(db.Host, "test")

cases := []struct {
description string
username string
setup func() error
fixtures []string
expected error
}{
{
description: "success to delete a status MFA",
username: "username",
setup: func() error {
return mongotest.UseFixture(fixtures.User)
},
expected: nil,
fixtures: []string{fixtures.FixtureUsers},
expected: nil,
},
}

for _, tc := range cases {
t.Run(tc.description, func(t *testing.T) {
err := tc.setup()
assert.NoError(t, err)
assert.NoError(t, fixtures.Apply(tc.fixtures...))
defer fixtures.Teardown() // nolint: errcheck

err = mongostore.DeleteSecret(ctx, tc.username)
err := mongostore.DeleteSecret(ctx, tc.username)
assert.Equal(t, tc.expected, err)

err = mongotest.DropDatabase()
Expand Down
6 changes: 5 additions & 1 deletion cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
github.com/satori/go.uuid v1.2.0 // indirect
github.com/sethvargo/go-envconfig v0.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/square/mongo-lock v0.0.0-20201208161834-4db518ed7fb2 // indirect
github.com/square/mongo-lock v0.0.0-20230808145049-cfcf499f6bf0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
Expand All @@ -65,3 +65,7 @@ require (
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/shellhub-io/shellhub => ../

replace github.com/shellhub-io/shellhub/api => ../api
Loading

0 comments on commit 6d6572f

Please sign in to comment.