<commit_before># Web Access Control implementation for Node.js

A stand-alone or express/connect Web Access Control implementation designed for Node.js with configurable graph callback.

See also:

* [Wiki article](http://www.w3.org/wiki/WebAccessControl)
* [Ontology](http://www.w3.org/ns/auth/acl)

## Usage

Example code:

`var fileCallbackOptions = {'baseUrl':'http://example.com','filename':'access.ttl'};`

`var accessControl = require('wac')({'graphCallback':wac.fileGraphCallback(fileCallbackOptions)});`

`accessControl.hasAccess('http://example.com/resource', 'GET', 'http://example.com/agent#me', null, callback);`

This code creates an access control object using the rules defined in the turtle file 'access.ttl' with the base URL 'http://example.com'.
The last line tests access for the resource 'http://example.com/resource' using HTTP method 'GET' for agent 'http://example.com/agent#me'.<commit_msg>added usage of the express middleware functionality to the readme file<commit_after># Web Access Control implementation for Node.js

A stand-alone or express/connect Web Access Control implementation designed for Node.js with configurable graph callback.

See also:

* [Wiki article](http://www.w3.org/wiki/WebAccessControl)
* [Ontology](http://www.w3.org/ns/auth/acl)

## Usage

Example code:

`var fileCallbackOptions = {'baseUrl':'http://example.com','filename':'access.ttl'};`

`var accessControl = require('wac')({'graphCallback':wac.fileGraphCallback(fileCallbackOptions)});`

`accessControl.hasAccess('http://example.com/resource', 'GET', 'http://example.com/agent#me', null, callback);`

This code creates an access control object using the rules defined in the turtle file 'access.ttl' with the base URL 'http://example.com'.
The last line tests access for the resource 'http://example.com/resource' using HTTP method 'GET' for agent 'http://example.com/agent#me'.

Express middleware example code:

`app.use(accessControl.middleware({}));`

Uses express/connect middleware functionality of the previously created `accessControl` object. 
{'fraction_non_alphanumeric': 0.13669413475521086, 'fraction_numerical': 0.0019389238972370335, 'mean_word_length': 5.701298701298701, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '844476', 'n_tokens_mistral': 598, 'n_tokens_neox': 587, 'n_words': 180}