{"id":21643867,"url":"https://github.com/antarasi/feathers-auth-test","last_synced_at":"2025-03-19T08:47:31.855Z","repository":{"id":79121843,"uuid":"114408611","full_name":"antarasi/feathers-auth-test","owner":"antarasi","description":"This project is prepared to test feathers authentication using REST and socket.io.","archived":false,"fork":false,"pushed_at":"2017-12-18T11:36:08.000Z","size":59,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-25T04:11:00.668Z","etag":null,"topics":["feathers","feathers-authentication","jwt"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antarasi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-12-15T20:27:16.000Z","updated_at":"2017-12-18T09:53:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"205a8cc6-9f0d-4dd3-a5cf-dcdda499e8f1","html_url":"https://github.com/antarasi/feathers-auth-test","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/antarasi%2Ffeathers-auth-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antarasi%2Ffeathers-auth-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antarasi%2Ffeathers-auth-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antarasi%2Ffeathers-auth-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antarasi","download_url":"https://codeload.github.com/antarasi/feathers-auth-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244394463,"owners_count":20445634,"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":["feathers","feathers-authentication","jwt"],"created_at":"2024-11-25T05:36:31.790Z","updated_at":"2025-03-19T08:47:31.843Z","avatar_url":"https://github.com/antarasi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# feathers-auth-test\n\n\u003e \n\n## About\n\nThis project is prepared to test feathers authentication using REST and socket.io.\n\n## What's inside\n\nServer is configured to have 2 protected endpoints in users service:\n\n1. FIND: `users:find` protected by `@feathersjs/authentication.hooks.authenticate('jwt')`\n2. GET: `users:get` protected by `feathers-authentication-hooks.restrictToAuthenticated()` \n\nand specs to run against two transports (REST and socket.io) to test authorization:\n\n`test/auth.test.js`:\n1. should reject unauthorized access\n    - When not logged in - both endpoints should reject requests\n2. should login correctly\n    - Perform login routine that result in generating `accessToken`\n3. should find all users (authenticate:jwt)\n    - Requested FIND endpoint should be fulfilled after login\n4. should get one user (restrictToAuthenticated)\n    - Requested GET endpoint should be fulfilled after login\n5. authtoken should be expired now\n    - Wait for `authToken` to expire \n6. should reject to find users (authenticate:jwt)\n    - Requested FIND endpoint should be rejected after `authToken` expiration\n7. should reject to get user (restrictToAuthenticated)  \n    - Requested GET endpoint should be rejected after `authToken` expiration\n\n## How to run\n\nRun npm scipt: `npm run mocha:auth`\n\n## Test results\n\nResponse messages are either misleading or not consistent in comparison to other transports. Therefore it breaks transport agnosticism rule.  \n\n### Socket.io failed tests:\n\n#### 6. should reject to find users (authenticate:jwt)\n```\n    Socket.io tests\n        6. should reject to find users (authenticate:jwt):\n            AssertionError: expected promise to be rejected with an error including 'jwt expired' but it was fulfilled with { Object (total, limit, ...) }\n```\n\nI expect that after the token expires, I should get `jwt expired` error message, but `authenticate('jwt')` method is fulfilling the request regardless of token expiration time. REST transport passes that test responding with `jwt expired`.\n\n  \n#### 7. should reject to get user (restrictToAuthenticated)\n```\n    Socket.io tests\n        7. should reject to get user (restrictToAuthenticated):\n            AssertionError: expected promise to be rejected with an error including 'You are not authenticated' but it was fulfilled with { Object (email, _id) }\n```\n\nI expect that after the token expires, I should get `jwt expired` error message, but `restrictToAuthenticated()` method is fulfilling the request regardless of token expiration time. REST transport passes that test responding with `jwt expired`. \n\n### REST failed tests:\n\n#### 4. should get one user (restrictToAuthenticated)\n```\n   REST tests\n        4. should get one user (restrictToAuthenticated):\n            NotAuthenticated: You are not authenticated.\n             at new NotAuthenticated (node_modules\\@feathersjs\\client\\dist\\feathers.js:508:17)\n             at convert (node_modules\\@feathersjs\\client\\dist\\feathers.js:653:32)\n             at toError (node_modules\\@feathersjs\\client\\dist\\feathers.js:94:9)\n             at \u003canonymous\u003e\n             at process._tickCallback (internal/process/next_tick.js:188:7)\n```\n\nI expect that when passing valid access token, `restrictToAuthenticated()` method should parse token from request like `authenticate('jwt')` does, but it looks like it doesn't. Socket.io transport passes that test and fulfill the request. What's the purpose of having either `authenticate('jwt')` and `restrictToAuthenticated()` methods that produce different behavior and make authorization less predictable?  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantarasi%2Ffeathers-auth-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantarasi%2Ffeathers-auth-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantarasi%2Ffeathers-auth-test/lists"}