 
     settings = database.key_value_store(name:'passport_settings')
     get_conf = (strategy, cb) ->
-        database.select_one
+        database.select
             table  : 'passport_settings'
             where  :
                 strategy : strategy
             columns: ['conf']
-            cb     : (err, result) ->
+            cb     : (err, results) ->
                 if err
+                    dbg("error getting passport conf for #{strategy} -- #{err}")
                     cb(err)
                 else
-                    cb(undefined, result[0])
-
+                    if results.length == 0
+                        dbg("WARNING: passport strategy #{strategy} not configured")
+                        cb(undefined, undefined)
+                    else
+
+                        cb(undefined, results[0][0])
+
+    # Set the site conf via cassandra like this:
+    #    update passport_settings set conf['auth']='https://cloud.sagemath.com/auth' where strategy='site_conf';
     get_conf 'site_conf', (err, site_conf) ->
+        if err or not site_conf?
+            cb(err)
+            return
         auth_url = site_conf.auth
+        dbg("auth_url=#{auth_url}")
 
         init_passport_local = (cb) ->
+            dbg("init_passport_local")
             # Strategy: local email address / password login
-            LocalStrategy = require('passport-local').Strategy
+            PassportStrategy = require('passport-local').Strategy
 
             verify = (username, password, done) ->
                 if username == 'a'

                console.log("local strategy validating user #{username}")
                done(null, {username:username})

            passport.use(new LocalStrategy(verify))

            app.get '/auth/local', (req, res) ->
                console.log('get login form')

init_passport = (app, cb) ->
    # Initialize authentication plugins using Passport
    passport = require('passport')
    dbg = (m) -> winston.debug("init_passport: #{m}")
    dbg()

    # initialize use of passport middleware
    app.use(passport.initialize())
