Getting authentication data(JWT) data in XMPP/lua events module?

Hi guys,

I’m working on a little lua module in prosody to log presence events, where I’d like to figure out if a user is authenticated and get at some jwt data. I have a setup with Keycloak authentication to play with but the presence events I see coming in are no different from anonymous users. Is there a way to see the difference? Are there other events I should be looking for?

For clarity, I’m subscribed for presence events with module:hook(“presence/full”, on_event); This results in XML data for things like join/leave etc.

Thanks!

This Lua script gets the affiliation value from JWT

Cool, thanks emrah!

I’ve reworked that code so I’m now also listening to muc-occupant-joined and I see the event coming in. The event however does not seem to include any additional info - below’s a sample from a user that was authenticated by Keycloak. Is there a list of events that can be subscribed to? I looked but could not find it - could be oversight on my part.

muc.meet.jitsi:muc_eventlistener info Received a muc_occupant_join event! Look: <presence from='72807af7-4b73-4024-b5fb-08c0e9958260@meet.jitsi/jpqGhjAh' to='thickradiationswalkworst@muc.meet.jitsi/72807af7'><x xmlns='http://jabber.org/protocol/muc'/><stats-id>Kenyatta-bia</stats-id><c hash='sha-1' node='http://jitsi.org/jitsimeet' ver='ZYz/Bk0YZmQuoeSFs25VOxJYXf4=' xmlns='http://jabber.org/protocol/caps'/><features><feature var='https://jitsi.org/meet/e2ee'/></features><jitsi_participant_codecType>vp8</jitsi_participant_codecType><nick xmlns='http://jabber.org/protocol/nick'>Demo User</nick><jitsi_participant_e2ee.idKey>8Kgby90P1Ia9XvA4bQrVyJcfBfFWLCov16s8066Tiwc</jitsi_participant_e2ee.idKey><audiomuted>false</audiomuted><videomuted>false</videomuted></presence>

Thanks,
Florian

Eureka :wink:

For posterity: the JWT can be found in event.origin.auth_token. Now to find the proper tools to decode and process this in lua.

Regards,
Florian