Jump to content

tibs
 Share

Recommended Posts

I don't always want to bother registering users, I just want them to be able to log in. I'm not alone because there are a number of other threads about OAuth, none of which mentions Opauth.

Opauth is a lean, non-opinionated, modular PHP thingy. It has 18 providers listed on their page, some of which are built-in, some are 3rd-party. Their website itself is an example, and it's on github as well.

It's lean: it doesn't need the provider SDKs, it implements only what it needs in the auth modules.

It's non-opinionated: you give your user a link to /auth/facebook, and then you are waiting for the results on /auth/callback; what you do with the returned array is your choice (the urls are of course customizable).

I could put together Twitter / Google / Facebook auth for a (non-processwire) site really quick. I stored the API auth params for the modules in a table as json-encoded hashes (just 2 keys and  2 values, but the keys vary by API, so that was the easiest), and I did the same with the returned credentials. Besides provider, uid, and credentials (what we really need), Opauth also returns a somewhat variable set of details about the profiles in the info key, stuff like name, gender, urls, and the like; the Processwire module could opt to mine and store in fields whatever it deems useful, then store the rest as json, or just throw it away. An example for what you get in your callback:

Array
(
    [auth] => Array
        (
            [provider] => Facebook
            [uid] => 1480000000008166
            [info] => Array
                (
                    [name] => Tibs
                    [image] => https://graph.facebook.com/1480000000008166/picture?type=square
                    [first_name] => Tibs
                    [urls] => Array
                        (
                            [facebook] => https://www.facebook.com/app_scoped_user_id/1480000000008166/
                        )

                )

            [credentials] => Array
                (
                    [token] => CAAEajKBojCkBAHj6cy0mM4EZBPvs082t5Vkm3PGa44jsfrfzCS1SwV09qOaZBQYnfxLnCacb7Wkr536wDzusIh4mkMmvwoC5VdZBKFRAGyLpqcVJYdWCIFv0iwfkjpiLpDsGVBChj1ac1Lq6ZBFjuCdrtfpcQtgWbonDVCzwGwZB0A37vLaQbCuh8OnbdRY1U1dPE2ZBU2PmgNGNP1ghzNo
                    [expires] => 2016-01-06T10:29:53+00:00
                )

            [raw] => Array
                (
                    [id] => 1480000000008166
                    [first_name] => Tibs
                    [gender] => male
                    [link] => https://www.facebook.com/app_scoped_user_id/148000000000166/
                    [locale] => en_US
                    [name] => Tibs
                    [timezone] => 1
                    [updated_time] => 2015-01-25T19:54:12+0000
                    [verified] => 1
                )

        )

    [timestamp] => 2015-11-07T11:20:56+00:00
    [signature] => hmcuwumqat4w84g1gkw0cgokloogg4w
)

To be honest, I'm not even working on anything in Processwire at the moment, but I wanted to post about Opauth since I discovered it. If someone decides to implement OAuth before I get around it myself, Opauth is the perfect candidate to do the heavy lifting :)

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...