123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- var MacaroonsBuilder = require('macaroons.js').MacaroonsBuilder;
- var MacaroonsVerifier = require('macaroons.js').MacaroonsVerifier;
- var express = require('express');
- var app = express();
- var bodyParser = require('body-parser');
-
- var location = "https://ent.brendanabolivier.com";
- var secretKey = "pocsecret";
-
- // parse application/x-www-form-urlencoded
- app.use(bodyParser.urlencoded({ extended: false }));
-
- // parse application/json
- app.use(bodyParser.json());
-
- app.get('/', function(req, res, next) {
- res.sendFile(__dirname + '/form.html');
- });
-
- app.post('/', function(req, res, next) {
- var identifier = req.body.first+';'+req.body.last;
-
- var m = new MacaroonsBuilder(location, secretKey, identifier)
- .add_first_party_caveat("status = student")
- .getMacaroon();
-
- res.cookie('das-macaroon', m.serialize());
-
- res.send('Logged in as ' + req.body.first + ' ' + req.body.last + ' (student)');
- });
-
- app.get('/teacher', function(req, res, next) {
- res.sendFile(__dirname + '/form.html');
- });
-
- app.post('/teacher', function(req, res, next) {
- var identifier = req.body.first+';'+req.body.last;
-
- var m = new MacaroonsBuilder(location, secretKey, identifier)
- .add_first_party_caveat("status = teacher")
- .getMacaroon();
-
- res.cookie('das-macaroon', m.serialize());
-
- res.send('Logged in as ' + req.body.first + ' ' + req.body.last + ' (teacher)');
- });
-
- app.listen(1337, function() {
- console.log('Server started');
- });
|