{"id":24383277,"url":"https://github.com/firstandthird/hapi-api-key","last_synced_at":"2025-04-11T01:12:24.344Z","repository":{"id":54281990,"uuid":"61217516","full_name":"firstandthird/hapi-api-key","owner":"firstandthird","description":"Hapi authentication plugin for api keys via query string or request header","archived":false,"fork":false,"pushed_at":"2021-02-26T20:30:02.000Z","size":33,"stargazers_count":4,"open_issues_count":2,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-11T01:12:18.486Z","etag":null,"topics":["hapi-plugin","hapi-v17"],"latest_commit_sha":null,"homepage":null,"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/firstandthird.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-06-15T15:08:35.000Z","updated_at":"2023-09-29T17:01:21.000Z","dependencies_parsed_at":"2022-08-13T10:50:52.975Z","dependency_job_id":null,"html_url":"https://github.com/firstandthird/hapi-api-key","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstandthird%2Fhapi-api-key","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstandthird%2Fhapi-api-key/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstandthird%2Fhapi-api-key/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstandthird%2Fhapi-api-key/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firstandthird","download_url":"https://codeload.github.com/firstandthird/hapi-api-key/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322571,"owners_count":21084337,"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":["hapi-plugin","hapi-v17"],"created_at":"2025-01-19T10:14:04.315Z","updated_at":"2025-04-11T01:12:24.331Z","avatar_url":"https://github.com/firstandthird.png","language":"JavaScript","readme":"## hapi-api-key\n\n\n[![Build Status](https://travis-ci.org/firstandthird/hapi-api-key.svg?branch=master)](https://travis-ci.org/firstandthird/hapi-api-key)\n\nHapi auth scheme that allows users to access a route based on whether they have a valid api key presented either as a query or as a header.\nRegister hapi-api-key as a plugin\nto make the 'api-key' scheme available for use with server.auth.strategy(...).\n\n### Installation\n\n`npm install hapi-api-key`\n\n### Usage\n\n```javascript\n  const hapiApiKeyPlugin = require('hapi-api-key');\n  await server.register({\n    plugin: hapiApiKeyPlugin,\n    options: {}\n  });\n  server.auth.strategy('api-key', 'api-key', {\n    apiKeys: {\n      1234: {\n        name: 'hueniverse'\n      }\n    }\n  });\n```\n\n### Options\n\n- __apiKeys__ (required)\n\n  List of allowed API keys\n\n- __schemeName__\n\n  The name hapi will use to refer to the schema.  By default this is 'api-key' but you\n  can make it whatever you want.\n\n- __validateKey__\n\n  hapi-api-key comes with a default function that approves or denies access\n  based on whether the header or field matches the list of allowed API keys,\n  but you can provide your own validateKey function instead.  Alternatively you\n  can specify validateKey as a string, in which case hapi-api-key will look for a\n  server method with that name in _server.methods_.\n\n- __queryKey__\n\n  The query field that contains the API key, by default this is 'token' (i.e.\n    _?token=1234567_) but you can override this to be whatever you want.\n\n- __headerKey__\n\n  The header field that contains the API key, by default this is the _x-api-key_\n  header but you can override this to be whatever you want.\n\n- __strategy__\n\n  By default hapi-api-key registers the api-key scheme with HAPI and then you manually register\n  a strategy that uses that scheme with server.auth.strategy(). But you can have hapi-api-key\n  register the strategy for you by passing a _strategy_ object when you register the plugin:\n```js\n{\n  strategy: {\n   name: 'myStrategyName',\n   mode: true,\n   apiKeys: {\n     'anAPIKey': {\n       name: 'authenticationName'\n     }\n   ]\n  }\n}\n  ```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstandthird%2Fhapi-api-key","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirstandthird%2Fhapi-api-key","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstandthird%2Fhapi-api-key/lists"}