Skip to content

Commit

Permalink
Update deperecation note for all() method and replaced outdated refer…
Browse files Browse the repository at this point in the history
…ences with the new everyone() method.
  • Loading branch information
coreybutler committed Oct 9, 2020
1 parent c82842f commit c64362d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (user.authorized('system resource', 'view')) {
</li>
<li>This was originally released as a library for <a href="https://butlerlogic.com" target="_blank">Butler Logic</a> clients. Fortunately, it has become a more generic tool, available for a general audience. As such, we've moved the package from <code>@butlerlogic/iam</code> to <code>@author.io/iam</code>. The Author npm organization is more suitable for long term support.</li>
</ol>
<p>This release also introduced 195 unit tests.</p>
</td>
</tr>
</table>
Expand Down Expand Up @@ -307,10 +308,10 @@ If a user was assigned to both the `basic user` _and_ `superuser` roles, the use
### Applying rights to everyone

There is a private/hidden role produced by IAM, called `everyone`. This role is always assigned to all users. It is used to assign permissions which are applicable to every user of the system. A special `all()` method simplifies the process of assigning rights to everyone.
There is a private/hidden role produced by IAM, called `everyone`. This role is always assigned to all users. It is used to assign permissions which are applicable to every user of the system. A special `everyone()` method simplifies the process of assigning rights to everyone.

```javascript
IAM.all({
IAM.everyone({
'resource': 'right',
'admin portal': 'deny:*',
'user portal': 'view', // A single string is valid
Expand Down Expand Up @@ -487,7 +488,7 @@ IAM.createResource({
})

// Deny admin portal rights for everyone.
IAM.all({
IAM.everyone({
'admin portal': 'deny:*'
})

Expand Down
2 changes: 1 addition & 1 deletion examples/ARCHIVE-@butlerlogic-iam/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const app = express()
IAM.createResource('blog', ['create', 'read', 'update', 'delete', 'list'])

// Identify rights associated with all users of the system.
IAM.all({
IAM.everyone({
blog: ['read', 'list']
})

Expand Down
2 changes: 1 addition & 1 deletion examples/ARCHIVE-@butlerlogic-iam/basic/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ IAM.createResource({

// Set defaults. Allow users to view the home
// and blog tabs, but deny access to the administrator.
IAM.all({
IAM.everyone({
home: '*',
blog: ['view', 'deny:edit']
})
Expand Down
2 changes: 1 addition & 1 deletion examples/ARCHIVE-@butlerlogic-iam/ui/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ IAM.createRole('superadmin', {
})

// Grant resource rights to everyone.
IAM.all({
IAM.everyone({
'admin portal': 'deny:*',
settings: '*',
profile: ['view', 'manage']
Expand Down
4 changes: 3 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Examples

We're working on new examples.
See the [codepen examples](https://codepen.io/coreybutler/pen/mdEyQxX).

The source is documented, and the unit tests provide other examples.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@author.io/iam",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "A Identification and Authorization Management library.",
"main": "src/index.js",
"module": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default class Manager extends Base {
reset () {
this.#items = new Map()
this.#named = new Map()
globalThis[REGISTRY_ID].all()
globalThis[REGISTRY_ID].everyone()
super.reset()
}
}
5 changes: 3 additions & 2 deletions src/lib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ class Registry extends Base {
}

all () {
console.warn('IAM.all() is deprecated. Use IAM.everyone() instead.')
const location = (new Error()).stack.split('\n').slice(1, 2).join('').trim()
console.warn('IAM.all() is deprecated. Use IAM.everyone() instead ' + location)
this.everyone(...arguments)
}

Expand Down Expand Up @@ -559,7 +560,7 @@ class Registry extends Base {
for (const role of cfg.roles) {
if (role.name && role.rights) {
if (role.name === 'everyone') {
this.all(role.rights)
this.everyone(role.rights)
} else {
const r = this.createRole(role.name, role.rights)
if (role.description) {
Expand Down

0 comments on commit c64362d

Please sign in to comment.