p2phttp: Allow unauthenticated users to lock content by default
* p2phttp: Allow unauthenticated users to lock content by default. * p2phttp: Added --unauth-nolocking option to prevent unauthenticated users from locking content. The rationalle for this is that locking is not really a write operation, so makes sense to allow in a repository that only allows read-only access. Not supporting locking in that situation will prevent the user from dropping content from a special remote they control in cases where the other copy of the content is on the p2phttp server. Also, when p2phttp is configured to also allow authenticated access, lockcontent was resulting in a password prompt for users who had no way to authenticate. And there is no good way to distinguish between the two types of users client side. --unauth-nolocking anticipates that this might be abused, and seems better than disabling unauthenticated access entirely if a server is being attacked. It may be that rate limiting locking by IP address or similar would be an effective measure in such a situation. Or just limiting the number of locks by anonymous users that can be live at any one time. Since the impact of such an DOS attempt is limited to preventing dropping content from the server, it seems not a very appealing target anyway.
This commit is contained in:
parent
87c88025d1
commit
de138c642b
7 changed files with 60 additions and 10 deletions
|
@ -57,6 +57,7 @@ type GetServerMode = IsSecure -> Maybe Auth -> ServerMode
|
|||
data ServerMode
|
||||
= ServerMode
|
||||
{ serverMode :: P2P.ServerMode
|
||||
, unauthenticatedLockingAllowed :: Bool
|
||||
, authenticationAllowed :: Bool
|
||||
}
|
||||
| CannotServeRequests
|
||||
|
@ -68,7 +69,7 @@ mkP2PHttpServerState acquireconn annexworkerpool getservermode = P2PHttpServerSt
|
|||
<*> pure getservermode
|
||||
<*> newTMVarIO mempty
|
||||
|
||||
data ActionClass = ReadAction | WriteAction | RemoveAction
|
||||
data ActionClass = ReadAction | WriteAction | RemoveAction | LockAction
|
||||
deriving (Eq)
|
||||
|
||||
withP2PConnection
|
||||
|
@ -152,6 +153,8 @@ checkAuthActionClass st sec auth actionclass go =
|
|||
case (sm, actionclass) of
|
||||
(ServerMode { serverMode = P2P.ServeReadWrite }, _) ->
|
||||
go P2P.ServeReadWrite
|
||||
(ServerMode { unauthenticatedLockingAllowed = True }, LockAction) ->
|
||||
go P2P.ServeReadOnly
|
||||
(ServerMode { serverMode = P2P.ServeAppendOnly }, RemoveAction) ->
|
||||
throwError $ forbiddenWithoutAuth sm
|
||||
(ServerMode { serverMode = P2P.ServeAppendOnly }, _) ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue