10.0.0 • Published 5 years ago

bell v10.0.0

Weekly downloads
1,070
License
BSD-3-Clause
Repository
github
Last release
5 years ago

bell

Third-party authentication plugin for hapi.

Lead Maintainer: Adri Van Houdt

Build Status

bell ships with built-in support for authentication using Facebook, GitHub, Google, Google Plus, Instagram, LinkedIn, Slack, Stripe, Twitter, Yahoo, Foursquare, VK, ArcGIS Online, Windows Live, Nest, Phabricator, BitBucket, Dropbox, Reddit, Tumblr, Twitch, Mixer, Salesforce, Pinterest, Discord, DigitalOcean, AzureAD, trakt.tv and Okta.

It also supports any compliant OAuth 1.0a and OAuth 2.0 based login services with a simple configuration object.

Documentation

API Documentation

Providers Documentation

Tutorials

Social Login with Twitter using hapi.js

Examples

All Examples

Twitter:

// Load modules

const Bell = require('bell');
const Hapi = require('hapi');


// Declare internals

const internals = {};


internals.start = async function () {

    const server = Hapi.server({ port: 8000 });

    // Register bell with the server

    await server.register(Bell);

    // Declare an authentication strategy using the bell scheme
    // with the name of the provider, cookie encryption password,
    // and the OAuth client credentials.

    server.auth.strategy('twitter', 'bell', {
        provider: 'twitter',
        password: 'cookie_encryption_password_secure',
        clientId: 'my_twitter_client_id',
        clientSecret: 'my_twitter_client_secret',
        isSecure: false     // Terrible idea but required if not using HTTPS especially if developing locally
    });

    // Use the 'twitter' authentication strategy to protect the
    // endpoint handling the incoming authentication credentials.
    // This endpoint usually looks up the third party account in
    // the database and sets some application state (cookie) with
    // the local application account information.

    server.route({
        method: ['GET', 'POST'],    // Must handle both GET and POST
        path: '/login',             // The callback endpoint registered with the provider
        options: {
            auth: 'twitter',
            handler: function (request, h) {

                if (!request.auth.isAuthenticated) {
                    return `Authentication failed due to: ${request.auth.error.message}`;
                }

                // Perform any account lookup or registration, setup local session,
                // and redirect to the application. The third-party credentials are
                // stored in request.auth.credentials. Any query parameters from
                // the initial request are passed back via request.auth.credentials.query.

                return h.redirect('/home');
            }
        }
    });

    await server.start();
};

internals.start();
10.0.0

5 years ago

9.5.0

5 years ago

9.4.0

5 years ago

9.3.1

6 years ago

9.3.0

6 years ago

9.2.0

6 years ago

9.1.0

6 years ago

9.0.0

6 years ago

8.9.0

6 years ago

8.8.0

7 years ago

8.7.0

7 years ago

8.6.0

7 years ago

8.5.0

7 years ago

8.4.0

7 years ago

8.3.0

8 years ago

8.2.1

8 years ago

8.2.0

8 years ago

8.1.1

8 years ago

8.1.0

8 years ago

8.0.1

8 years ago

8.0.0

8 years ago

7.9.3

8 years ago

7.9.2

8 years ago

7.9.1

8 years ago

7.9.0

8 years ago

7.8.0

8 years ago

7.7.3

8 years ago

7.7.2

8 years ago

7.7.1

8 years ago

7.7.0

8 years ago

7.6.1

8 years ago

7.6.0

8 years ago

7.5.1

8 years ago

7.5.0

8 years ago

7.4.0

8 years ago

7.3.0

8 years ago

7.2.0

8 years ago

7.1.0

8 years ago

7.0.0

8 years ago

6.3.0

8 years ago

6.2.0

8 years ago

6.1.0

8 years ago

6.0.0

8 years ago

5.4.0

9 years ago

5.3.0

9 years ago

5.2.0

9 years ago

5.1.0

9 years ago

5.0.1

9 years ago

5.0.0

9 years ago

4.0.1

9 years ago

4.0.0

9 years ago

3.0.0

9 years ago

2.9.0

9 years ago

2.8.0

9 years ago

2.7.1

9 years ago

2.7.0

9 years ago

2.6.0

9 years ago

2.5.0

9 years ago

2.4.0

9 years ago

2.3.0

9 years ago

2.2.0

9 years ago

2.1.0

9 years ago

2.0.0

9 years ago

2.0.0-rc1

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.0

10 years ago