summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2023-04-12 22:53:57 +0200
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2023-09-25 09:43:37 +0200
commit97308a5b0f1f930220be889be5c486328af104d0 (patch)
tree2239a248aed4ce722480d2af313da9d61d62f400
parenta23c3e61c5d89ef67973891b5b3a176c06e1b174 (diff)
OAuth: Implement the Public() method for tokens
-rw-r--r--internal/oauth/token.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/oauth/token.go b/internal/oauth/token.go
index a3d0d3b..251b689 100644
--- a/internal/oauth/token.go
+++ b/internal/oauth/token.go
@@ -7,6 +7,7 @@ import (
"time"
"github.com/eduvpn/eduvpn-common/internal/log"
+ "github.com/eduvpn/eduvpn-common/types/server"
"github.com/go-errors/errors"
)
@@ -38,6 +39,14 @@ type Token struct {
ExpiredTimestamp time.Time
}
+func (t *Token) Public() server.Tokens {
+ return server.Tokens{
+ Access: t.Access,
+ Refresh: t.Refresh,
+ Expires: t.ExpiredTimestamp.Unix(),
+ }
+}
+
// tokenRefresher is a structure that contains our access and refresh tokens and a timestamp when they expire.
// Additionally, it contains the refresher to get new tokens
type tokenRefresher struct {