acl-elasticsearch-backend
An Elasticsearch backend for node_acl
Last updated 3 years ago by adnanesaghir .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install acl-elasticsearch-backend 
SYNC missed versions from official npm registry.

acl_elasticsearch_backend

An Elasticsearch backend for NODE ACL

#Installation

npm install acl-elasticsearch-backend

#How to use it

Usage sample:

'use strict';

var Elasticsearch = require('elasticsearch');
var AclEsBackend = require('acl-elasticsearch-backend');
var Acl = require('acl');

var client = new Elasticsearch.Client({
  apiVersion: '1.7',
  hosts: ['localhost:9200'],
  log: 'trace',
  keepAlive: true,
  maxSockets: 100,
  minSockets: 100
});
client.indices.putTemplate({
  name: 'acltest-template',
  body: {
    template: 'acltest',
    mappings: {
      _default_: {
        dynamic_templates: [
          {
            string_fields: {
              match: '*',
              match_mapping_type: 'string',
              mapping: {
                type: 'string',
                index: 'not_analyzed'
              }
            }
          }
        ]
      }
    }
  }
}, function(err, resp) {
  if (err) {
    throw new Error(err);
  }
  var aclEsBackend = new AclEsBackend({
    client: client,
    index: 'acltest',
    prefix: 'test_',
    refresh: true,
    size: 1000
  });
  var acl = new Acl(aclEsBackend);
  acl.addUserRoles('Joe', ['Admin', 'Moderator'], function(err) {
    if (err) {
      throw new Error(err);
    }
    acl.userRoles('Joe', function(err, roles) {
      console.log('Joe user roles are: ', roles);
    });
  });
});

#Documentation See NODE ACL documentation

Current Tags

  • 1.0.5                                ...           latest (3 years ago)

5 Versions

  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 5
Dependencies (3)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |