Skip to content

Commit

Permalink
add openid auth-not working
Browse files Browse the repository at this point in the history
  • Loading branch information
portokallidis committed Feb 3, 2015
1 parent f7801ec commit c7936ce
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 47 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CHANGELOG v0.2.0

- * f7801ec - 2015-02-01: CLI: remove console.log for undefined
- * 7044aec - 2015-02-01: CLI: undefined search term bug fix , duplicate risk element
- * 48bba86 - 2015-02-01: CLI: fix bug created by a double quote and update cli tool not to build script twice
- * 7742311 - 2015-02-01: CLI: add minimum requirements
Expand Down
9 changes: 0 additions & 9 deletions client/app/main/main.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ angular.module('edumaterialApp')
$scope.onComplete=function(item,model,label){
$scope.searchQuery();
};

// $scope.previewPanel='small';
// $scope.togglePanel=function(){
// var height='400px';
// if($scope.previewPanel==='big') height='50px';


// document.querySelector('#document-preview').style.height = height;
// };


//fetch whole article and rate it
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"passport-http": "^0.2.2",
"passport-local": "^0.1.6",
"passport-oauth1": "^1.0.1",
"passport-saml": "^0.8.0",
"passport-openid": "^0.3.1",
"passport-twitter": "latest",
"request": "^2.47.0",
"request-json": "^0.5.0",
Expand Down
56 changes: 53 additions & 3 deletions server/auth/carre/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,64 @@ var auth = require('../auth.service');
var router = express.Router();

router
.get('/', passport.authenticate('carre', {

// Accept the OpenID identifier and redirect the user to their OpenID
// provider for authentication. When complete, the provider will redirect
// the user back to the application at:
// /auth/openid/return

.get('/',passport.authenticate('openid', {
identifier:'https://carre.kmi.open.ac.uk/users/nporto',
failureRedirect: '/signup',
session: false
}))


// The OpenID provider has redirected the user back to the application.
// Finish the authentication process by verifying the assertion. If valid,
// the user will be logged in. Otherwise, authentication has failed.

.get('/callback', passport.authenticate('carre', {
.get('/callback', passport.authenticate('openid', {
failureRedirect: '/signup',
session: false

}), auth.setTokenCookie);

module.exports = router;


module.exports = router;



// app.post('/login/callback',
// passport.authenticate('saml', { failureRedirect: '/', failureFlash: true }),
// function(req, res) {
// res.redirect('/');
// }
// );

// app.get('/login',
// passport.authenticate('saml', { failureRedirect: '/', failureFlash: true }),
// function(req, res) {
// res.redirect('/');
// }
// );



// router
// .get('/', passport.authenticate('google', {
// failureRedirect: '/signup',
// scope: [
// 'https://www.googleapis.com/auth/userinfo.profile',
// 'https://www.googleapis.com/auth/userinfo.email'
// ],
// session: false
// }))

// .get('/callback', passport.authenticate('google', {
// failureRedirect: '/signup',
// session: false
// }), auth.setTokenCookie);

// module.exports = router;
86 changes: 52 additions & 34 deletions server/auth/carre/passport.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
exports.setup = function (User, config) {
var passport = require('passport');
var OAuth1Strategy = require('passport-oauth1').Strategy;

var passport = require('passport')
, OpenIDStrategy = require('passport-openid').Strategy;

passport.use(new OAuth1Strategy({

userAuthorizationURL: config.carre.userAuthorizationURL||'http://google.com',
requestTokenURL: config.carre.requestTokenURL||'http://google.com',
accessTokenURL: config.carre.accessTokenURL||'http://google.com',
consumerKey: config.carre.clientID,
consumerSecret: config.carre.clientSecret,
callbackURL: config.carre.callbackURL
passport.use(new OpenIDStrategy({
providerURL:'http://localhost:3000',
returnURL: 'http://edu.carre-project.eu/auth/carre/callback',
realm: 'http://edu.carre-project.eu/',
profile: true
},
function(token, tokenSecret, profile, done) {
User.findOne({
'carre.id_str': profile.id
}, function(err, user) {
if (err) {
return done(err);
}
if (!user) {
user = new User({
name: profile.displayName,
username: profile.username,
role: 'user',
provider: 'carre',
carre: profile._json
});
user.save(function(err) {
if (err) return done(err);
return done(err, user);
});
} else {
return done(err, user);
}
function(identifier, profile, done) {
User.findOrCreate({ openId: identifier }, function(err, user) {
done(err, user);
});
}
));
}
));


// passport.use(new OAuth1Strategy({

// userAuthorizationURL: config.carre.userAuthorizationURL||'http://google.com',
// requestTokenURL: config.carre.requestTokenURL||'http://google.com',
// accessTokenURL: config.carre.accessTokenURL||'http://google.com',
// consumerKey: config.carre.clientID,
// consumerSecret: config.carre.clientSecret,
// callbackURL: config.carre.callbackURL
// },
// function(token, tokenSecret, profile, done) {
// User.findOne({
// 'carre.id_str': profile.id
// }, function(err, user) {
// if (err) {
// return done(err);
// }
// if (!user) {
// user = new User({
// name: profile.displayName,
// username: profile.username,
// role: 'user',
// provider: 'carre',
// carre: profile._json
// });
// user.save(function(err) {
// if (err) return done(err);
// return done(err, user);
// });
// } else {
// return done(err, user);
// }
// });
// }
// ));



};

0 comments on commit c7936ce

Please sign in to comment.