Triggering authentication programmatically from a jax-rs call

30 views
Skip to first unread message

thew...@gmail.com

unread,
Aug 10, 2021, 9:23:33 AM8/10/21
to Pac4j users mailing list
I have a need to trigger authentication programmatically from a jax-rs call (under dropwizard, jersey). This needs to happen as a result of an exception being thrown from within certain jax-rs calls. How can I then make pac4j initiate an authentication when this event happens, so the client (here a curl script) would authenticate and then re-try the request?

-JM

Jérôme LELEU

unread,
Aug 27, 2021, 4:26:52 AM8/27/21
to thew...@gmail.com, Pac4j users mailing list
Hi,

Generally, you target a protected URL to trigger an authentication process.

This URL is protected with a @Pacj4Security annotation and the SecurityFilter behind.

So if you want to do things manually, you need to reproduce the behavior from this component which is globally: call the SecurityLogic with the right parameters. Take a look at the source code.

Thanks.
Best regards,
Jérôme


Le mar. 10 août 2021 à 15:23, thew...@gmail.com <thew...@gmail.com> a écrit :
I have a need to trigger authentication programmatically from a jax-rs call (under dropwizard, jersey). This needs to happen as a result of an exception being thrown from within certain jax-rs calls. How can I then make pac4j initiate an authentication when this event happens, so the client (here a curl script) would authenticate and then re-try the request?

-JM

--
You received this message because you are subscribed to the Google Groups "Pac4j users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pac4j-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pac4j-users/f2a35318-3a5f-4be5-bb56-9e91388d40fan%40googlegroups.com.

thew...@gmail.com

unread,
Aug 27, 2021, 4:38:27 AM8/27/21
to Pac4j users mailing list
Thanks. Yes, I went the route of adding a protected URL, since I had to find a solution here. Also, that seems like the cleanest and easiest way.

-JM

Reply all
Reply to author
Forward
0 new messages