File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
servant-auth/servant-auth-server/src/Servant/Auth/Server/Internal Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change
1
+ synopsis: Allow IO in validationKeys
2
+ prs: #1580
3
+ issues: #1579
4
+
5
+ description: {
6
+
7
+ Currently validationKeys are a fixed JWKSet. This does not work with OIDC
8
+ providers such as AWS Cognito or Okta, which regularly fetching jwks_uri to
9
+ discover new and expired keys.
10
+
11
+ This change alters the type of validationKeys from JWKSet to IO JWKSet.
12
+ }
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ data JWTSettings = JWTSettings
33
33
-- | Algorithm used to sign JWT.
34
34
, jwtAlg :: Maybe Jose. Alg
35
35
-- | Keys used to validate JWT.
36
- , validationKeys :: Jose. JWKSet
36
+ , validationKeys :: IO Jose. JWKSet
37
37
-- | An @aud@ predicate. The @aud@ is a string or URI that identifies the
38
38
-- intended recipient of the JWT.
39
39
, audienceMatches :: Jose. StringOrURI -> IsMatch
@@ -44,7 +44,7 @@ defaultJWTSettings :: Jose.JWK -> JWTSettings
44
44
defaultJWTSettings k = JWTSettings
45
45
{ signingKey = k
46
46
, jwtAlg = Nothing
47
- , validationKeys = Jose. JWKSet [k]
47
+ , validationKeys = pure $ Jose. JWKSet [k]
48
48
, audienceMatches = const Matches }
49
49
50
50
-- | The policies to use when generating cookies.
Original file line number Diff line number Diff line change @@ -58,14 +58,15 @@ makeJWT v cfg expiry = runExceptT $ do
58
58
59
59
verifyJWT :: FromJWT a => JWTSettings -> BS. ByteString -> IO (Maybe a )
60
60
verifyJWT jwtCfg input = do
61
- verifiedJWT <- liftIO $ runExceptT $ do
61
+ keys <- validationKeys jwtCfg
62
+ verifiedJWT <- runExceptT $ do
62
63
unverifiedJWT <- Jose. decodeCompact (BSL. fromStrict input)
63
64
Jose. verifyClaims
64
65
(jwtSettingsToJwtValidationSettings jwtCfg)
65
- (validationKeys jwtCfg)
66
+ keys
66
67
unverifiedJWT
67
68
return $ case verifiedJWT of
68
69
Left (_ :: Jose. JWTError ) -> Nothing
69
70
Right v -> case decodeJWT v of
70
71
Left _ -> Nothing
71
- Right v' -> Just v'
72
+ Right v' -> Just v'
You can’t perform that action at this time.
0 commit comments