att-express-auth
Drop-in auth middleware for alpha-auth AT&T.
Last updated 8 years ago by nlf .
Original npm · Tarball · package.json
$ cnpm install att-express-auth 
SYNC missed versions from official npm registry.

AT&T Alpha-auth middleware for Express.js

Super simple oauth middleware for AT&T's alpha auth

First you have to go register your application and get a client ID and client secret. Just drop those into the code below and then just add a link or button that points to /auth somewhere on your page and you're good to go.

install

npm install att-express-auth

The code below should work once you've dropped in your client id and secret:

var express = require('express'),
    attAuth = require('att-express-auth'),
    app = express();

// config our middleware
app.use(express.cookieParser());
app.use(express.session({ secret: 'phone phone phone' }));
app.use(attAuth.middleware({
    app: app,
    clientId: 'YOUR CLIENT ID',
    clientSecret: 'YOUR CLIENT SECRET',
    scopes: ['profile', 'addessbook', 'locker', 'messages', 'geo'],
    accountsUrl: 'https://auth.tfoundry.com' // whatever accounts server you want to use, defaults to https://auth.tfoundry.com
    redirectUrl: 'http://localhost:3000/secured' // whatever URL you want users to be redirected to after auth
}));

app.get('/', function (req, res) {
    res.send('<h1>AT&T Express App sample</h1><a href="/auth">login</a>');
});

app.get('/login', function (req, res) {
    res.send('<h1>Please login</h1><a href="/auth">login</a>');
});

app.get('/login-failed', function (req, res) {
    res.send('<h1>Login failed</h1>');
});

app.get('/secured', attAuth.secure(), function (req, res) {
    res.send(req.session.user);
});

app.get('/other-secured', attAuth.secure(), function (req, res) {
    res.send(req.session.user);
});

app.listen(3000);
console.log('Demo AT&T auth app running on port 3000');

Current Tags

  • 0.0.4                                ...           latest (8 years ago)

4 Versions

  • 0.0.4                                ...           8 years ago
  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 4
Dependencies (0)
None
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |