From 9ce4e4458794290755c68a180125acc68ab84038 Mon Sep 17 00:00:00 2001 From: Jeroen Wijenbergh Date: Wed, 8 May 2024 11:49:19 +0200 Subject: Server: Add a way to pass OAuth start time --- internal/server/institute.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'internal/server/institute.go') 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 } -- cgit v1.2.3