{"id":14970045,"url":"https://github.com/knownasilya/just-auth","last_synced_at":"2025-08-17T14:03:27.962Z","repository":{"id":25551871,"uuid":"28984904","full_name":"knownasilya/just-auth","owner":"knownasilya","description":"Simple token based authentication for Express.js","archived":false,"fork":false,"pushed_at":"2023-07-12T23:39:10.000Z","size":816,"stargazers_count":3,"open_issues_count":8,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-17T14:02:39.012Z","etag":null,"topics":["authentication","expressjs","jsonwebtoken","jwt","middleware"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knownasilya.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2015-01-08T20:38:41.000Z","updated_at":"2022-01-15T15:19:45.000Z","dependencies_parsed_at":"2024-09-23T06:02:50.227Z","dependency_job_id":"7dbb8457-5862-4cde-b995-178aed43c397","html_url":"https://github.com/knownasilya/just-auth","commit_stats":{"total_commits":139,"total_committers":3,"mean_commits":"46.333333333333336","dds":0.1151079136690647,"last_synced_commit":"2dc030c882d32c83abe7c7740a55bc484c60dfd2"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/knownasilya/just-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fjust-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fjust-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fjust-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fjust-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knownasilya","download_url":"https://codeload.github.com/knownasilya/just-auth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fjust-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270856775,"owners_count":24657700,"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","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","expressjs","jsonwebtoken","jwt","middleware"],"created_at":"2024-09-24T13:42:56.715Z","updated_at":"2025-08-17T14:03:27.894Z","avatar_url":"https://github.com/knownasilya.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# just-auth\n\n[![NPM][npm-badge-img]][npm-badge-link]\n[![Build Status][travis-badge]][travis-badge-url]\n[![Coverage Status][coveralls-badge]][coveralls-badge-url]\n\nSimple SPA focused token based authentication for Express.js\nThis library follows convention over configuration, but configuration is available :wink:.\n\n## Installation\n\nDownload node at [nodejs.org](http://nodejs.org) and install it, if you haven't already.\n\n```sh\nnpm install just-auth --save\n```\n\n\n## Usage\n\n```js\nconst express = require('express');\nconst justAuth = require('just-auth');\nconst app = express();\nconst auth = justAuth({\n  secret: 'c47sRfunny101',\n\n  getUser(email, callback) {\n    // if error: callback({ myerror: 'failure' });\n    // if success: callback(undefined, { email: 'my@email', passwordHash: '%asdaq42ad..' });\n  },\n\n  // Default behavior (don't specify if this suites you)\n  configureToken(user) {\n    // user without passwordHash\n    return user;\n  }\n});\n\napp.use('/auth', auth.router);\n\n// Can also use `succeeded()` and `failed()` for redirects, etc.\n// See https://www.npmjs.com/package/express-authentication\napp.use('/api/admin', auth.middleware.required());\n\napp.listen(80);\n```\n\nPOST to `/auth/login` with `{ email: 'my@email', password: 'bacon' }`.\nResult will be JSON, e.g. `{ token: '2mkql3...' }`.\n\n_Note: To use the built in password utilities, you can use the following:_\n\n```js\nconst passUtils = require('just-auth/lib/password');\n\nconst isValid = passUtils.validate(pass, hash);\n\npassUtils.hash(pass, function (err, hash) {\n  // error or hash\n});\n```\n\n\n## Available Options\n\n* `secret` - String, **required**.\n* `loginEndpoint` - String, defaults to '/login'.\n* `idField` - String, defaults to 'email', the field name of the identifier for the user.\n  The value of this field is passed to the `getUser` function.\n* `passwordField` - String, defaults to 'password'.\n* `passwordHashField` - String, defaults to 'passwordHash'.\n* `rememberMeField` - String, defaults to 'rememberMe'.\n* `rememberMeAdditionalMinutes` - Number, defaults to 13 days in minutes.\n* `tokenOptions` - Object, defaults to [this](https://github.com/knownasilya/just-auth/blob/master/index.js#L16). See full options\n  [here](https://github.com/auth0/node-jsonwebtoken/tree/v7.0.0#jwtsignpayload-secretorprivatekey-options-callback).\n\n### Methods\n\n* `getUser` - **Required**; Function, `function (id, callback)`, should return a user object or an error via the callback.\n* `configureToken` - Function, `function (user)`, should return the data that you want in the token, defaults to `user` if not specified.\n* `validatePassword` - Function, `function (password, passwordHash)` should return a promise.\n  By default this is `pbkdf2Utils.verify`, see [here](https://www.npmjs.com/package/pbkdf2-utils).\n\n\n## Tests\n\n```sh\nnpm install\nnpm test\n````\n\n## License\n\nISC\n\n[npm-badge-img]: https://badge.fury.io/js/just-auth.svg\n[npm-badge-link]: http://badge.fury.io/js/just-auth\n[travis-badge]: https://travis-ci.org/knownasilya/just-auth.svg?branch=master\n[travis-badge-url]: https://travis-ci.org/knownasilya/just-auth\n[coveralls-badge]: https://coveralls.io/repos/knownasilya/just-auth/badge.svg?branch=master\n[coveralls-badge-url]: https://coveralls.io/r/knownasilya/just-auth?branch=master\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknownasilya%2Fjust-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknownasilya%2Fjust-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknownasilya%2Fjust-auth/lists"}