{"id":15659414,"url":"https://github.com/bdefore/express-jwt-proxy","last_synced_at":"2025-05-05T19:28:04.663Z","repository":{"id":136861404,"uuid":"43813895","full_name":"bdefore/express-jwt-proxy","owner":"bdefore","description":"Express middleware for logging in via external JWT service and proxying authenticated calls to an external API service","archived":false,"fork":false,"pushed_at":"2016-02-12T15:33:46.000Z","size":33,"stargazers_count":21,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T17:45:34.769Z","etag":null,"topics":[],"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/bdefore.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}},"created_at":"2015-10-07T12:21:40.000Z","updated_at":"2023-03-28T05:33:17.000Z","dependencies_parsed_at":"2023-05-01T06:13:04.989Z","dependency_job_id":null,"html_url":"https://github.com/bdefore/express-jwt-proxy","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdefore%2Fexpress-jwt-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdefore%2Fexpress-jwt-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdefore%2Fexpress-jwt-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdefore%2Fexpress-jwt-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdefore","download_url":"https://codeload.github.com/bdefore/express-jwt-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252562296,"owners_count":21768268,"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-03T13:16:48.384Z","updated_at":"2025-05-05T19:28:04.642Z","avatar_url":"https://github.com/bdefore.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# express-jwt-proxy\n\nAn Express middleware to route login requests to an external authentication server and store JWT's and add them to headers en route to an external service.\n\n## Install\n\n`npm install express-jwt-proxy`\n\n## Usage\n\n```javascript\nconst isProduction = process.env.NODE_ENV === 'production';\nconst apiPortDefault = isProduction ? 443 : 3000;\nconst apiPort = process.env.API_PORT || apiPortDefault;\n\nconst authConfig = {\n  api: {\n    endpoint: '/v1',\n    host: process.env.API_HOST || 'http://localhost',\n    port: process.env.API_PORT || apiPortDefault\n  },\n  auth: {\n    clientId: isProduction ? process.env.JWT_CLIENT_ID : undefined,\n    clientSecret: isProduction ? process.env.JWT_CLIENT_SECRET : undefined,\n    endpoint: `${process.env.AUTHENTICATION_HOST}/authenticate`\n  },\n  debug: !isProduction,\n  endpoint: '/api',\n  sessionStore: {\n    type: 'redis',\n    prefix: 'jwt-example',\n    secret: process.env.JWT_CLIENT_SECRET,\n    url: process.env.REDIS_URL\n  }\n}\n\nconst app = new Express();\n\njwtProxy(app, authConfig);\n```\n\nYou should then be able to use the following routes:\n\n`POST {config.apiPrefix}/login`: Accepts a user object with `email` and `password` properties. These will be sent in a POST request to `authenticationEndpoint` and the response will contain an `access_token` which will be stored for that user's session.\n\n`POST {config.apiPrefix}/logout`: Will destroy the record of that user's JWT from the session\n\n`{config.apiPrefix}/*`: Will redirect to the configured API endpoint, appending the JWT stored in the session to the header\n\nIn your subsequent middleware, you'll be able to access the login state by using the following:\n\n```\nconst loggedIn = res._headers['logged-in'] === \"true\";\n```\n\n## Examples\n\n- [Using Universal Redux npm package](https://github.com/bdefore/universal-redux/tree/0.x/examples/jwt)\n\n## Inspiration\n\nhttp://alexbilbie.com/2014/11/oauth-and-javascript/\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdefore%2Fexpress-jwt-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdefore%2Fexpress-jwt-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdefore%2Fexpress-jwt-proxy/lists"}