Is it bug on cas-server-support-jpa-ticket-registry?

51 views
Skip to first unread message

Elena

unread,
Feb 19, 2018, 8:37:03 PM2/19/18
to CAS Community
Hello, I use cas's module oauth-webflow and jpa-ticket-registry.

when I do logout, it makes error like it.
It caoused tgtkey is used by oauth_tokens table's foreign key.
please check it. thanks.
------------------------------------
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "ticketgrantingticket" violates foreign key constraint "fkq0iyiw6b2rufxe2ocmpsqdo50" on table "oauth_tokens"
10:29:30.298 [QUIET] [system.out] Detail: Key (id)=(TGT-1-YeyYjtQc855ls4Xy2aBFVzV8qFAVSxgQjPGFE7hchWvwS0ajp_zZjNUqdMw35SpY1wI-security-dev-02) is still referenced from table "oauth_tokens".

Elena

unread,
Feb 19, 2018, 8:43:47 PM2/19/18
to CAS Community
+) i use cas 5.2.2

NGUYEN-VIET Quang

unread,
Dec 6, 2018, 6:21:22 PM12/6/18
to cas-...@apereo.org
Hello
It's a bit dated issue, however we have the same issue on v 5.2.5.

Anyway, I think the issue is still present on master actually.

The error’s message is clear:  it’s caused of a database’s constraint between two table OAUTH_TOKENS and TICKETGRANTINGTICKET on the field TICKETGRANTINGTICKET_ID of OAUTH_TOKENS.

Digging on the code, on the class JpaTicketRegistry, the function deleteTicketGrantingTickets()

https://github.com/apereo/cas/blob/ab784b404df8a12eaae58b66fae78d8199277663/support/cas-server-support-jpa-ticket-registry/src/main/java/org/apereo/cas/ticket/registry/JpaTicketRegistry.java#L184

Inside this function, only the ServiceTicket, TicketGrantingTicket and linked TicketGrantingTicket are suppressed.

Obviously, all the other oauth2’s tickets : meaning  OAuthCode, AccessToken, RefreshToken are forgotten or are not implemented yet …

So, we can patch the code with something similar

        // patch
        final TicketDefinition at = this.ticketCatalog.find(AccessToken.PREFIX);
        String sqlText = "delete from " + getTicketEntityName(at) + " s where s.ticketGrantingTicket.id = :id";
        LOGGER.debug("AT " + sqlText);
        query = entityManager.createQuery(sqlText);
        query.setParameter("id", ticketId);
        totalCount += query.executeUpdate();
 
And this code is needed to repeat also for RefreshToken.PREFIX and OAuthCode.PREFIX

 @leleuj and  @mmoayyed, do you think that’s is a right place to do the patch ?

Thanks
Quang.









Le mar. 20 févr. 2018 à 02:43, Elena <ahee...@gmail.com> a écrit :
+) i use cas 5.2.2

--
- 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/899d39bd-f96c-404d-a5b2-73a704e0aaa2%40apereo.org.
Reply all
Reply to author
Forward
0 new messages