Adds support for several auth tokens
This commit is contained in:
@@ -128,6 +128,7 @@ console.log("Cert is : "); console.dir(cert);
|
||||
|
||||
// Check if the given certificate authorizes waiver of "auth"
|
||||
o.authorizedByCert = function(cert, auth) {
|
||||
auth = _.isArray(auth) ? auth : [auth];
|
||||
|
||||
var err = this.checkInvalidCertificate(cert);
|
||||
if ( err ) throw err;
|
||||
@@ -139,12 +140,7 @@ o.authorizedByCert = function(cert, auth) {
|
||||
|
||||
// Token based authentication requires valid token
|
||||
if ( method === 'token' ) {
|
||||
var found = cert.auth.valid_tokens.indexOf(auth);
|
||||
//if ( found !== -1 ) {
|
||||
//console.log("Token " + auth + " is found at position " + found + " in valid tokens " + cert.auth.valid_tokens);
|
||||
// return true;
|
||||
//} else return false;
|
||||
return cert.auth.valid_tokens.indexOf(auth) !== -1;
|
||||
return _.intersection(cert.auth.valid_tokens, auth).length > 0;
|
||||
}
|
||||
|
||||
throw new Error("Unsupported authentication method: " + cert.auth.method);
|
||||
|
||||
Reference in New Issue
Block a user