XF 2.2 Access OAuth config from within Provider Service

Jarvis

Member
Hi there everyone, I'm working on a generic implementation of a keycloak OAuth provider that we need for our own forum, but that I will also be providing for free for anyone else.

I've got a working repo here, however I'm having issues within the service impl, as well as the data provider impl. I need to get access to the OAuth config, but internally the OAuth subcontainer is acquiring it via calling the provider impl - something I don't know if I can easily do from within the service or data provider.

Specifically, I need the config block from the connected accounts panel. So that I can then set the correct authentication and base endpoints.

Nh4vUmq.png


Any ideas on how I can gain access? I had a look in
Code:
\XF:app()->container()
as well as
Code:
\XF:app()->oauth()
, but don't see a viable way of gaining the config that way. Should I just be doing a DB call instead?

Cheers.
 
Last edited:
In case you want to save yourself some work, our Connected Account Providers add-on has a Keycloak adapter integrated, albeit not listed at the moment. It might satisfy your use case.
Hey! I did actually come across this addon when looking around for pre-existing resources to learn from.

I don't see any reference to keycloak there though. Where should I be looking?
 
Anyone else got any ideas? :) I'm still tracking this, and want to put it out afterwards. I've yet to see a connected account provider for a self hosted keycloak instance
 
I'm pretty sure you should have all this data within your XF connected account provider instance (the class that extends XF\ConnectedAccount\Provider\AbstractProvider). Specifically, it's passed into getOAuth and getProviderData, which instantiate your provider service and data objects respectively. You should be able to override/extend those methods to pass any additional details into the created objects (to set different endpoints, etc).
 
Back
Top Bottom