{"id":16124233,"url":"https://github.com/itaditya/acl-tutorial","last_synced_at":"2025-04-06T12:22:38.579Z","repository":{"id":99907503,"uuid":"109469798","full_name":"itaditya/acl-tutorial","owner":"itaditya","description":"A descriptive tutorial to serve as a starting point for doing Authentication and Authorization in Nodejs","archived":false,"fork":false,"pushed_at":"2017-11-09T14:00:54.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-12T18:18:46.643Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itaditya.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-04T05:32:57.000Z","updated_at":"2017-11-04T13:36:30.000Z","dependencies_parsed_at":"2023-05-11T00:15:12.878Z","dependency_job_id":null,"html_url":"https://github.com/itaditya/acl-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itaditya%2Facl-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itaditya%2Facl-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itaditya%2Facl-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itaditya%2Facl-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itaditya","download_url":"https://codeload.github.com/itaditya/acl-tutorial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247479477,"owners_count":20945468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T21:20:12.168Z","updated_at":"2025-04-06T12:22:38.546Z","avatar_url":"https://github.com/itaditya.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Simple authentication and authorization example with passport, node_acl, MongoDB and expressjs(v4.x)\n\u003e The example shown here uses local userdata and sessions to remember a\n logged in user. Roles are persistent all the way and applied to user\n after logging in.\n\n### Usage:\n 1. Install dependencies with `npm i`.\n 2. Start this as server by running `npm start`. Make sure mongo is also running.\n 3. Play with the resoures.\n \n    **Login via GET**\n     http://localhost:3500/login?username=bob\u0026password=secret\n\n    **Logout**\n     http://localhost:3500/logout\n\n    **Check your current user and roles**\n     http://localhost:3500/status\n\n    **Only visible for users and higher**\n     http://localhost:3500/secret\n\n    **Manage roles**\n    user is either 1 or 2 and role is either 'guest', 'user' or 'admin'\n     http://localhost:3500/allow/:user/:role\n     http://localhost:3500/disallow/:user/:role\n\n\n### Explanation:\n * Passport is used to **authenticate** a user.\n * Acl is used to **authorize** a user.\n * There are two users present in memory. You can login as either one of them.\n * When you first start a server, a *logged in user* has *no role*.\n * Such user cannot access any *resources*. You can check this at http://localhost:3500/secret.\n * In our code, there are three roles - *admin, user, guest* .\n * User can do anything that guest can do (Using `acl.addRoleParents('user', 'guest')`)\n * Admin can do anything that user can do. (Using `acl.addRoleParents('admin', 'user')`)\n * Also admin can do *anything* with **secret** resource.\n * A user can only *get* the **secret** resource.\n * A guest can do nothing.\n * To assign an authenticated(logged in) user a role, we use `acl.addUserRoles(userId, role)` method. This is wrapped in http://localhost:3500/allow/:user/:role.\n    Try out - http://localhost:3500/allow/1/user. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitaditya%2Facl-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitaditya%2Facl-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitaditya%2Facl-tutorial/lists"}