-
Notifications
You must be signed in to change notification settings - Fork 17
Added all new credential related routes #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -751,4 +751,197 @@ Security.prototype.getUserRights = function (userId, options, cb) { | |
}); | ||
}; | ||
|
||
/** | ||
* Create credentials of the specified <strategy> for the user <kuid>. | ||
* | ||
* @param strategy | ||
* @param kuid | ||
* @param credentials | ||
* @param options | ||
* @param cb | ||
* @returns {Security} | ||
*/ | ||
Security.prototype.createCredentials = function (strategy, kuid, credentials, options, cb) { | ||
if (!cb && typeof options === 'function') { | ||
cb = options; | ||
options = null; | ||
} | ||
|
||
this.kuzzle.query({controller: 'security', action: 'createCredentials'}, {_id: kuid, strategy: strategy, body: credentials}, options, function(err, res) { | ||
if (!err) { | ||
cb && cb(null, res.result._source); | ||
} else { | ||
cb && cb(err); | ||
} | ||
}); | ||
|
||
return this; | ||
}; | ||
|
||
/** | ||
* Delete credentials of the specified <strategy> for the user <kuid> . | ||
* | ||
* @param strategy | ||
* @param kuid | ||
* @param options | ||
* @param cb | ||
* @returns {Security} | ||
*/ | ||
Security.prototype.deleteCredentials = function (strategy, kuid, options, cb) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This applies to all the following methods that accept There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then kuzzle wil answer an error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok then we assume that we leave the responsibility to Kuzzle. Approving. |
||
if (!cb && typeof options === 'function') { | ||
cb = options; | ||
options = null; | ||
} | ||
|
||
this.kuzzle.query({controller: 'security', action: 'deleteCredentials'}, {strategy: strategy, _id: kuid}, options, typeof cb !== 'function' ? null : function(err, res) { | ||
if (!err) { | ||
cb && cb(null, res.result); | ||
} else { | ||
cb && cb(err); | ||
} | ||
}); | ||
|
||
return this; | ||
}; | ||
|
||
/** | ||
* Retrieve a list of accepted fields per authentication strategy. | ||
* | ||
* @param options | ||
* @param cb | ||
*/ | ||
Security.prototype.getAllCredentialFields = function (options, cb) { | ||
if (!cb && typeof options === 'function') { | ||
cb = options; | ||
options = null; | ||
} | ||
|
||
this.kuzzle.query({controller: 'security', action: 'getAllCredentialFields'}, {}, options, typeof cb !== 'function' ? null : function(err, res) { | ||
if (!err) { | ||
cb && cb(null, res.result); | ||
} else { | ||
cb && cb(err); | ||
} | ||
}); | ||
}; | ||
|
||
/** | ||
* Retrieve the list of accepted field names by the specified <strategy>. | ||
* | ||
* @param strategy | ||
* @param options | ||
* @param cb | ||
*/ | ||
Security.prototype.getCredentialFields = function (strategy, options, cb) { | ||
if (!cb && typeof options === 'function') { | ||
cb = options; | ||
options = null; | ||
} | ||
|
||
this.kuzzle.query({controller: 'security', action: 'getCredentialFields'}, {strategy: strategy}, options, typeof cb !== 'function' ? null : function(err, res) { | ||
if (!err) { | ||
cb && cb(null, res.result); | ||
} else { | ||
cb && cb(err); | ||
} | ||
}); | ||
}; | ||
|
||
/** | ||
* Get credential information of the specified <strategy> for the user <kuid>. | ||
* | ||
* @param strategy | ||
* @param kuid | ||
* @param options | ||
* @param cb | ||
*/ | ||
Security.prototype.getCredentials = function (strategy, kuid, options, cb) { | ||
if (!cb && typeof options === 'function') { | ||
cb = options; | ||
options = null; | ||
} | ||
|
||
this.kuzzle.query({controller: 'security', action: 'getCredentials'}, {strategy: strategy, _id: kuid}, options, typeof cb !== 'function' ? null : function(err, res) { | ||
if (!err) { | ||
cb && cb(null, res.result); | ||
} else { | ||
cb && cb(err); | ||
} | ||
}); | ||
}; | ||
|
||
/** | ||
* Check the existence of the specified <strategy>’s credentials for the user <kuid>. | ||
* | ||
* @param strategy | ||
* @param kuid | ||
* @param options | ||
* @param cb | ||
*/ | ||
Security.prototype.hasCredentials = function (strategy, kuid, options, cb) { | ||
if (!cb && typeof options === 'function') { | ||
cb = options; | ||
options = null; | ||
} | ||
|
||
this.kuzzle.query({controller: 'security', action: 'hasCredentials'}, {strategy: strategy, _id: kuid}, options, typeof cb !== 'function' ? null : function(err, res) { | ||
if (!err) { | ||
cb && cb(null, res.result); | ||
} else { | ||
cb && cb(err); | ||
} | ||
}); | ||
}; | ||
|
||
/** | ||
* Updates credentials of the specified <strategy> for the user <kuid>. | ||
* | ||
* @param strategy | ||
* @param kuid | ||
* @param credentials | ||
* @param options | ||
* @param cb | ||
* @returns {Security} | ||
*/ | ||
Security.prototype.updateCredentials = function (strategy, kuid, credentials, options, cb) { | ||
if (!cb && typeof options === 'function') { | ||
cb = options; | ||
options = null; | ||
} | ||
|
||
this.kuzzle.query({controller: 'security', action: 'updateCredentials'}, {strategy: strategy, _id: kuid, body: credentials}, options, typeof cb !== 'function' ? null : function(err, res) { | ||
if (!err) { | ||
cb && cb(null, res.result); | ||
} else { | ||
cb && cb(err); | ||
} | ||
}); | ||
|
||
return this; | ||
}; | ||
|
||
/** | ||
* Validate credentials of the specified <strategy> for the user <kuid>. | ||
* | ||
* @param strategy | ||
* @param kuid | ||
* @param credentials | ||
* @param options | ||
* @param cb | ||
*/ | ||
Security.prototype.validateCredentials = function (strategy, kuid, credentials, options, cb) { | ||
if (!cb && typeof options === 'function') { | ||
cb = options; | ||
options = null; | ||
} | ||
|
||
this.kuzzle.query({controller: 'security', action: 'validateCredentials'}, {strategy: strategy, _id: kuid, body: credentials}, options, typeof cb !== 'function' ? null : function(err, res) { | ||
if (!err) { | ||
cb && cb(null, res.result); | ||
} else { | ||
cb && cb(err); | ||
} | ||
}); | ||
}; | ||
|
||
module.exports = Security; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if
!strategy
?