Skip to content

Commit 1daacd9

Browse files
committed
refactor: Remove redundant VANull constructor
1 parent 50aaf46 commit 1daacd9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/PostgREST/Auth/Jwt.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ instance JSON.FromJSON StringOrURI where
6262
where
6363
isValidURI = (||) <$> not . T.isInfixOf ":" <*> isURI . T.unpack
6464

65-
data ValidAud = VANull | VAString StringOrURI | VAArray [StringOrURI] deriving Generic
65+
data ValidAud = VAString StringOrURI | VAArray [StringOrURI] deriving Generic
6666
instance JSON.FromJSON ValidAud where
67-
parseJSON JSON.Null = pure VANull
68-
parseJSON o = JSON.genericParseJSON JSON.defaultOptions { JSON.sumEncoding = JSON.UntaggedValue } o
67+
parseJSON = JSON.genericParseJSON JSON.defaultOptions { JSON.sumEncoding = JSON.UntaggedValue }
6968

7069
checkForErrors :: (Applicative m, Monoid (m JwtClaimsError)) => UTCTime -> (Text -> Bool) -> JSON.Object -> m JwtClaimsError
7170
checkForErrors time audMatches = mconcat
@@ -89,7 +88,6 @@ checkForErrors time audMatches = mconcat
8988
validAud = \case
9089
(VAString aud) -> validAudString aud
9190
(VAArray auds) -> null auds || any validAudString auds
92-
_ -> True
9391
validAudString = audMatches . unStringOrURI
9492

9593
checkValue invalid msg val =
@@ -100,6 +98,7 @@ checkForErrors time audMatches = mconcat
10098

10199
claim key parseError checkParsed = maybe (pure parseError) (maybe mempty checkParsed) . parseMaybe (.:? key)
102100

101+
103102
-- | Receives the JWT secret and audience (from config) and a JWT and returns a
104103
-- JSON object of JWT claims.
105104
parseToken :: (MonadError Error m, MonadIO m) => JwkSet -> ByteString -> m JWT.JwtContent

0 commit comments

Comments
 (0)