{"id":22202159,"url":"https://github.com/rumkin/http-auth-payload","last_synced_at":"2025-03-25T00:59:21.868Z","repository":{"id":57268063,"uuid":"67890469","full_name":"rumkin/http-auth-payload","owner":"rumkin","description":"HTTP authorization header middleware","archived":false,"fork":false,"pushed_at":"2016-10-07T17:05:21.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-07T16:41:08.519Z","etag":null,"topics":["auth","authorization","connect","express","http","http-header","javascript"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rumkin.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","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":"2016-09-10T19:34:06.000Z","updated_at":"2018-03-15T01:54:18.000Z","dependencies_parsed_at":"2022-09-02T02:50:12.033Z","dependency_job_id":null,"html_url":"https://github.com/rumkin/http-auth-payload","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/rumkin%2Fhttp-auth-payload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fhttp-auth-payload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fhttp-auth-payload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fhttp-auth-payload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rumkin","download_url":"https://codeload.github.com/rumkin/http-auth-payload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245377989,"owners_count":20605377,"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":["auth","authorization","connect","express","http","http-header","javascript"],"created_at":"2024-12-02T16:12:35.227Z","updated_at":"2025-03-25T00:59:21.849Z","avatar_url":"https://github.com/rumkin.png","language":"JavaScript","readme":"# HTTP Authorization Payload Middleware\n\nParse authorization http header and add auth information into request object.\n\n![Build](https://img.shields.io/travis/rumkin/http-auth-payload.svg)\n\n## Install\n\nInstall with npm:\n```bash\nnpm i http-auth-payload\n```\n\n## Usage\n\nUsage example with express application:\n\n```javascript\nconst express = require('express');\nconst httpAuthPayload = require('http-auth-payload');\n\nexpress()\n    .use(httpAuthPayload)\n    .use((req, res, next) =\u003e {\n        if (req.auth.type !== 'bearer') {\n            res.status(403).send('Access denied');\n            return;\n        }\n\n        if (req.auth.payload !== 'secret-token') {\n            res.status(403).send('Access denied');\n            return;\n        }\n\n        next();\n    })\n    .use((req, res, next) =\u003e {\n        res.send('Logged in');\n    })\n    .listen();\n```\n\nIf authorization header not passed or empty then type has value `none` and\nrequest property 'hasAuth' is `false`.\n\n## API\n\n### (req, res, next)\n\nModule exports middleware.\n\n### parse(authorization) =\u003e AuthObject\n\nMethod parse authorization and return auth object:\n\n```\n{\n    type: 'http',\n    payload: '...',\n}\n```\n\n### parseRequest(request) =\u003e AuthObject\n\nMethod get request's authorization header and parse it with `parse` method.\n\n\n## License\n\nMIT.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumkin%2Fhttp-auth-payload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frumkin%2Fhttp-auth-payload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumkin%2Fhttp-auth-payload/lists"}