@@ -76,7 +76,7 @@ type API =
76
76
:<|> APIAuthReq'
77
77
:<|> APIAuthResp'
78
78
79
- api :: forall err m . SPHandler (Error err ) m => ST -> HandleVerdict m -> ServerT API m
79
+ api :: forall err m . ( SPHandler (Error err ) m ) => ST -> HandleVerdict m -> ServerT API m
80
80
api appName handleVerdict =
81
81
meta appName defSPIssuer defResponseURI
82
82
:<|> authreq' defSPIssuer
@@ -124,8 +124,8 @@ parseAuthnResponseBody mbSPId base64 = do
124
124
-- rejecting some noise characters and ignoring others.
125
125
let xmltxt :: LBS = EL. decodeLenient (cs base64 :: LBS )
126
126
resp <-
127
- either (throwError . BadSamlResponseXmlError . cs) pure $
128
- decode (cs xmltxt)
127
+ either (throwError . BadSamlResponseXmlError . cs) pure
128
+ $ decode (cs xmltxt)
129
129
issuer <- maybe (throwError BadSamlResponseIssuerMissing ) pure (resp ^. rspIssuer)
130
130
idp :: IdPConfig extra <- getIdPConfigByIssuerOptionalSPId issuer mbSPId
131
131
creds <- idpToCreds issuer idp
@@ -145,11 +145,11 @@ instance FromMultipart Mem AuthnResponseBody where
145
145
m (AuthnResponse , IdPConfig extra )
146
146
eval mbSPId = do
147
147
base64 <-
148
- either (const $ throwError BadSamlResponseFormFieldMissing ) pure $
149
- lookupInput " SAMLResponse" resp
148
+ either (const $ throwError BadSamlResponseFormFieldMissing ) pure
149
+ $ lookupInput " SAMLResponse" resp
150
150
parseAuthnResponseBody mbSPId base64
151
151
152
- issuerToCreds :: forall m err . SPStoreIdP (Error err ) m => Maybe Issuer -> Maybe (IdPConfigSPId m ) -> m (NonEmpty SignCreds )
152
+ issuerToCreds :: forall m err . ( SPStoreIdP (Error err ) m ) => Maybe Issuer -> Maybe (IdPConfigSPId m ) -> m (NonEmpty SignCreds )
153
153
issuerToCreds Nothing _ = throwError BadSamlResponseIssuerMissing
154
154
issuerToCreds (Just issuer) mbSPId = idpToCreds issuer =<< getIdPConfigByIssuerOptionalSPId issuer mbSPId
155
155
@@ -167,30 +167,28 @@ idpToCreds issuer idp = do
167
167
-- | Pull assertions sub-forest and pass unparsed xml input to 'verify' with a reference to
168
168
-- each assertion individually. The input must be a valid 'AuthnResponse'. All assertions
169
169
-- need to be signed by the issuer given in the arguments using the same key.
170
- simpleVerifyAuthnResponse :: forall m err . MonadError (Error err ) m => NonEmpty SignCreds -> LBS -> m ()
170
+ simpleVerifyAuthnResponse :: forall m err . ( MonadError (Error err ) m ) => NonEmpty SignCreds -> LBS -> m ()
171
171
simpleVerifyAuthnResponse creds raw = do
172
172
doc :: Cursor <- do
173
173
let err = throwError . BadSamlResponseSamlError . cs . show
174
174
either err (pure . fromDocument) (parseLBS def raw)
175
175
assertions :: [Element ] <- do
176
176
let elemOnly (NodeElement el) = Just el
177
177
elemOnly _ = Nothing
178
- case catMaybes $
179
- elemOnly . node
180
- <$> (doc $/ element " {urn:oasis:names:tc:SAML:2.0:assertion}Assertion" ) of
178
+ case mapMaybe (elemOnly . node) (doc $/ element " {urn:oasis:names:tc:SAML:2.0:assertion}Assertion" ) of
181
179
[] -> throwError BadSamlResponseNoAssertions
182
180
some@ (_ : _) -> pure some
183
181
nodeids :: [String ] <- do
184
182
let assertionID :: Element -> m String
185
183
assertionID (Element _ attrs _) =
186
- maybe (throwError BadSamlResponseAssertionWithoutID ) (pure . cs) $
187
- Map. lookup " ID" attrs
184
+ maybe (throwError BadSamlResponseAssertionWithoutID ) (pure . cs)
185
+ $ Map. lookup " ID" attrs
188
186
assertionID `mapM` assertions
189
187
allVerifies creds raw nodeids
190
188
191
189
-- | Call verify and, if that fails, any work-arounds we have. Discard all errors from
192
190
-- work-arounds, and throw the error from the regular verification.
193
- allVerifies :: forall m err . MonadError (Error err ) m => NonEmpty SignCreds -> LBS -> [String ] -> m ()
191
+ allVerifies :: forall m err . ( MonadError (Error err ) m ) => NonEmpty SignCreds -> LBS -> [String ] -> m ()
194
192
allVerifies creds raw nodeids = do
195
193
let workArounds :: [Either String () ]
196
194
workArounds =
@@ -206,7 +204,7 @@ allVerifies creds raw nodeids = do
206
204
-- | ADFS illegally breaks whitespace after signing documents; here we try to fix that.
207
205
-- https://github.com/wireapp/wire-server/issues/656
208
206
-- (This may also have been a copy&paste issue in customer support, but let's just leave it in just in case.)
209
- verifyADFS :: MonadError String m => NonEmpty SignCreds -> LBS -> [String ] -> m ()
207
+ verifyADFS :: ( MonadError String m ) => NonEmpty SignCreds -> LBS -> [String ] -> m ()
210
208
verifyADFS creds raw nodeids = verify creds raw' `mapM_` nodeids
211
209
where
212
210
raw' = go raw
@@ -224,13 +222,13 @@ verifyADFS creds raw nodeids = verify creds raw' `mapM_` nodeids
224
222
data FormRedirect xml = FormRedirect URI xml
225
223
deriving (Eq , Show , Generic )
226
224
227
- class HasXML xml => HasFormRedirect xml where
225
+ class ( HasXML xml ) => HasFormRedirect xml where
228
226
formRedirectFieldName :: xml -> ST
229
227
230
228
instance HasFormRedirect AuthnRequest where
231
229
formRedirectFieldName _ = " SAMLRequest"
232
230
233
- instance HasXMLRoot xml => MimeRender HTML (FormRedirect xml ) where
231
+ instance ( HasXMLRoot xml ) => MimeRender HTML (FormRedirect xml ) where
234
232
mimeRender
235
233
(Proxy :: Proxy HTML )
236
234
(FormRedirect (cs . serializeURIRef' -> uri) (cs . EL. encode . cs . encode -> value)) =
@@ -248,7 +246,7 @@ instance HasXMLRoot xml => MimeRender HTML (FormRedirect xml) where
248
246
<input type="submit" value="Continue">
249
247
|]
250
248
251
- instance HasXMLRoot xml => Servant. MimeUnrender HTML (FormRedirect xml ) where
249
+ instance ( HasXMLRoot xml ) => Servant. MimeUnrender HTML (FormRedirect xml ) where
252
250
mimeUnrender Proxy lbs = do
253
251
cursor <- fmapL show $ fromDocument <$> parseLBS def lbs
254
252
let formAction :: [ST ] = cursor $// element " {http://www.w3.org/1999/xhtml}form" >=> attribute " action"
@@ -392,7 +390,7 @@ simpleHandleVerdict onsuccess = \case
392
390
crash :: (SP m , MonadError (Error err ) m ) => String -> m a
393
391
crash msg = logger Fatal msg >> throwError UnknownError
394
392
395
- enterH :: SP m => String -> m ()
393
+ enterH :: ( SP m ) => String -> m ()
396
394
enterH msg =
397
395
logger Debug $ " entering handler: " <> msg
398
396
0 commit comments