A module to consume Freeipa server JSON_RPC API.
$ npm i --save node-freeipa
First of all import the module and configure it, the user and password are needed to authenticate to the API.
const ipa = require('node-freeipa')
const opts = {
server: "ipaserver.yourdomain",
auth: {
user: 'someuser',
pass: 'someuserpassword'
}
};
ipa.configure(opts);
Than make the call to desired method, below calling the json_metadata to return all methods provided by freipa server.
// Calling the method
ipa.json_metadata.then(result => {
console.log(result);
});
// Using async/await
let result = await ipa.json_metadata();
console.log(result);
Just remember, all methods will return a promise. A list with all methods can be seen in https://server/ipa/ui/#/p/apibrowser/type=command
Type: json
Pass all attributes for module configuration, the ones you can use:
var options = {
server: "domain-not-changed", //server.domain of your destination
auth: {
user: false,
pass: false,
},
ca: false, //Your Freeipa's CA loaded with fs
expires: 1440, // Time in minutes to expiration of cookie/auth.
cacheFolder: '.tmp', // Location where the cookie cache will be saved. Default: inside node_modules of the app.
};
Type: String
The method you wan't to call, ex: user_find.
Type: Array
Array of arguments you wan't to use, default: [].
Type: Json object
Json object containing options for the request, default: {}.
ipa.user_find().then(result => { });
//same as
ipa.user_find([""],{}).then(result => { });
// searching by an user with login
ipa.user_find([""],{login: 'mylogin'}).then(result => { });
// searching by criteria only
ipa.user_find(['mylogin']).then(result => { });
// searching by criteria only and option
ipa.user_find(['mylogin'], {mail: 'mylogin@domain.com'}).then(result => { });
These are padronized erros returning by any of the requests. Every error are returned from resolve, reject was discarded on version 2.2+.
ERROR | DESC |
---|---|
FREEIPA.NOARGS | No options was passed to Request Builder |
FREEIPA.NO_DATA | No data returned |
FREEIPA.AUTH_ERROR | Invalid authentication or json parse |
FREEIPA.REQUEST_ERROR | Error during the request |
FREEIPA.UNHANDLED_ERROR | Unhandled error |
<IPA.ERROR> | Returned from Freeipa Servers |
Below are some helpers on how to use Freeipa API:
Talking to Freeipa Freeipa API_Examples
MIT © Lucas Diedrich