Skip to content

Commit

Permalink
Always purge NC token when revoking
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszWojciechO committed Jan 7, 2025
1 parent 3d0d8bf commit b2e1ae4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion daemon/rpc_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (r *RPC) Logout(ctx context.Context, in *pb.LogoutRequest) (payload *pb.Pay
}
}

if !r.ncClient.Revoke(internal.IsDevEnv(string(r.environment))) {
if !r.ncClient.Revoke() {
log.Println(internal.WarningPrefix, "error revoking NC token")
}

Expand Down
4 changes: 2 additions & 2 deletions daemon/rpc_logout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type mockNC struct {
nc.NotificationClient
}

func (mockNC) Stop() error { return nil }
func (mockNC) Revoke(bool) bool { return true }
func (mockNC) Stop() error { return nil }
func (mockNC) Revoke() bool { return true }

type mockApi struct {
core.CombinedAPI
Expand Down
2 changes: 1 addition & 1 deletion daemon/rpc_set_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (r *RPC) SetDefaults(ctx context.Context, in *pb.Empty) (*pb.Payload, error
}

if internal.IsDevEnv(string(r.environment)) {
if !r.ncClient.Revoke(true) {
if !r.ncClient.Revoke() {
log.Println(internal.WarningPrefix, "error revoking token")
}
}
Expand Down
7 changes: 3 additions & 4 deletions nc/nc.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type AcknowledgementPayload struct {
type NotificationClient interface {
Start() error
Stop() error
Revoke(bool) bool
Revoke() bool
}

type ClientBuilder interface {
Expand Down Expand Up @@ -486,7 +486,7 @@ func (c *Client) Stop() error {
}

// Revoke revokes the NC communication token
func (c *Client) Revoke(purgeSession bool) bool {
func (c *Client) Revoke() bool {
c.startMu.Lock()
defer c.startMu.Unlock()

Expand All @@ -495,8 +495,7 @@ func (c *Client) Revoke(purgeSession bool) bool {
return false
}

log.Println(logPrefix, "revoking token, purgeSession:", purgeSession)
ok, err := c.credsFetcher.RevokeCredentials(purgeSession)
ok, err := c.credsFetcher.RevokeCredentials(true)
if ok {
log.Println(logPrefix, "token revoked successfully")
return true
Expand Down

0 comments on commit b2e1ae4

Please sign in to comment.