@nearform/udaru-hapi-plugin

    5.3.2 • Public • Published

    Hapi Udaru Authentication Plugin

    npm travis coveralls snyk

    Udaru is a Policy Based Access Control (PBAC) authorization module. It supports Organizations, Teams and User entities that are used to build the access model. The policies attached to these entities define the 'Actions' that can be performed by an entity on various 'Resources'.

    See the Udaru website for complete documentation on Udaru.

    Install

    To install via npm:

    npm install @nearform/udaru-hapi-plugin
    

    Usage

    const Hapi = require('hapi')
    const UdaruPlugin = require('@nearform/udaru-hapi-plugin')
     
    ...
     
    const server = Hapi.server()
     
    await server.register({register: UdaruPlugin})

    Hooks

    In order to register udaru hooks, just provide a hooks key in the plugin options where keys are the names and values are handler functions (or array of functions).

    const Hapi = require('hapi')
    const UdaruPlugin = require('@nearform/udaru-hapi-plugin')
     
    ...
     
    const server = new Hapi.server()
     
    await server.register({
      register: UdaruPlugin,
      options: {
        // Other options here
        hooks: {
          'authorize:isUserAuthorized': [
            async function (error, args, result) {
              if (error) {
                console.error(`Authorization errored: ${error}`)
              } else {
                console.log(`Access to ${args[0]} got access: ${result[0].access}`)
              }
            }
          ]
        }
      }
    })

    License

    Copyright nearForm Ltd 2017. Licensed under MIT.

    Install

    npm i @nearform/udaru-hapi-plugin

    DownloadsWeekly Downloads

    9

    Version

    5.3.2

    License

    MIT

    Unpacked Size

    352 kB

    Total Files

    31

    Last publish

    Collaborators

    • capaj
    • alan.slater
    • davidefiorello
    • filippo.desantis
    • jimmymintzer
    • cianfoley_nearform
    • mattrobinson
    • shogun_panda
    • shaunjbaker
    • nearformer
    • matteo.collina
    • simoneb
    • iamsw
    • joezo
    • jackdclark
    • lpww
    • chrisdwheatley
    • admataz
    • ckiss
    • ovhemert
    • fiacc
    • zimny
    • irelandm
    • dublx
    • paolochiodi
    • eamonn.frisby
    • jackmurdoch
    • sameer13
    • gilach