Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Doubt with AuthTokenUtil methods on Liferay 7
Hi all,
I have a doubt about a method of AuthTokenUtil. I am upgrading a Liferay 6 to Liferay 7 and I am not sure what to do with one method.
In Liferay 6 I have this piece of code :
However, the method "check" is no longer available.
Does anyone know how is the right way to do it now? I was looking at the "checkCSRFToken" but I'm not sure that this method will be the same than the old one.
Any help would be very appreciated.
Kind regards.
I have a doubt about a method of AuthTokenUtil. I am upgrading a Liferay 6 to Liferay 7 and I am not sure what to do with one method.
In Liferay 6 I have this piece of code :
[table]
[tr]
[td]try {[/td]
[/tr]
[tr]
[td][/td]
[td] HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(PortalUtil.getHttpServletRequest(resourceRequest)){[/td]
[/tr]
[tr]
[td][/td]
[td] @Override[/td]
[/tr]
[tr]
[td][/td]
[td] public String getParameter(String name) {[/td]
[/tr]
[tr]
[td][/td]
[td] if (name.equals("p_auth")) {[/td]
[/tr]
[tr]
[td][/td]
[td] return PortalUtil.getOriginalServletRequest((HttpServletRequest) super.getRequest()).getParameter(name);[/td]
[/tr]
[tr]
[td][/td]
[td] }[/td]
[/tr]
[tr]
[td][/td]
[td]
[/td]
[/tr]
[tr]
[td][/td]
[td] return super.getParameter(name);[/td]
[/tr]
[tr]
[td][/td]
[td] }[/td]
[/tr]
[tr]
[td][/td]
[td] };[/td]
[/tr]
[tr]
[td][/td]
[td] AuthTokenUtil.check(wrapper);[/td]
[/tr]
[tr]
[td][/td]
[td]} catch (Exception e) {[/td]
[/tr]
[tr]
[td][/td]
[td] throw new PortletException("Invalid CSRF token!", e);[/td]
[/tr]
[tr]
[td][/td]
[td]}
However, the method "check" is no longer available.
Does anyone know how is the right way to do it now? I was looking at the "checkCSRFToken" but I'm not sure that this method will be the same than the old one.
Any help would be very appreciated.
Kind regards.
Hi ,You can use AuthTokenUtil.checkCSRFToken(request, origin); may be you can refer below how it is used
https://github.com/liferay/liferay-portal/blob/7.2.x/portal-impl/src/com/liferay/portal/action/UpdateEmailAddressAction.java#L88
https://github.com/liferay/liferay-portal/blob/7.2.x/portal-impl/src/com/liferay/portal/action/UpdateEmailAddressAction.java#L88
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™