10

I am trying to set up WordPress as an OAuth2 client. All of our users are stored in our proprietary CMS which is an OAuth provider. We have very little (to no) users in our WordPress database, primarily just administrators. Ideally, I do not want to store user data in the WordPress database because I would need to somehow maintain state across X number of WordPress sites, whereas I have one source of truth within our proprietary CMS.

My initial design of this so far was to create a plugin that overrides the existing WordPress user functionality and stores an OAuth access token and user uuid within a cookie or session. But, I need this user to be accessible in other plugins, so ideally overriding the default WordPress user methods.

Is this an acceptable approach? Or, am I trying to work with WordPress in a way that it wasn't meant to be worked?

I can find tons of plugins for setting WordPress up as an OAuth2 provider, but very few as a client. That being said, I have found some that do set up WordPress as a client, but a lot of them are specific to Google Apps, Facebook, Twitter, etc. Moreover, these apps rely on storing user data locally within the WordPress user table. I would prefer not to do so.

Thanks for any help!

  • Hi Nick, Welcome to WPSE. Unfortunately I can't help you with the actual issue at hand - but could you please remove the intro (not really relevant for the issue) and maybe add what you've already tried maybe even adding some code. This makes it easier for everyone to help. Thanks! – kraftner Dec 16 '14 at 16:31
  • Thanks @kraftner for the hasty response. I haven't written much code because I'm trying to do some design/research first and I guess I was looking for affirmation with my idea. However, it seems like I should get a proof of concept up and running. Sorry if I took the wrong approach here. I'll try to do some work and post with smaller issues and some work examples. – Nick Dec 16 '14 at 16:36
  • Didn't want to upset you, I really just thought that as you are new I'd tell you that you'll get more and better responses if you're question is short and focused instead of telling a story with irrelevant information. – kraftner Dec 16 '14 at 16:48
  • @kraftner not upset at all sir! – Nick Dec 16 '14 at 16:55
  • 1
    Have you seen this answer? – kaiser Jan 14 '15 at 6:00
1

If you can stick to overriding just functions that are located in wp-includes/pluggable.php then you should be able to avoid any kind of plugin conflicts ... unless you are using plugins that are overriding the same pluggable functions.

Just make sure that your functions are declared before pluggables is loaded. Plugins are loaded before the pluggables file ... so if you define your function overrides in a plugin then you can be certain they are loaded. Otherwise just make sure to use an earlier action to do so.

There are quite a few authentication, cookie, and user related functions in there for use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.