Issue
- If there's a web server in front of Liferay, when clicking on the Authorize button to authorize OAuth2 applications HTTP is used instead of HTTPS and the following WARNs are displayed in the log.
2019-11-08 09:37:05.000 WARN [http-nio-8080-exec-63][AbstractOAuthService:88] Unsecure HTTP, Transport Layer Security is recommended
2019-11-08 09:37:05.001 WARN [http-nio-8080-exec-63][WebApplicationExceptionMapper:88] javax.ws.rs.BadRequestException: HTTP 400 Bad Request_
at org.apache.cxf.jaxrs.utils.SpecExceptions.toBadRequestException(SpecExceptions.java:84)_
at org.apache.cxf.jaxrs.utils.ExceptionUtils.toBadRequestException(ExceptionUtils.java:119)_
at org.apache.cxf.rs.security.oauth2.services.RedirectionBasedGrantService.completeAuthorization(RedirectionBasedGrantService.java:356)_
at org.apache.cxf.rs.security.oauth2.services.RedirectionBasedGrantService.authorizeDecisionForm(RedirectionBasedGrantService.java:117)_
Environment
- Liferay DXP 7.1
Resolution
- Set the web.server.forwarded.protocol.enabled property to true in your portal-ext.properties file.
Additional Information
Please see the descriptions of the web.server.forwarded.protocol.enabled and web.server.forwarded.protocol.header properties.
## Set this to true to use the property "web.server.forward.protocol.header"# to get the protocol. The property "web.server.protocol" must not have been# overriden.## Env: LIFERAY_WEB_PERIOD_SERVER_PERIOD_FORWARDED_PERIOD_PROTOCOL_PERIOD_ENABLED#web.server.forwarded.protocol.enabled=false## Set the HTTP header to use to get the protocol. The property# "web.server.forwarded.protocol.enabled" must be set to true.## Env: LIFERAY_WEB_PERIOD_SERVER_PERIOD_FORWARDED_PERIOD_PROTOCOL_PERIOD_HEADER#web.server.forwarded.protocol.header=X-Forwarded-Proto