summaryrefslogtreecommitdiff
path: root/client/client.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2023-03-29 11:58:46 +0200
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2023-04-18 14:05:19 +0200
commit537a09d4334f1555b80d87b7d935328963a21739 (patch)
tree071eeb52a4ed79a1e1b49831c80d6a2336cee7cf /client/client.go
parent61871cb9ea7605e5350e9612edf8c9d603da2883 (diff)
Client + Server: Implement a token updater callback
Diffstat (limited to 'client/client.go')
-rw-r--r--client/client.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/client/client.go b/client/client.go
index 2bb0cc2..89db8f5 100644
--- a/client/client.go
+++ b/client/client.go
@@ -11,6 +11,7 @@ import (
"github.com/eduvpn/eduvpn-common/internal/fsm"
"github.com/eduvpn/eduvpn-common/internal/http"
"github.com/eduvpn/eduvpn-common/internal/log"
+ "github.com/eduvpn/eduvpn-common/internal/oauth"
"github.com/eduvpn/eduvpn-common/internal/server"
"github.com/eduvpn/eduvpn-common/internal/util"
"github.com/eduvpn/eduvpn-common/types"
@@ -116,6 +117,30 @@ type Client struct {
// The Failover monitor for the current VPN connection
Failover *failover.DroppedConMon `json:"-"`
+
+ // tokenCB is the token callback
+ tokenCB func(srv server.Server, tok oauth.Token)
+}
+
+func (c *Client) ForwardTokenUpdate(srv server.Server) {
+ if c.tokenCB == nil {
+ log.Logger.Debugf("No token update callback available")
+ return
+ }
+ t := oauth.Token{}
+ o := srv.OAuth()
+ if o != nil {
+ t = o.Token()
+ } else {
+ log.Logger.Debugf("OAuth was nil when forwarding token callback")
+ }
+ log.Logger.Debugf("Running token callback")
+ c.tokenCB(srv, t)
+}
+
+// SetTokenUpdater sets the token updater callback
+func (c *Client) SetTokenUpdater(updater func(srv server.Server, tok oauth.Token)) {
+ c.tokenCB = updater
}
// Register initializes the clientwith the following parameters: