make serveKeepLocked check auth just to be safe
This commit is contained in:
parent
63e42aa1bc
commit
e979e85bff
5 changed files with 34 additions and 17 deletions
|
@ -104,13 +104,7 @@ getP2PConnection
|
|||
-> (ConnectionParams -> ConnectionParams)
|
||||
-> Handler P2PConnectionPair
|
||||
getP2PConnection apiver st cu su bypass sec auth actionclass fconnparams =
|
||||
case (getServerMode st sec auth, actionclass) of
|
||||
(Just P2P.ServeReadWrite, _) -> go P2P.ServeReadWrite
|
||||
(Just P2P.ServeAppendOnly, RemoveAction) -> throwError err403
|
||||
(Just P2P.ServeAppendOnly, _) -> go P2P.ServeAppendOnly
|
||||
(Just P2P.ServeReadOnly, ReadAction) -> go P2P.ServeReadOnly
|
||||
(Just P2P.ServeReadOnly, _) -> throwError err403
|
||||
(Nothing, _) -> throwError basicAuthRequired
|
||||
checkAuthActionClass st sec auth actionclass go
|
||||
where
|
||||
go servermode = liftIO (acquireP2PConnection st cp) >>= \case
|
||||
Left (ConnectionFailed err) ->
|
||||
|
@ -128,6 +122,22 @@ getP2PConnection apiver st cu su bypass sec auth actionclass fconnparams =
|
|||
, connectionWaitVar = True
|
||||
}
|
||||
|
||||
checkAuthActionClass
|
||||
:: P2PHttpServerState
|
||||
-> IsSecure
|
||||
-> Maybe Auth
|
||||
-> ActionClass
|
||||
-> (P2P.ServerMode -> Handler a)
|
||||
-> Handler a
|
||||
checkAuthActionClass st sec auth actionclass go =
|
||||
case (getServerMode st sec auth, actionclass) of
|
||||
(Just P2P.ServeReadWrite, _) -> go P2P.ServeReadWrite
|
||||
(Just P2P.ServeAppendOnly, RemoveAction) -> throwError err403
|
||||
(Just P2P.ServeAppendOnly, _) -> go P2P.ServeAppendOnly
|
||||
(Just P2P.ServeReadOnly, ReadAction) -> go P2P.ServeReadOnly
|
||||
(Just P2P.ServeReadOnly, _) -> throwError err403
|
||||
(Nothing, _) -> throwError basicAuthRequired
|
||||
|
||||
basicAuthRequired :: ServerError
|
||||
basicAuthRequired = err401 { errHeaders = [(h, v)] }
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue