Introducing SCAuth

We just deployed a new version of Mockingbird that is officially running SCAuth for all of its authentication needs.

Which leads to the obvious question - what exactly is SCAuth and why would you care about it?  

If, like me, you have an application running on Cappuccino that requires users to login, you probably have a bunch of code that deals with keeping track of the users' session data, keeping it in sync with the backend, and showing users a login dialog at the right times.  There are a couple of not-so-well-known classes/hooks in Cappuccino that make this easier for you (I'm looking at you, CPUserSessionManager and setClassDelegate on CPURLConnection), but it wasn't quite enough for me, so I made SCAuth on top of it to do a bit more. SCAuth comes with SCUserSessionManager which subclasses CPUserSessionManager to make the class a bit more robust (letting you do things like logout and sync your session data).  Eventually, I'd like to make SCAuth handle all kinds of session data depending on what login provider is being used (for example, if your app uses Facebook Connect to login, there are probably facebook connect-y things you want to access about the user from your Cappuccino application).  This should be pretty easily possible by just switching out the login provider that SCAuth uses.

SCAuth also uses setClassDelegate on CPURLConnection to deal with making your users login whenever they do something that requires them to log in.  It uses the login provider that is set on the SCUserSessionManager to deal with logging the user in.  By default, this login provider is a login dialog that comes with SCAuth, but it's pretty easy to make this login provider whatever you want.  

After refactoring Mockingbird to abstract out all this authentication nonsense, I cut down quite a few lines of code, so hopefully someone else will also find this useful (or, if not, make suggestions for how it can be more useful).  You can read the README at the github page for more details.  Oh, and there is an example.

Posted
Views