Skip to content

Commit 33e6c33

Browse files
authored
Check passphrase randomness in G.Logout
1 parent 795cedc commit 33e6c33

37 files changed

Lines changed: 180 additions & 181 deletions

‎go/chat/server_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5956,7 +5956,7 @@ func kickTeamRekeyd(g *libkb.GlobalContext, t libkb.TestingTB) {
59565956

59575957
func logout(g *libkb.GlobalContext) error {
59585958
m := libkb.NewMetaContextBackground(g)
5959-
return m.Logout()
5959+
return m.LogoutKillSecrets()
59605960
}
59615961

59625962
func TestChatSrvUserResetAndDeleted(t *testing.T) {

‎go/client/cmd_deprovision.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package client
55

66
import (
77
"fmt"
8+
89
"github.com/keybase/cli"
910
"github.com/keybase/client/go/libcmdline"
1011
"github.com/keybase/client/go/libkb"
@@ -72,7 +73,9 @@ func (c *CmdDeprovision) GetUsage() libkb.Usage {
7273
}
7374
}
7475

75-
func (c *CmdDeprovision) ParseArgv(*cli.Context) error { return nil }
76+
func (c *CmdDeprovision) ParseArgv(ctx *cli.Context) error {
77+
return nil
78+
}
7679

7780
func (c *CmdDeprovision) getUsernameToDeprovision() (string, error) {
7881
configCli, err := GetConfigClient(c.G())

‎go/client/cmd_logout.go‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/keybase/cli"
88
"github.com/keybase/client/go/libcmdline"
99
"github.com/keybase/client/go/libkb"
10+
"github.com/keybase/client/go/protocol/keybase1"
1011
"golang.org/x/net/context"
1112
)
1213

@@ -25,13 +26,7 @@ func (v *CmdLogout) Run() error {
2526
return err
2627
}
2728
ctx := context.TODO()
28-
if !v.Force {
29-
err := ensureSetPassphraseFromRemote(libkb.NewMetaContextTODO(v.G()))
30-
if err != nil {
31-
return err
32-
}
33-
}
34-
return cli.Logout(ctx, 0)
29+
return cli.Logout(ctx, keybase1.LogoutArg{Force: v.Force})
3530
}
3631

3732
func NewCmdLogout(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
@@ -44,7 +39,7 @@ func NewCmdLogout(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Comman
4439
Flags: []cli.Flag{
4540
cli.BoolFlag{
4641
Name: "f, force",
47-
Usage: "If there are any reasons not to logout right now, ignore them",
42+
Usage: "If there are any reasons not to logout right now, ignore them (potentially dangerous)",
4843
},
4944
},
5045
}

‎go/client/cmd_signup.go‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,6 @@ func (s *CmdSignup) checkRegistered() (err error) {
256256
return
257257
}
258258

259-
err = ensureSetPassphraseFromRemote(libkb.NewMetaContextTODO(s.G()))
260-
if err != nil {
261-
return err
262-
}
263-
264259
if !s.doPrompt {
265260
return nil
266261
}

‎go/client/cmd_stress.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func (c *CmdStress) logout() {
279279
c.G().Log.Warning("GetLoginClient error: %s", err)
280280
return
281281
}
282-
err = cli.Logout(context.TODO(), 0)
282+
err = cli.Logout(context.TODO(), keybase1.LogoutArg{})
283283
if err != nil {
284284
c.G().Log.Warning("Logout error: %s", err)
285285
return

‎go/client/util.go‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎go/engine/account_delete.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ func (e *AccountDelete) Run(m libkb.MetaContext) error {
7070
return err
7171
}
7272
m.Debug("account deleted, logging out")
73-
return m.Logout()
73+
return m.LogoutWithOptions(libkb.LogoutOptions{KeepSecrets: false, Force: true})
7474
}

‎go/engine/common_test.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import (
88
"encoding/hex"
99
"errors"
1010
"fmt"
11+
"testing"
12+
1113
"github.com/keybase/client/go/externalstest"
1214
"github.com/keybase/client/go/libkb"
1315
"github.com/keybase/client/go/protocol/keybase1"
1416
insecureTriplesec "github.com/keybase/go-triplesec-insecure"
1517
"github.com/stretchr/testify/require"
16-
"testing"
1718
)
1819

1920
func SetupEngineTest(tb libkb.TestingTB, name string) libkb.TestContext {
@@ -317,7 +318,7 @@ func LoggedIn(tc libkb.TestContext) bool {
317318

318319
func Logout(tc libkb.TestContext) {
319320
mctx := libkb.NewMetaContextForTest(tc)
320-
if err := mctx.Logout(); err != nil {
321+
if err := mctx.LogoutKillSecrets(); err != nil {
321322
tc.T.Fatalf("logout error: %s", err)
322323
}
323324
}

‎go/engine/deprovision.go‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ import (
1313
// use this engine.
1414
type DeprovisionEngine struct {
1515
libkb.Contextified
16-
username libkb.NormalizedUsername
17-
doRevoke bool // requires being logged in already
16+
username libkb.NormalizedUsername
17+
doRevoke bool // requires being logged in already
18+
logoutOptions libkb.LogoutOptions
1819
}
1920

20-
func NewDeprovisionEngine(g *libkb.GlobalContext, username string, doRevoke bool) *DeprovisionEngine {
21+
func NewDeprovisionEngine(g *libkb.GlobalContext, username string, doRevoke bool, logoutOptions libkb.LogoutOptions) *DeprovisionEngine {
2122
return &DeprovisionEngine{
22-
Contextified: libkb.NewContextified(g),
23-
username: libkb.NewNormalizedUsername(username),
24-
doRevoke: doRevoke,
23+
Contextified: libkb.NewContextified(g),
24+
username: libkb.NewNormalizedUsername(username),
25+
doRevoke: doRevoke,
26+
logoutOptions: logoutOptions,
2527
}
2628
}
2729

@@ -82,7 +84,7 @@ func (e *DeprovisionEngine) attemptLoggedInRevoke(m libkb.MetaContext) error {
8284
}
8385

8486
m.UIs().LogUI.Info("Logging out...")
85-
if err = m.Logout(); err != nil {
87+
if err = m.LogoutWithOptions(e.logoutOptions); err != nil {
8688
m.Debug("DeprovisionEngine error during logout: %s", err)
8789
return err
8890
}

‎go/engine/deprovision_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func assertDeprovisionWithSetup(tc libkb.TestContext, targ assertDeprovisionWith
136136
expectedNumKeys -= 2
137137
}
138138

139-
e := NewDeprovisionEngine(tc.G, fu.Username, true /* doRevoke */)
139+
e := NewDeprovisionEngine(tc.G, fu.Username, true /* doRevoke */, libkb.LogoutOptions{})
140140
uis = libkb.UIs{
141141
LogUI: tc.G.UI.GetLogUI(),
142142
SecretUI: fu.NewSecretUI(),
@@ -267,11 +267,11 @@ func assertDeprovisionLoggedOut(tc libkb.TestContext) {
267267
// Unlike the first test, this time we log out before we run the
268268
// deprovision. We should be able to do a deprovision with revocation
269269
// disabled.
270-
if err := m.Logout(); err != nil {
270+
if err := m.LogoutKillSecrets(); err != nil {
271271
tc.T.Fatal(err)
272272
}
273273

274-
e := NewDeprovisionEngine(tc.G, fu.Username, false /* doRevoke */)
274+
e := NewDeprovisionEngine(tc.G, fu.Username, false /* doRevoke */, libkb.LogoutOptions{})
275275
uis = libkb.UIs{
276276
LogUI: tc.G.UI.GetLogUI(),
277277
SecretUI: fu.NewSecretUI(),
@@ -373,7 +373,7 @@ func assertCurrentDeviceRevoked(tc libkb.TestContext) {
373373
tc.T.Fatal(err)
374374
}
375375

376-
e := NewDeprovisionEngine(tc.G, fu.Username, true /* doRevoke */)
376+
e := NewDeprovisionEngine(tc.G, fu.Username, true /* doRevoke */, libkb.LogoutOptions{})
377377
uis = libkb.UIs{
378378
LogUI: tc.G.UI.GetLogUI(),
379379
SecretUI: fu.NewSecretUI(),

0 commit comments

Comments
 (0)