From 2b2a80421f216e394c261aaf021cd21130c28c58 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Sat, 16 Dec 2017 13:29:26 +0100 Subject: [PATCH] New translations dev-plugins.md (Spanish) --- website/translated_docs/es-ES/dev-plugins.md | 67 ++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 website/translated_docs/es-ES/dev-plugins.md diff --git a/website/translated_docs/es-ES/dev-plugins.md b/website/translated_docs/es-ES/dev-plugins.md new file mode 100644 index 000000000..6b5ba47a3 --- /dev/null +++ b/website/translated_docs/es-ES/dev-plugins.md @@ -0,0 +1,67 @@ +--- +id: dev-plugins +date: 2017-07-10T23:36:56.503Z +title: Developing Plugins +--- +There are many ways to extend `verdaccio`, currently we only support `authentication plugins` + +## Authentication Plugins + +This section will describe how it looks like a Verdaccio plugin in a ES5 way. Basically we have to return an object with a single method called `authenticate` that will recieve 3 arguments (`user, password, callback`). Once the authentication has been executed there is 2 options to give a response to `verdaccio`. + +##### OnError + +Either something bad happened or auth was unsuccessful. + + callback(null, false) + + +##### OnSuccess + +The auth was successful. + +`groups` is an array of strings where the user is part of. + + callback(null, groups); + + +### Example + +```javascript +function Auth(config, stuff) { + var self = Object.create(Auth.prototype); + self._users = {}; + + // config for this module + self._config = config; + + // verdaccio logger + self._logger = stuff.logger; + + // pass verdaccio logger to ldapauth + self._config.client_options.log = stuff.logger; + + return self; +} + +Auth.prototype.authenticate = function (user, password, callback) { + var LdapClient = new LdapAuth(self._config.client_options); + .... + LdapClient.authenticate(user, password, function (err, ldapUser) { + ... + var groups; + ... + callback(null, groups); + }); +}; + +module.exports = Auth; +``` + +## Storage Plugins + +// in progress + +## Middleware Integration + +// in progress \ No newline at end of file