Skip to content
This repository has been archived by the owner on Dec 15, 2019. It is now read-only.

Commit

Permalink
load related modules only when specific auth method is enabled
Browse files Browse the repository at this point in the history
Since Cantas supports several authentication strategies now and in the
future, most of the time, not all of them are enabled, in such a case
just load related dependent module for each enabled authentication
strategy is flexible and make it possible that administrator has the
opportunity to only install needed dependencies.

In particular, if someone deploys Cantas somewhere such as OpenShift
where it's impossible to `yum install` for Kerberos authentication, this
change can handle this situation easily.
  • Loading branch information
tkdchen committed Jun 27, 2015
1 parent 6e50f76 commit 744360d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions services/auth/strategies.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

'use strict';

var krb5 = require('node-krb5');
var LocalStrategy = require('passport-local').Strategy;
var RemoteUserStrategy = require('./remoteUserStrategy');
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
var settings = require('../../settings');
var User = require('../../models/user');
var utils = require('../utils');
Expand Down Expand Up @@ -66,6 +64,8 @@
var CantasKerberosStrategy = new LocalStrategy(function(kerberosName, password, done) {
// asynchronous verification, for performance concern.
process.nextTick(function() {
var krb5 = require('node-krb5');

// IMPORTANT! NEVER store or log password here. It violates infosec policy!
var principal = utils.build_krb5_user_principal(kerberosName, settings.realm);
var email = principal.toLowerCase();
Expand Down Expand Up @@ -126,6 +126,8 @@

var CantasGoogleStrategy;
if (settings.auth.google && settings.auth.google.clientID && settings.auth.google.clientSecret) {
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;

CantasGoogleStrategy = new GoogleStrategy({
clientID: settings.auth.google.clientID,
clientSecret: settings.auth.google.clientSecret,
Expand Down

0 comments on commit 744360d

Please sign in to comment.