{"id":19581196,"url":"https://github.com/jmw5598/node-express-jwt-example","last_synced_at":"2025-04-27T09:33:01.530Z","repository":{"id":92886046,"uuid":"158096906","full_name":"jmw5598/node-express-jwt-example","owner":"jmw5598","description":"An example project implementing JWT authentication and role base authorization with Node.js, Express.js, Sequelize, and Sqlite","archived":false,"fork":false,"pushed_at":"2019-03-31T14:35:06.000Z","size":112,"stargazers_count":18,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T23:33:21.479Z","etag":null,"topics":["authentication","authorization","es6","express","javascript","jsonwebtoken","jwt","node","role","sequelize","sequelizejs","sqlite","sqlite3"],"latest_commit_sha":null,"homepage":"","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/jmw5598.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":"2018-11-18T15:16:45.000Z","updated_at":"2025-02-11T08:10:42.000Z","dependencies_parsed_at":"2023-05-16T04:01:22.214Z","dependency_job_id":null,"html_url":"https://github.com/jmw5598/node-express-jwt-example","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/jmw5598%2Fnode-express-jwt-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmw5598%2Fnode-express-jwt-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmw5598%2Fnode-express-jwt-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmw5598%2Fnode-express-jwt-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmw5598","download_url":"https://codeload.github.com/jmw5598/node-express-jwt-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251118901,"owners_count":21539190,"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":["authentication","authorization","es6","express","javascript","jsonwebtoken","jwt","node","role","sequelize","sequelizejs","sqlite","sqlite3"],"created_at":"2024-11-11T07:34:03.422Z","updated_at":"2025-04-27T09:33:01.523Z","avatar_url":"https://github.com/jmw5598.png","language":"JavaScript","readme":"# Node Express JWT Authentication / Authorization Example\n\nAn example project implementing JWT authentication and role based authorization.\n\n### Demo Setup\n1. Clone the repository with `git clone https://github.com/jmw5598/node-express-jwt-example.git`\n2. Generate RSA256 public private keys and place them in the `config` folder with file names `public.key` and `private.key`.  A 512bit key size should be fine.\n    - [Online RSA Key Generator][1]\n3. Install dependencies with `npm install`.\n4. Run migrations and seed that Sqlite database with `sequelize db:migrate` and `sequelize db:seed:all`.\n5. Run the project with `node index.js`.\n\n### Default Credentials\n\n| Username | Password | Description |\n| - | - | - |\n| admin | admin | User with `ADMIN` and `USER` roles. |\n| user | user | User with only `USER` role. |\n\n### Default Routes\n\n| Path | Method | Description |\n| - | - | - |\n| `/auth` | `POST` | Authenticate user, returns JWT token.  Jwt token can the be place in `Authorization` header prefixed with `Bearer`|\n| `/users` | `GET` | List all users [requires ADMIN role] |\n| `/users` | `POST` | Create new user [requires ADMIN role] |\n| `/api/v1/restricted/usersOnly` | `GET` | Users only path |\n| `/api/v1/restricted/adminOnly` | `GET` | Admin only path |\n\n\n### Middleware Methods\n\n| Method | Description |\n| - | - |\n| `verify()` | Verifies token passed in `Authorization` request header.  Token prefixed with `Bearer` |\n| `hasRole(role)` | Ensures the authenticated user has appropriate role |\n| `hasAnyRole([role, role])` | Ensures the authenticated user has ANY of the appropriate roles |\n| `hasAllRoles([role, role])` | Ensures the authenticated user has ALL the appropriate roles |\n\n\n[1]: http://travistidwell.com/jsencrypt/demo/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmw5598%2Fnode-express-jwt-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmw5598%2Fnode-express-jwt-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmw5598%2Fnode-express-jwt-example/lists"}