diff --git a/authcollection.go b/authcollection.go index 7108972..fb78dd7 100644 --- a/authcollection.go +++ b/authcollection.go @@ -97,45 +97,7 @@ func (ac *redisAuthCell) ToBytes() []byte { } func newAuthCollectionWithRedis(redisClient *redis.Client, subctx context.Context, maingateURL string, apiToken string) *AuthCollection { - req, _ := http.NewRequest("GET", fmt.Sprintf("%s/config", maingateURL), nil) - req.Header.Add("MG-X-API-TOKEN", apiToken) - sessionTTL := int64(3600) - client := http.Client{ - Timeout: 3 * time.Second, - } - resp, err := client.Do(req) - if resp != nil { - defer resp.Body.Close() - } - - if err != nil { - if !*devflag { - logger.Error("get maingate config failed :", err) - return nil - } - } else if resp.StatusCode == http.StatusOK { - raw, _ := io.ReadAll(resp.Body) - if len(raw) == 0 { - logger.Error("get maingate config failed :", err) - return nil - } - - var config map[string]any - err = json.Unmarshal(raw, &config) - if err != nil { - logger.Error("get maingate config failed :", err) - return nil - } - - if ttl, ok := config["maingate_session_ttl"].(float64); ok { - sessionTTL = int64(ttl) - } - } else if !*devflag { - logger.Error("get maingate config failed :", err) - return nil - } - ac := MakeAuthCollection(time.Duration(sessionTTL * int64(time.Second))) pubsub := redisClient.Subscribe(subctx, sessionSyncChannelName) ctx, cancel := context.WithCancel(context.TODO())