# clapper

> Third-party acl plugin for hapi bell

Latest version **1.0.9** (published 2015-07-12) · 0 weekly downloads

## Install

```sh
npm install clapper
pnpm add clapper
yarn add clapper
bun add clapper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2015-07-12 |
| First published | 2015-06-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ho-Fan Kang |
| Maintainers | hofan41 |

## Links

- npm: https://www.npmjs.com/package/clapper
- Repository: https://github.com/hofan41/clapper
- Homepage: https://github.com/hofan41/clapper#readme
- Issues: https://github.com/hofan41/clapper/issues
- npm.io page: https://npm.io/package/clapper

## Dependencies (7)

- [joi](https://npm.io/package/joi.md) 6.x.x
- [bell](https://npm.io/package/bell.md) 2.x.x
- [boom](https://npm.io/package/boom.md) 2.x.x
- [hoek](https://npm.io/package/hoek.md) 2.x.x
- [promise](https://npm.io/package/promise.md) 7.x.x
- [hapi-auth-cookie](https://npm.io/package/hapi-auth-cookie.md) 3.x.x
- [hapi-require-https](https://npm.io/package/hapi-require-https.md) 2.x.x

## Recent versions

- 1.0.9 (latest) — 2015-07-12
- 1.0.8 — 2015-07-11
- 1.0.7 — 2015-07-10
- 1.0.6 — 2015-07-10
- 1.0.5 — 2015-06-17
- 1.0.4 — 2015-06-17
- 1.0.3 — 2015-06-17
- 1.0.2 — 2015-06-16
- 1.0.1 — 2015-06-16
- 1.0.0 — 2015-06-16

## README

![clapper Logo](https://raw.github.com/hofan41/clapper/master/images/clapper.png)

**clapper** is a third-party access control plugin for [hapi](https://github.com/hapijs/hapi). **clapper** uses and registers bell, hapi-auth-cookie, and hapi-require-https plugins. 

**clapper** is intended to be the only plugin you need to get simple OAuth authentication and access control working for your application.


Lead Maintainer: [Ho-Fan Kang](https://github.com/hofan41)

### Usage

**clapper** was designed to be fully functional via configuration.

**clapper** works by adding a global pre-handler on all incoming server requests. This handler function is used to determine whether or not 
the user can proceed by examining their access rights and the route's access pre-requisites.

```javascript
var Hapi = require('hapi');
var server = new Hapi.Server();

server.connection({ port: 8000 });

// Register clapper with the server.
// This example adds facebook as one of the login providers.
server.register({ 
    register: require('clapper'),
    options: {                      // plugin options are mandatory
      defaultRights: {
        anonymous: { canHazCheezburger: false },
        authenticated: { canHazCheezburger: true }
      },
      cookie: {                     // hapi-auth-cookie strategy options here
        password: COOKIE_PASSWORD,
        isSecure: false
      },
      logins: [ {
          displayName: 'Facebook',
          routeName: 'facebook',    // clapper will create a route at '/auth/facebook'
          bellProvider: {           // related bell strategy options here
            provider: 'facebook',
            password: COOKIE_PASSWORD,
            clientId: FACEBOOK_APP_ID,
            clientSecret: FACEBOOK_APP_SECRET,
            isSecure: false,
            forceHttps: false
          }
      } ]
    }
  },
function (err) {

  // Declare a route that requires the user to have the 'canHazCheezburger' right.
  // If the user does not have the right, they will be redirected to the error view.
  // If the user does have the right, the route handler function will be executed.
  server.route({
    path: '/',
    method: 'GET',
    config: {
      plugins: {
        clapper: {
          canHazCheezburger: true
        }
      }
    },
    handler: function (request, reply) {
      return reply('I can haz cheezburger!');
    }
  });

  // Start the server.
  // To test, please access:
  // 1. http://localhost:8000/              - confirm error page.
  // 2. http://localhost:8000/auth/facebook - login.
  // 3. http://localhost:8000/              - confirm cheezburger.
  server.start();
});
```

### Options

**clapper** requires the following plugin configuration options:
- `defaultRights` - an object containing the following:
    - `anonymous` - an object containing boolean properties representing an anonymous user's rights granted by default.
    - `authenticated` - an object containing boolean properties representing an authenticated user's rights granted by default.
- `cookie` - an object containing the [hapi-auth-cookie strategy options](https://github.com/hapijs/hapi-auth-cookie#hapi-auth-cookie) used by **clapper**
- `logins` - an array containing at least one instance of the object defined below:
    - `displayName` - a string representing the name of the authentication provider as displayed to the user
    - `routeName` - a unique string representing the name of the route to be created by **clapper** for authentication with the specified OAuth provider
    - `bellProvider` - an object containing the [bell authentication strategy options](https://github.com/hapijs/bell#options) used by **clapper**
    - `additionalRights` - **optional** an object containing boolean properties representing additional rights granted to any authenticated users using this specific authentication provider
    - `plugins` - **optional** an array of objects where each one is either:
        - a plugin registration function
        - an object with the following:
            - `register` - a hapi plugin registration function.
            - `options` - optional options passed to the registration function when called.

---
_Source: https://npm.io/package/clapper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
