{"_id":"express-authorization","_rev":"13-66dd9105f0bbf93e795799bc101d037b","name":"express-authorization","description":"An authorization system for connect and express applications inspired by Apache's Shiro project.","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.0":{"name":"express-authorization","version":"0.1.0","description":"An authorization system for connect and express applications inspired by Apache's Shiro project.","main":"lib","scripts":{"test":"mocha -R spec test","dist":"mkdir -p dist; browserify -s authorization lib/consider.js -o dist/authorization.js; uglifyjs dist/authorization.js -o dist/authorization.min.js"},"keywords":["express","connect","authorization","shiro"],"repository":{"type":"git","url":"https://github.com/support-dot-com/express-authorization.git"},"author":{"name":"Support.com, Inc."},"contributors":[{"name":"Charles Eads"}],"license":"MIT","bugs":{"url":"https://github.com/support-dot-com/express-authorization/issues"},"_id":"express-authorization@0.1.0","dist":{"shasum":"7c1ed22cff19520e0ee5910f12411e00513f1493","tarball":"https://registry.npmjs.org/express-authorization/-/express-authorization-0.1.0.tgz","integrity":"sha512-eOWQA0EIMM2PviYu0ZItfW8yhK9Hs5HO1/ncY7oQZDdlXxsHDCN+WxEesrwhL7UPiM+pMisYpm6jtSFOrmuafg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG6wtKOt0n+XDIT6yoc3CdU8sOPIYYP5vb4xWuAIl6EEAiEA+lSGtlNc+U7UqNzzEs+A7/9YKM7oHC6uZ5+8aaQf56k="}]},"_resolved":"express-authorization-0.1.0.tgz","_from":"express-authorization-0.1.0.tgz","_npmVersion":"1.3.11","_npmUser":{"name":"charleseads","email":"charles@eads.org"},"maintainers":[{"name":"charleseads","email":"charles@eads.org"}]},"0.1.1":{"name":"express-authorization","version":"0.1.1","description":"An authorization system for connect and express applications inspired by Apache's Shiro project.","main":"lib","scripts":{"test":"mocha -R spec test","dist":"mkdir -p dist; browserify -s authorization lib/consider.js -o dist/authorization.js; uglifyjs dist/authorization.js -o dist/authorization.min.js"},"keywords":["express","connect","authorization","shiro"],"repository":{"type":"git","url":"https://github.com/support-dot-com/express-authorization.git"},"author":{"name":"Support.com, Inc."},"contributors":[{"name":"Charles Eads"}],"license":"MIT","bugs":{"url":"https://github.com/support-dot-com/express-authorization/issues"},"_id":"express-authorization@0.1.1","dist":{"shasum":"3b0d306360cb2e87b9fe3b34343653a7bcde99e3","tarball":"https://registry.npmjs.org/express-authorization/-/express-authorization-0.1.1.tgz","integrity":"sha512-HV1lc94E9FQ90AJhpKVDdrNv0tSrf66r3YumsbJLdrIv87tXPed6GnIbVS2xOjjG+eTFWW1K6fpu2B0N3JV82w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC+741XzTDYF5S3QvZ7qdXB/j7ADIGUJ+xaH5xtBN1ovgIgIqdXH5zRcCB1DdNZhJ5U19ri87Qb6MbmOgX+bxQnqdM="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"charleseads","email":"charles@eads.org"},"maintainers":[{"name":"charleseads","email":"charles@eads.org"}]},"1.0.0":{"name":"express-authorization","version":"1.0.0","description":"An authorization system for connect and express applications inspired by Apache's Shiro project.","main":"lib","scripts":{"test":"mocha -R spec test","dist":"mkdir -p dist; browserify -s authorization lib/consider.js -o dist/authorization.js; uglifyjs dist/authorization.js -o dist/authorization.min.js"},"keywords":["express","connect","authorization","shiro"],"repository":{"type":"git","url":"https://github.com/support-dot-com/express-authorization.git"},"author":{"name":"Support.com, Inc."},"contributors":[{"name":"Charles Eads"}],"license":"MIT","gitHead":"d138e39ba8d054b3fe340847678e483d00b7294a","bugs":{"url":"https://github.com/support-dot-com/express-authorization/issues"},"homepage":"https://github.com/support-dot-com/express-authorization","_id":"express-authorization@1.0.0","_shasum":"84ea1867798bf2e37f50f2e82b174775941a7ce0","_from":"./","_npmVersion":"1.4.28","_npmUser":{"name":"charleseads","email":"charles@eads.org"},"maintainers":[{"name":"charleseads","email":"charles@eads.org"}],"dist":{"shasum":"84ea1867798bf2e37f50f2e82b174775941a7ce0","tarball":"https://registry.npmjs.org/express-authorization/-/express-authorization-1.0.0.tgz","integrity":"sha512-QLyQXsmF6Y+zBJeqb64jj+wWopWcQWdDtNa8J838XuUCoQ5jVQVE8gSBmf2eBdwXPPGBP0OWLmNy2mQCoPvuog==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDqwE0lzHAd3x0NpfNxROMCMQtaifR0Cc0btEqqNVl06gIhAKUViU8k6/CCLEHj7g5I036gUFKV1c3N5I+aj3bjWY7j"}]}}},"readme":"# express-authorization\nAn express/connect middleware module for enforcing an Apache Shiro inspired authorization system.\n\n```js\nvar express = require('express');\nvar authorization = require('express-authorization');\nvar app = express();\n\n// Consider an authenticated user in the express session:\n// req.session.user.permissions = [\"restricted:*\"]\n\napp.get('/restricted',\n  authorization.ensureRequest.isPermitted(\"restricted:view\"),\n  function(req, res) {\n    ...\n  });\n```\n\n## Installation\n\n    $ npm install express-authorization\n\n## Features\n\n  * Easy integration into your express or connect based code\n  * Permission claim evaluation in the browser\n  * Expressive permissions inspired by [Apache Shiro](http://shiro.apache.org/permissions.html)\n  * Customizable to fit your application needs\n  * High test coverage\n\n## Philosophy\n\n  In __express-authorization__, a permission is a statement that defines access to an explicit activity, behavior or action.\n  Subjects, usually website users, are assigned permissions to enable access to sets of activities, behaviors, or actions.\n  To practically assign sets of permissions to subjects, __express-authorization__ supports a wildcard enabled permission statement\n  syntax that closely follows the syntax used by [Apache Shiro](http://shiro.apache.org/permissions.html).\n  A collection of permissions assigned to a subject are compiled by the system into a regular expression referred to as a claim.\n  Claims are then queried regarding whether or not they permit permissions that gate activities, behaviors, or actions.\n\n## Documentation\n\n### Permission Wildcard Expressions\n\n  __express-authorization__ uses the [Apache Shiro](http://shiro.apache.org/permissions.html) wildcard permission syntax directly.\n\n   * Permission statements are composed of from parts delimited by colons (:).\n   * Permission parts can contain lists delimited by commas (,).\n   * Wildcard ? and * can be used to match one or more chataters within an expression part.\n   * Examples: system:* | activity:create,update,delete\n\n### Permission Query\n\n  Permissions statements are strings that can be specified in parameter lists that may include arrays of composited permissions.\n  A subject, usually a user, is expected to be represented by an object with a permissions property refering to either\n  a single permission or an array of permissions.\n\n  In the permission query API, a permission source is placed under consideration and compiled into a claim that is\n  queries to confirm permitted permissions.\n\n```js\nauthorization\n  .considerSubject(user)\n  .isPermitted(\"express:coding\")\nauthorization\n  .considerPermissions(\"source:edit\", \"express:*\")\n  .isPermitted(\"express:coding\")\n```\n\n#### From subject or permission list -> claim -> isPermitted\n```js\nauthorization.considerSubject | authorization.considerPermissions -> claim\n```\n  The __considerSubject__ and __considerPermissions__ methods are used to generate a claim object.\n  A claim object is litterly a regular expression that matches any permissions that are permitted by the\n  subject, user, or permission list under consideration.  In addition, an __isPermitted__ method is exposed on\n  the claim for checking if one or more permissions are supported.  See the __consider__ test cases in the code\n  for more examples.\n\n### Express Middleware\n\n  __express-authorization__ uses a fluent API to generate express middleware for enforcing permissions.\n  ```js\n  authorization.ensureRequest.isPermitted(\"restricted:view\")\n  ```\n  To generate an express middleware, you write a call chain starting with a reference to __authenticate.ensureRequest__\n  and ending in a call to __isPermitted__.  The call to __isPermitted__ returns a connect/express compliant middleware function.\n\n  By default, __ensureRequest__ sources permissions from the session through references to session.user.permissions or session.permissions.\n  To consider alternative permission sources, __withSubject__ or __withPermissions__ callbacks (asynchronous or immediate) are used.\n  ```js\n  authorization.ensureRequest\n    .withPermissions(function (req, res, done) { done([\"identity:*\"]); })\n    .isPermitted(\"identity:edit\");\n  ```\n\n  __ensureRequest__ redirects to __/login__ by default when a request is denied.\n  __redirectTo__ can be used to specify an alternate redirect url.\n  __onDenied__ can be used to prived a custom response function.\n\n  All of these options (__withSubject__, __withPermissions__, __redirectTo__, and __onDenied__)\n  can be set either through chained API calls, or on the __ensureRequest.options__ object.\n  When set on the global __authorization.ensureRequest.options__, these establish new defaults.\n\n  A custom __new authorization.EnsureRequest()__ object can be constructed for use if required.\n\n### Browser\n\n  The __dist__ directory includes a version of the permission query API that can be used in your web pages.  See __dist/authorization.js__.\n\n## License\n\nMIT License\n\nCopyright (c) 2013 [Support.com, Inc.](http://www.support.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","maintainers":[{"name":"charleseads","email":"charles@eads.org"}],"time":{"modified":"2022-06-17T22:09:05.844Z","created":"2013-11-14T21:16:28.786Z","0.1.0":"2013-11-14T21:16:31.050Z","0.1.1":"2013-11-26T03:57:27.167Z","1.0.0":"2015-03-20T20:06:45.266Z"},"author":{"name":"Support.com, Inc."},"repository":{"type":"git","url":"https://github.com/support-dot-com/express-authorization.git"},"users":{"charleseads":true,"mjurincic":true,"maniteja":true,"kodekracker":true},"homepage":"https://github.com/support-dot-com/express-authorization","keywords":["express","connect","authorization","shiro"],"contributors":[{"name":"Charles Eads"}],"bugs":{"url":"https://github.com/support-dot-com/express-authorization/issues"},"license":"MIT","readmeFilename":"README.md"}