summaryrefslogtreecommitdiff
path: root/internal/server/institute.go
diff options
context:
space:
mode:
authorJeroen Wijenbergh <jeroenwijenbergh@protonmail.com>2024-05-08 11:49:19 +0200
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2024-05-08 13:54:45 +0000
commit9ce4e4458794290755c68a180125acc68ab84038 (patch)
treed4211e55bd77d07938651619733c7b435597d53a /internal/server/institute.go
parent580f94b4023fba35ab2f58d2e6d7b3b7c40ec139 (diff)
Server: Add a way to pass OAuth start time
Diffstat (limited to 'internal/server/institute.go')
-rw-r--r--internal/server/institute.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/internal/server/institute.go b/internal/server/institute.go
index 7cb399f..caae004 100644
--- a/internal/server/institute.go
+++ b/internal/server/institute.go
@@ -2,6 +2,7 @@ package server
import (
"context"
+ "time"
"github.com/eduvpn/eduvpn-common/internal/api"
"github.com/eduvpn/eduvpn-common/internal/config/v2"
@@ -15,8 +16,8 @@ import (
// `ctx` is the context used for cancellation
// `disco` are the discovery servers
// `id` is the identifier for the server, the base url
-// `na` is true when authorization should not be triggered
-func (s *Servers) AddInstitute(ctx context.Context, disco *discovery.Discovery, id string, na bool) error {
+// `ot` specifies specifies the start time OAuth was already triggered
+func (s *Servers) AddInstitute(ctx context.Context, disco *discovery.Discovery, id string, ot *int64) error {
// This is basically done to double check if the server is part of the institute access section of disco
dsrv, err := disco.ServerByURL(id, "institute_access")
if err != nil {
@@ -30,13 +31,20 @@ func (s *Servers) AddInstitute(ctx context.Context, disco *discovery.Discovery,
BaseAuthWK: dsrv.BaseURL,
}
- err = s.config.AddServer(dsrv.BaseURL, server.TypeInstituteAccess, v2.Server{})
+ auth := time.Time{}
+ if ot != nil {
+ auth = time.Unix(*ot, 0)
+ }
+
+ err = s.config.AddServer(dsrv.BaseURL, server.TypeInstituteAccess, v2.Server{
+ LastAuthorizeTime: auth,
+ })
if err != nil {
return err
}
// no authorization should be triggered, return
- if na {
+ if ot != nil {
return nil
}