mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-10-30 10:05:58 +01:00
return 401 on scm http request if anonymous access is enabled but does not have the required permissions
This commit is contained in:
@@ -13,6 +13,8 @@ import sonia.scm.repository.NamespaceAndName;
|
||||
import sonia.scm.repository.api.RepositoryService;
|
||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
import sonia.scm.repository.spi.HttpScmProtocol;
|
||||
import sonia.scm.security.Authentications;
|
||||
import sonia.scm.util.HttpUtil;
|
||||
import sonia.scm.web.UserAgent;
|
||||
import sonia.scm.web.UserAgentParser;
|
||||
|
||||
@@ -73,7 +75,11 @@ public class HttpProtocolServlet extends HttpServlet {
|
||||
resp.setStatus(HttpStatus.SC_NOT_FOUND);
|
||||
} catch (AuthorizationException e) {
|
||||
log.debug(e.getMessage());
|
||||
resp.setStatus(HttpStatus.SC_FORBIDDEN);
|
||||
if (Authentications.isAuthenticatedSubjectAnonymous()) {
|
||||
HttpUtil.sendUnauthorized(resp);
|
||||
} else {
|
||||
resp.setStatus(HttpStatus.SC_FORBIDDEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user