Socket
Book a DemoInstallSign in
Socket

hapi-auth-man

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-auth-man

Cookie authentication plugin with onPostAuth ACL roles and view injection

latest
Source
npmnpm
Version
0.1.23
Version published
Maintainers
2
Created
Source

hapi-auth-man

Based on hapi-auth-cookie added

  • ACL support
  • Inject credentials into view context

###ACL Support

After initializing this plugin, you can set roles like plugins.plugin["hapi-auth-man"].roles = roles

roles must be object which keys specifies roles, values are promise returned functions.

roles = {
	"superadmin": function(request, database) {
		database.getUser(request.auth.credentials.id).then(function (user)) {
			if ( user.isSuperAdmin ) {
				return true;
			}
			return false;
		}.catch(function (e)) {
			return false;
		}			
	},
	"admin": function(request, database) {
		
 	}
	...
}

###Inject credentials into view context

On hapi 's onPreResponse event, if response object contains successful authentication and response type is view,

request.auth.credentials injecting into the view context as a credentials

You can use it in templates files like;

// in EJS
<% if (locals.credentials) { %>
    <h2><%= credentials.id %></h2>
<% } %>

###Authentication

Check out hapi-auth-cookie

Keywords

hapi

FAQs

Package last updated on 28 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.