https://github.com/data-fair/sd-express
Middleware and router helpers to write expressjs applications that depend on simple-directory for authentication.
https://github.com/data-fair/sd-express
Last synced: 4 months ago
JSON representation
Middleware and router helpers to write expressjs applications that depend on simple-directory for authentication.
- Host: GitHub
- URL: https://github.com/data-fair/sd-express
- Owner: data-fair
- License: mit
- Created: 2018-05-07T20:20:38.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-05-28T08:05:29.000Z (about 1 year ago)
- Last Synced: 2025-10-11T02:59:07.264Z (8 months ago)
- Language: JavaScript
- Size: 2.59 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple Directory - Express
[](https://travis-ci.org/data-fair/sd-express)
[](https://coveralls.io/github/data-fair/sd-express?branch=master)
Middleware and router helpers to write expressjs applications that depend on [simple-directory](https://data-fair.github.io/simple-directory/) for authentication.
npm i @data-fair/sd-express
Initialization:
```
const app = require('express')()
const session = require('@data-fair/sd-express')({directoryUrl: 'http://my-simple-directory'})
// These routes are authenticated. In your router req.user will be defined with the content of the session.
app.use('/api', session.auth, apiRouter)
// These routes can all be used as callback redirections from authentication (thanks to session.loginCallback)
// Also they will have req.user but without the cost of crypto verification and session prolongation (thanks to session.decode)
app.use('/ui', session.loginCallback, session.decode, uiRouter)
// The router exposes login, logout and ping routes to manage auth and session.
app.use('/session', session.router)
```
**TODO**: Proper documentation of options and functionalities. For now [the code is the doc](https://github.com/data-fair/sd-express/blob/master/index.js).