Auth in FOAM part 8
Auth in FOAM
FOAM has several pluggable components for handling auth. See the auth guide for full details.
Authentication vs. Authorization
Before we get hands-on, let’s draw a careful distinction:
- Authentication is verifying who the user claims to be.
- Authorization is determining what that user is allowed to see and update.
FOAM has components to help with both parts, as we’ll see.
TODO
That’s as far as the tutorial goes for now - sorry!
Here’s the short version of using Google auth with FOAM:
- Create a new app on the Developer Console
- Add new OAuth web credentials for it, with the origin
localhost:8000
. - Grab the key.
- Add a property
owner
tocom.todo.model.Todo
, tagged ashidden: true
. - Create a property called
googleClientId
onTodoApp
that has itsdefaultValue
set to that key. - Export
googleClientId
:exports: ['googleClientId']
. - Add the
googleAuth: true
setting to the client’sEasyClientDAO
. - On the server, require the following:
foam.dao.GoogleAuthDAO
foam.dao.AuthorizedDAO
foam.dao.PrivateOwnerAuthorizer
- Make the server’s DAO into the following onion-like layering:
That should do it. This will be expanded into a proper tutorial later, probably once FOAM has username/password auth instead. Juggling the Google keys is easy enough if you want Google auth, but it’s a pain if you don’t.