@@ -36,8 +36,8 @@ data OIDCAuth = OIDCAuth { issuerURL :: Text
36
36
, clientID :: Text
37
37
, clientSecret :: Text
38
38
, tlsParams :: TLS. ClientParams
39
- , idTokenMVar :: TVar (Maybe Text )
40
- , refreshTokenMVar :: TVar (Maybe Text )
39
+ , idTokenTVar :: TVar (Maybe Text )
40
+ , refreshTokenTVar :: TVar (Maybe Text )
41
41
}
42
42
43
43
-- | Cache OIDCAuth based on issuerURL and clientID.
@@ -55,7 +55,7 @@ getToken :: OIDCAuth -> IO Text
55
55
getToken o@ (OIDCAuth {.. }) = do
56
56
now <- getPOSIXTime
57
57
mgr <- newManager tlsManagerSettings
58
- idToken <- atomically $ readTVar idTokenMVar
58
+ idToken <- readTVarIO idTokenTVar
59
59
let maybeExp = idToken
60
60
& (>>= decode)
61
61
& (fmap claims)
@@ -68,7 +68,7 @@ getToken o@(OIDCAuth{..}) = do
68
68
69
69
fetchToken :: Manager -> OIDCAuth -> IO Text
70
70
fetchToken mgr o@ (OIDCAuth {.. }) = do
71
- maybeToken <- atomically $ readTVar refreshTokenMVar
71
+ maybeToken <- readTVarIO refreshTokenTVar
72
72
case maybeToken of
73
73
Nothing -> error " cannot refresh id-token without a refresh token"
74
74
Just token -> do
@@ -85,7 +85,7 @@ fetchToken mgr o@(OIDCAuth{..}) = do
85
85
case OAuth. idToken oauthToken of
86
86
Nothing -> error " token response did not contain an id_token, either the scope \" openid\" wasn't requested upon login, or the provider doesn't support id_tokens as part of the refresh response."
87
87
Just (IdToken t) -> do
88
- _ <- atomically $ writeTVar idTokenMVar (Just t)
88
+ _ <- atomically $ writeTVar idTokenTVar (Just t)
89
89
return t
90
90
91
91
fetchTokenEndpoint :: Manager -> OIDCAuth -> IO Text
@@ -116,7 +116,7 @@ oidcAuth _ _ = Nothing
116
116
-}
117
117
cachedOIDCAuth :: OIDCCache -> DetectAuth
118
118
cachedOIDCAuth cache AuthInfo {authProvider = Just (AuthProviderConfig " oidc" (Just cfg))} (tls, kubecfg) = Just $ do
119
- m <- atomically $ readTVar cache
119
+ m <- readTVarIO cache
120
120
o <- case findInCache m cfg of
121
121
Left e -> error e
122
122
Right (Just o) -> return o
@@ -137,8 +137,8 @@ findInCache cache cfg = do
137
137
parseOIDCAuthInfo :: Map Text Text -> IO (Either String OIDCAuth )
138
138
parseOIDCAuthInfo m = do
139
139
eitherTLSParams <- parseCA m
140
- idTokenMVar <- atomically $ newTVar $ Map. lookup " id-token" m
141
- refreshTokenMVar <- atomically $ newTVar $ Map. lookup " refresh-token" m
140
+ idTokenTVar <- atomically $ newTVar $ Map. lookup " id-token" m
141
+ refreshTokenTVar <- atomically $ newTVar $ Map. lookup " refresh-token" m
142
142
return $ do
143
143
tlsParams <- eitherTLSParams
144
144
issuerURL <- lookupEither m " idp-issuer-url"
0 commit comments