Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nc token revoke #728

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion daemon/rpc_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (r *RPC) Logout(ctx context.Context, in *pb.LogoutRequest) (payload *pb.Pay
return &pb.Payload{Type: internal.CodeFailure}, nil
}

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
6 changes: 2 additions & 4 deletions daemon/rpc_set_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ func (r *RPC) SetDefaults(ctx context.Context, in *pb.Empty) (*pb.Payload, error
log.Println(internal.WarningPrefix, err)
}

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

if err := r.cm.Reset(); err != nil {
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 @@ -542,7 +542,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 @@ -551,8 +551,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
Loading