Nasjonal Turbase Auth
Authenticate group (grupper) users in Nasjonal Turbase with 0 effort. Just install, and start using it.
Requirements
- Node.JS >= 0.10
- Nasjonal Turbase API key
Install
npm install turbasen-auth --save
Test
npm test
Usage
var auth = ;
Configure
This package uses the official Node.JS library for Nasjonal Turbase (turbasen.js) which can be fully configured using the environment variables:
NTB_API_KEY
- API key for authenticate requestsNTB_API_ENV
- API environment (default api, can be dev)NTB_USER_AGENT
- User Agent for API requests
You can also set or update the configuration programmatically using the
auth.turbasen.configure()
method.
auth.authenticate()
Authenticate user against Nasjonal Turbase.
Params
string
email - user emailstring
password - user passwordstring
callback - callback function (Error
error,object
user)
Return
The returned user object contains navn
(name), epost
(email), and gruppe
(group).
Example
auth;
auth.middleware()
A Connect / Express compatible middleware to make authentication super easy.
Body Params
The following params must be sent as JSON in the request body.
string
email - user emailstring
password - user password
Return
If the authentication succeeds the user information (identical to
authenticate()
) will be available in the req.turbasenAuth
variable.
Example
See server.js for a complete Express example.
app;
auth.createUserAuth()
Create user authentication object for storage in Nasjonal Turbase.
Params
string
name - user namestring
email - user emailstring
password - user passwordstring
callback - callback function (Error
error,object
user)
Return
The returned user object contains navn
(name), epost
(email), and pbkdf2
(user authentication).
Example
auth;