You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnnil, defaultErrors.New("No SuperTokens core available to query. Please pass supertokens > connectionURI to the init function, or override all the functions of the recipe you are using.")
78
+
}
79
+
80
+
resultFromCache:=getJWKSFromCacheIfPresent()
81
+
82
+
ifresultFromCache!=nil {
83
+
returnresultFromCache.JWKS, nil
84
+
}
85
+
86
+
varlastErrorerror
87
+
88
+
mutex.Lock()
89
+
defermutex.Unlock()
50
90
for_, path:=rangecorePaths {
51
-
// RefreshUnknownKID - Fetch JWKS again if the kid in the header of the JWT does not match any in cache
52
-
// RefreshRateLimit - Only allow one re-fetch every 500 milliseconds
53
-
// RefreshInterval - Refreshes should occur every 600 seconds
// Dont add to cache if there is an error to keep the logic of checking cache simple
109
+
//
110
+
// This also has the added benefit where if initially the request failed because the core
111
+
// was down and then it comes back up, the next time it will try to request that core again
112
+
// after the cache has expired
113
+
jwksCache=&jwksResult
114
+
115
+
ifsupertokens.IsRunningInTestMode() {
116
+
returnedFromCache=false
117
+
}
118
+
119
+
returnjwksResult.JWKS, nil
120
+
}
121
+
122
+
lastError=jwksError
64
123
}
65
124
66
-
returnresult
125
+
// This means that fetching from all cores failed
126
+
returnnil, lastError
67
127
}
68
128
69
129
/**
@@ -74,29 +134,21 @@ Every core instance a backend is connected to is expected to connect to the same
74
134
token verification. Otherwise, the result of session verification would depend on which core is currently available.
75
135
*/
76
136
funcGetCombinedJWKS() (*keyfunc.JWKS, error) {
77
-
varlastErrorerror
78
-
79
-
iflen(jwksResults) ==0 {
80
-
returnnil, defaultErrors.New("No SuperTokens core available to query. Please pass supertokens > connectionURI to the init function, or override all the functions of the recipe you are using.")
0 commit comments