summaryrefslogtreecommitdiff
path: root/internal/server/institute
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2023-09-06 15:55:26 +0200
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2023-09-25 09:43:37 +0200
commit9697ea01b79cde6c8901d7853dc0b414acf84fa7 (patch)
tree2827e2328de82a59fb840905fbfe295342f3d97f /internal/server/institute
parent2e9dbcb863bf72239a80c7c33f6808d24c3ac69e (diff)
Server: Have separate implementations for refreshing endpoints
Diffstat (limited to 'internal/server/institute')
-rw-r--r--internal/server/institute/institute.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/server/institute/institute.go b/internal/server/institute/institute.go
index e0a52b7..46977ac 100644
--- a/internal/server/institute/institute.go
+++ b/internal/server/institute/institute.go
@@ -3,6 +3,7 @@ package institute
import (
"context"
+ "github.com/eduvpn/eduvpn-common/internal/discovery"
"github.com/eduvpn/eduvpn-common/internal/oauth"
"github.com/eduvpn/eduvpn-common/internal/server/api"
"github.com/eduvpn/eduvpn-common/internal/server/base"
@@ -98,6 +99,27 @@ func (s *Server) NeedsLocation() bool {
return false
}
+func (s *Server) RefreshEndpoints(ctx context.Context, _ *discovery.Discovery) error {
+ // Re-initialize the endpoints
+ b, err := s.Base()
+ if err != nil {
+ return err
+ }
+
+ err = api.Endpoints(ctx, b)
+ if err != nil {
+ return err
+ }
+
+ // update OAuth
+ auth := s.OAuth()
+ if auth != nil {
+ auth.BaseAuthorizationURL = b.Endpoints.API.V3.Authorization
+ auth.TokenURL = b.Endpoints.API.V3.Token
+ }
+ return nil
+}
+
func (s *Server) Public() (interface{}, error) {
return &server.Server{
DisplayName: s.Basic.DisplayName,