Skip to main content

User Management with Auth0

Tonight I wanted to write about my current journey with moving our user identity management provider (which shall rename nameless), over to Auth0.  I would like to talk about the pitfalls and triumphs as we go.  It's mostly all good - a shame we hadn't done so sooner!

Now one of the most attractive attributes is the different methods/connectors that are provided in order to easily integrate your existing system, and I mean they cover just about everything, but this is also a segway to my first - very little - bit of criticism.  From what I see there are two main channels to provide some type of form to present to your user to input their credentials.  By the way, I'm still learning so please feel free to say I'm wrong at any stage.
  1. Lock / Universal Login 
  2. Hosted Pages
There is a mention of a "custom" way to work with Lock, but the customization looks little to be desired.  As to the hosted pages, well, again - correct me if I'm wrong - but it looks like the form being hosted has to contain the whole DOM, and if I'm going to make changes to my site's general template, I don't want to have to come back in here and do separate alterations.

I should also give a quick callout for the plugin they have developed for WordPress: Login by Auth0.  I've done some intial testing, and it works very well, and with all the functionality WordPress gives you, I understand you would just need to use its existing methods to login and create forms around.  Maybe it's just a bad name, but this got me to thinking how I would effectively create users as well using it.

But I digress, for me, I just want to tap in to the API's directly and build the form myself in our own environment - so for our migration, I am using the JS SDK (v9).  I've overcome a few hurdles, one of the most confusing aspects is the cross terminology from one type of API call to another.

For instance, take this example from this documentation, covering the use of the userinfo API. After the user has signed in, and they are given an access code, this is the same code you would use in place of the header: Authorization: Bearer {ACCESS_TOKEN}.

However, don't let this confuse you with that if you wanted to do something like a "user search", or "link accounts" etc.  This is done with the Auth0 Mangement API.  You'll also notice that unlike API's such as userinfo, where the URL is structured like: https://YOUR_DOMAIN/userinfo, the management API uses the format of https://YOUR_DOMAIN/api/v2/....

This management API uses a separate retrieval of an access token, which you can follow this guide on how to retrieve it.

Hopefully this has given some extra food for thought, and I'm sure this won't be the last I write on this subject. Nitty-picking at things aside, I'm very excited our team has collectively decided to use this platform.  It's tailored directly for devs!

Comments

Popular posts from this blog

Running NodeJS Serverless Locally

 So it's been a long time, but I thought this was a neat little trick so I thought I'd share it with the world - as little followers as I have.  In my spare time I've been writing up a new hobby project in Serverless , and while I do maintain a staging and production environment in AWS, it means I need to do a deployment every time I want to test all of the API's I've drafted for it. Not wanting to disturb the yaml configuration for running it locally, I've come up with a simple outline of a server which continues to use the same configuration.  Take the express driven server I first define here: And then put a index.js  in your routes folder to contain this code: Voila! This will take the request from your localhost and interpret the path against your serverless.yml and run the configured function.  Hope this helps someone!

question2answer Wordpress Integration

 Today I want to journal my implementation of a WordPress site with the package of "question2answer".  It comes as self-promoted as being able to integrate with WordPress "out of the box".  I'm going to vent a small amount of frustration here, because the only integration going on is the simplicity of configuration with using the same database, along with the user authentication of WordPress.  Otherwise they run as two separate sites/themes. This will not do. So let's get to some context.  I have a new hobby project in mind which requires a open source stack-overflow clone.  Enter question2answer .  Now I don't want to come across as completely ungrateful, this package - while old, ticks all the boxes and looks like it was well maintained, but I need every  page to look the same to have a seamless integration.  So, let's go through this step by step. Forum Index Update This step probably  doesn't need to be done, but I just wanted to mak...

Getting all deltas from Auth0

Before I get in to the solution of this article, let me tell you how it started and fill you in on the problem that arose.  I wrote a procedure to get daily deltas of users - those of which who had created/updated their account on the given day (and including the day before for good measure on the GMT timestamp).  The simple search criteria was just the following: updated_at:[yyyy-mm-dd TO yyyy-mm-dd] Simple, right?  the []'s being the dates are inclusive, while using {} would mean exclusively.  Auth0 lets you mix these on either side depending on your use.  While this is all well and good, Auth0 will limit the number of results (even with paging) to 1000 only. So, your first option is that you could have your procedure create a user export job, and then parsing through the results and eliminating those which do not meet your updated_at search criteria.  I can tell you first hand that eventually the amount of users will just get to be too much and cumb...