[6.x] [REST Protocol] [Request a Service Ticket] HTTP 200 - empty body

206 views
Skip to first unread message

Michele Melluso

unread,
Jan 28, 2019, 8:50:51 AM1/28/19
to CAS Community
Hi all,

we're trying to integrate Rest Protocol as described here:


in 5.3.6 everything works just fine, we obtain TGTs and STs also in Jwt format.

in all 6.x versions we manage to get a TGT (also in JWT format) but when we try to get an ST we receive a 200 response with empty body.
Our java version is java-11-openjdk-11.0.1.13-10.fc29.x86_64

the Api is called exactly as in 5.3.6 version:

curl -X POST \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'cache-control: no-cache' \
  -d 'service=https%3A%2F%2Flocalhost......&ticket=true'

the result is:
HTTP/1.1 200 
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=15768000 ; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Content-Type: application/vnd.cas.services+yaml;charset=UTF-8
Content-Length: 0
Date: Mon, 28 Jan 2019 13:48:52 GMT
Server: Apereo CAS




Cas log says that the ticket is created:
=============================================================
WHO: {myuser}
WHAT: [status=200-OK,body=ST-1-GiBOLycp8wL.........]
ACTION: REST_API_SERVICE_TICKET_CREATED
APPLICATION: CAS
WHEN: Mon Jan 28 14:34:39 CET 2019
CLIENT IP ADDRESS: 127.0.0.1
SERVER IP ADDRESS: 127.0.0.1
=============================================================


Debugging the following class i can see a nicely populated ResponseEntity :

Screenshot from 2019-01-28 14-41-40.png



org.apereo.cas.support.rest.resources.ServiceTicketResource.createServiceTicket

return this.serviceTicketResourceEntityResponseFactory.build(tgtId, service, authenticationResult);

but no body is returned.


any help is welcome
thanks in advance
Michele

Dmitriy Kopylenko

unread,
Jan 29, 2019, 9:08:14 AM1/29/19
to cas-...@apereo.org
Hi,

there was one custom HttpMessageConverter added in 6.0 which messes up with the body of a response on the way back during content negotiation (if by default Accept header value is set to */*): https://github.com/apereo/cas/blob/master/core/cas-server-core-services-api/src/main/java/org/apereo/cas/services/util/RegisteredServiceYamlHttpMessageConverter.java

Set the Accept header value to text/plain and you should be good to go.

I don’t know yet if it’s a “bug” or “feature”.

Cheers,
D.
--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/2e774cc6-7cab-454a-9f13-850654bed7d7%40apereo.org.
35d649e8-7362-47d0-bd91-c8582f03f8b6.png

Michele Melluso

unread,
Jan 29, 2019, 9:31:25 AM1/29/19
to CAS Community, dkopy...@unicon.net
Hi,

i confirm that adding the header 'Accept: text/plain'

works perfectly :)

Thank you
Michele

Raheem Shaik

unread,
Jan 27, 2020, 2:11:41 PM1/27/20
to CAS Community, dkopy...@unicon.net
Hi Michele,

I am also facing the same issue on cas 6.0.x , can you please let me know where i have to add the header 'Accept: text/plain'

Regards,
Raheem

Raheem Shaik

unread,
Jan 31, 2020, 1:14:36 AM1/31/20
to CAS Community, dkopy...@unicon.net
Michele/Dmitriy,

I have found  how to pass to my header 'Accept: text/plain' while using POST method but after getting the jwt token not able to retrieve Payload data due to that our authentication is failing  

Did you faced this issue?, if not can you please let me know what should be added to my end to get it work properly 
Reply all
Reply to author
Forward
0 new messages