@@ -44,13 +44,13 @@ func (a *ClientProvider) createAuthJwks(cert string) error {
4444
4545func (a * ClientProvider ) getPemCert (token * jwt.Token , refreshJwks bool ) (string , error ) {
4646 cert := ""
47- cert , expired , err := a .getCachedJwks ()
47+ cert , err := a .getCachedJwks ()
4848 if err != nil {
4949 return cert , err
5050 }
5151
52- // check if the cache expired as well is not invoked via refresh token cron
53- if refreshJwks || expired {
52+ // check if the refresh jwks cache flag coming from the refresh cron is set to true
53+ if refreshJwks {
5454 _ , resp , err := a .httpClient .Request (fmt .Sprintf ("%s/oauth/.well-known/jwks.json" , a .AuthURL ), "GET" , nil , nil , nil )
5555 if err != nil {
5656 return cert , err
@@ -82,8 +82,7 @@ func (a *ClientProvider) getPemCert(token *jwt.Token, refreshJwks bool) (string,
8282 return cert , nil
8383}
8484
85- func (a * ClientProvider ) getCachedJwks () (string , bool , error ) {
86- expired := true
85+ func (a * ClientProvider ) getCachedJwks () (string , error ) {
8786 res , err := a .esClient .Search (strings .TrimSpace (auth0JwksCache + a .Environment ), searchJwksQuery )
8887 if err != nil {
8988 go func () {
@@ -92,27 +91,23 @@ func (a *ClientProvider) getCachedJwks() (string, bool, error) {
9291 fmt .Println ("Err: send to slack: " , err )
9392 }()
9493
95- return "" , expired , err
94+ return "" , err
9695 }
9796
9897 var e ESJwksSchema
9998 err = json .Unmarshal (res , & e )
10099 if err != nil {
101100 log .Println ("repository: GetOauthJwks: could not unmarshal the data" , err )
102- return "" , expired , err
101+ return "" , err
103102 }
104103
105104 if len (e .Hits .Hits ) > 0 {
106105 data := e .Hits .Hits [0 ]
107- // compare current time v/s existing cached time + 30 mins
108- if data .Source .CreatedAt .Add (30 * time .Minute ).Unix () > time .Now ().UTC ().Unix () {
109- expired = false
110- }
111106
112- return data .Source .Jwks , expired , nil
107+ return data .Source .Jwks , nil
113108 }
114109
115- return "" , expired , errors .New ("GetJwks: could not find the associated jwks" )
110+ return "" , errors .New ("GetJwks: could not find the associated jwks" )
116111}
117112
118113var searchJwksQuery = map [string ]interface {}{
0 commit comments