<commit_before>'use strict';
// =========================================================================
//
// Policies for buckets
//
// =========================================================================
var acl  = require ('acl');
acl      = new acl (new acl.memoryBackend ());

exports.invokeRolesPolicies = function () {
	acl.allow ('admin', [
		'/api/bucket',
		'/api/bucket/:bucket',
		'/api/new/bucket'
		], '*'
	);
	acl.allow ('guest', [
		'/api/bucket',
		'/api/bucket/:bucket',
		'/api/new/bucket'
		], 'get'
	);
};

exports.isAllowed = function (req, res, next) {
	var roles = (req.user) ? req.user.roles : ['admin'];
	acl.areAnyRolesAllowed (roles, req.route.path, req.method.toLowerCase(), function (err, isAllowed) {
		if (err) {
			// An authorization error occurred.
			return res.status(500).send('Unexpected authorization error');
		} else {
			if (isAllowed) {
				// Access granted! Invoke next middleware
				return next();
			} else {
				return res.status(403).json({
					message: 'User is not authorized'
				});
			}
		}
	});
};


<commit_msg>Added 'base' url to policy<commit_after>'use strict';
// =========================================================================
//
// Policies for buckets
//
// =========================================================================
var acl  = require ('acl');
acl      = new acl (new acl.memoryBackend ());

exports.invokeRolesPolicies = function () {
	acl.allow ('admin', [
		'/api/bucket',
		'/api/bucket/:bucket',
		'/api/base/bucket',
		'/api/new/bucket'
		], '*'
	);
	acl.allow ('guest', [
		'/api/bucket',
		'/api/bucket/:bucket',
		'/api/base/bucket',
		'/api/new/bucket'
		], 'get'
	);
};

exports.isAllowed = function (req, res, next) {
	var roles = (req.user) ? req.user.roles : ['admin'];
	acl.areAnyRolesAllowed (roles, req.route.path, req.method.toLowerCase(), function (err, isAllowed) {
		if (err) {
			// An authorization error occurred.
			return res.status(500).send('Unexpected authorization error');
		} else {
			if (isAllowed) {
				// Access granted! Invoke next middleware
				return next();
			} else {
				return res.status(403).json({
					message: 'User is not authorized'
				});
			}
		}
	});
};



{'fraction_non_alphanumeric': 0.29850746268656714, 'fraction_numerical': 0.005427408412483039, 'mean_word_length': 3.542094455852156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2760136', 'n_tokens_mistral': 803, 'n_tokens_neox': 697, 'n_words': 150}