Issue
- In our server logs we see a lot of warnings with stack traces like these:
2021-03-05 07:10:40.666 WARN [http-nio-127.0.0.1-8080-exec-276][PortalImpl:6843] java.lang.SecurityException: Access denied to com.liferay.document.library.kernel.service.DLAppService#ge
tFileEntryByUuidAndGroupId
java.lang.SecurityException: Access denied to com.liferay.document.library.kernel.service.DLAppService#getFileEntryByUuidAndGroupId
at com.liferay.portal.security.service.access.policy.internal.SAPAccessControlPolicy.checkAccess(SAPAccessControlPolicy.java:113)
at com.liferay.portal.security.service.access.policy.internal.SAPAccessControlPolicy.onServiceRemoteAccess(SAPAccessControlPolicy.java:81)
at com.liferay.portal.security.access.control.AccessControlAdvisorImpl.accept(AccessControlAdvisorImpl.java:49)
at com.liferay.portal.security.access.control.AccessControlAdvice.before(AccessControlAdvice.java:54)
at com.liferay.portal.kernel.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:53)
at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
at com.sun.proxy.$Proxy200.getFileEntryByUuidAndGroupId(Unknown Source)
at com.liferay.document.library.kernel.service.DLAppServiceUtil.getFileEntryByUuidAndGroupId(DLAppServiceUtil.java:899)
at com.liferay.portal.webserver.WebServerServlet.getFileEntry(WebServerServlet.java:456)
at com.liferay.portal.webserver.WebServerServlet._checkResourcePermission(WebServerServlet.java:1488)
at com.liferay.portal.webserver.WebServerServlet.service(WebServerServlet.java:278)
2021-03-01 05:03:41.557 WARN [http-nio-127.0.0.1-8080-exec-302][PortalImpl:6843] java.lang.SecurityException: Access denied to com.liferay.document.library.kernel.service.DLAppService#getFileEntry
java.lang.SecurityException: Access denied to com.liferay.document.library.kernel.service.DLAppService#getFileEntry
at com.liferay.portal.security.service.access.policy.internal.SAPAccessControlPolicy.checkAccess(SAPAccessControlPolicy.java:113)
at com.liferay.portal.security.service.access.policy.internal.SAPAccessControlPolicy.onServiceRemoteAccess(SAPAccessControlPolicy.java:81)
at com.liferay.portal.security.access.control.AccessControlAdvisorImpl.accept(AccessControlAdvisorImpl.java:49)
at com.liferay.portal.security.access.control.AccessControlAdvice.before(AccessControlAdvice.java:54)
at com.liferay.portal.kernel.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:53)
at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
at com.sun.proxy.$Proxy194.getFileEntry(Unknown Source)
at com.liferay.document.library.kernel.service.DLAppServiceUtil.getFileEntry(DLAppServiceUtil.java:884)
at com.liferay.portal.webserver.WebServerServlet.getFileEntry(WebServerServlet.java:449)
at com.liferay.portal.webserver.WebServerServlet._checkResourcePermission(WebServerServlet.java:1488)
at com.liferay.portal.webserver.WebServerServlet.service(WebServerServlet.java:278)
Environment
- DXP 7.2, starting from Fix Pack 1
Resolution
- these warnings are logged now due to an intended change made in 7.2 dxp-1 (https://issues.liferay.com/browse/LPS-95290)
- they can be logged for example when guest users try to access Liferay documents from third party programs (like opening a PDF file in MS Word) through the remote API
-
go to Control Panel/Configuration/Service Access Policy and look for the line for
OAUTH2_everything.read.documents.download
and make sure that Enabled is set to Yes, and Default is set to Yes (this will allow also guest access - if Default is turned on, the service access policies are applied to both authenticated and unauthenticated requests, so to all incoming requests. Making unauthenticated Requests documentation gives a much better explanation on what it is doing: it opens up the API for Guest access. So making a SAP Default means there is no Guest access restriction at SAP level (but of course the permission checks at service level remain active)
- Another possible solution would be to create new Service Access Policy for these service endpoints. Your current service access policies can be found in the UI under Control Panel > Configurations > Service Access Policies. (for more info please see access policy framework).