New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ndx-auth

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ndx-auth

authorization endpoints for ndx-framework

latest
Source
npmnpm
Version
0.1.13
Version published
Maintainers
1
Created
Source

ndx-auth

oauth2 user authentication for ndx-framework

install with
npm install --save ndx-auth

what it does

ndx-auth adds a post route /auth/token to your app, calling this with a valid base64 encoded Basic Authentication header will provide an accessToken which can then be used to connect to the app.

Example

src/server/app.coffee

require 'ndx-server'
.config
  database: 'db'
.use 'ndx-cors'
.use 'ndx-user-roles'
.use 'ndx-auth'
.use 'ndx-superadmin'
.controller (ndx) ->
  ndx.app.get '/api/protected', ndx.authenticate('superadmin'), (req, res, next) ->
    res.json res.user
.start()

connector.coffee

$scope.username = 'superadmin@admin.com'
$scope.password = 'admin'
user = "#{$scope.username}:#{$scope.password}"
$http.defaults.headers.common['Authorization'] = 'Basic ' + base64.encode(user)
$http.post 'http://localhost:3000/auth/token'
.then (response) ->
  if response.data and response.data.accessToken
    $http.defaults.headers.common['Authorization'] = 'Bearer ' + response.data.accessToken
    #all api calls will now be authenticated
    $http.get 'http://localhost:3000/api/protected'
    .then (response) ->
      console.log response.data

FAQs

Package last updated on 05 Feb 2018

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