Hi ,
You can use "user.contactid" in the fetch xml something like this-
------------------------------------------
{% fetchxml entitltment_query %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" aggregate="true">
<entity name="entitlement">
<attribute name='remainingterms' alias='remainingterms_sum' aggregate='sum' />
<filter type="and">
<condition attribute="contactid" operator="eq" value="{{ user.contactid }}" />
<condition attribute="statecode" operator="eq" value="1" />
</filter>
</entity>
</fetch>
{% endfetchxml %}
------------------------------------------
You could also achieve this by creating a contact lookup field on case entity say "Customer's Primary Contact" and auto populate it with customer's primary contact and then creating entity permission to get all cases this lookup relationship. This way you don't need to write/ customize the page with fetch xml. I tried this and it worked fine-