diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/discovery/discovery.go | 15 | ||||
| -rw-r--r-- | internal/server/secureinternet.go | 4 |
2 files changed, 10 insertions, 9 deletions
diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go index 383a696..daa08e8 100644 --- a/internal/discovery/discovery.go +++ b/internal/discovery/discovery.go @@ -148,14 +148,18 @@ func (discovery *Discovery) MarkOrganizationsExpired() { } // DetermineOrganizationsUpdate returns a boolean indicating whether or not the discovery organizations should be updated -// FIXME: Implement based on // https://github.com/eduvpn/documentation/blob/v3/SERVER_DISCOVERY.md // - [IMPLEMENTED] on "first launch" when offering the search for "Institute Access" and "Organizations"; -// - [IMPLEMENTED in client/server.go] when the user tries to add new server AND the user did NOT yet choose an organization before; -// - [IMPLEMENTED in client/server.go] when the authorization for the server associated with an already chosen organization is triggered, e.g. after expiry or revocation. -// - [IMPLEMENTED using a custom error message, and in client/server.go] NOTE: when the org_id that the user chose previously is no longer available in organization_list.json the application should ask the user to choose their organization (again). This can occur for example when the organization replaced their identity provider, uses a different domain after rebranding or simply ceased to exist. +// - [IMPLEMENTED in client/client.go and here] when the user tries to add new server AND the user did NOT yet choose an organization before; We cannot really differentiate between adding a new server and when the function is called at random so we have a 4 hour cache +// - [IMPLEMENTED in client/client.go] when the authorization for the server associated with an already chosen organization is triggered, e.g. after expiry or revocation. +// - [IMPLEMENTED here] NOTE: when the org_id that the user chose previously is no longer available in organization_list.json the application should ask the user to choose their organization (again). This can occur for example when the organization replaced their identity provider, uses a different domain after rebranding or simply ceased to exist. func (discovery *Discovery) DetermineOrganizationsUpdate() bool { - return discovery.OrganizationList.Timestamp.IsZero() + if discovery.OrganizationList.Timestamp.IsZero() { + return true + } + // 4 hour since the last update + upd := discovery.OrganizationList.Timestamp.Add(4 * time.Hour) + return !time.Now().Before(upd) } // SecureLocationList returns a slice of all the available locations. @@ -228,6 +232,7 @@ func (discovery *Discovery) SecureHomeArgs(orgID string) (*Organization, *Server // Get a server with the base url srv, err := discovery.ServerByURL(org.SecureInternetHome, "secure_internet") if err != nil { + discovery.MarkOrganizationsExpired() return nil, nil, err } return org, srv, nil diff --git a/internal/server/secureinternet.go b/internal/server/secureinternet.go index 746dd4f..0571e5f 100644 --- a/internal/server/secureinternet.go +++ b/internal/server/secureinternet.go @@ -25,10 +25,6 @@ func (s *Servers) AddSecure(ctx context.Context, disco *discovery.Discovery, org } dorg, dsrv, err := disco.SecureHomeArgs(orgID) if err != nil { - // We mark the organizations as expired because we got an error - // Note that in the docs it states that it only should happen when the Org ID doesn't exist - // However, this is nice as well because it also catches the error where the SecureInternetHome server is not found - disco.MarkOrganizationsExpired() return err } |
