Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Forcing of approval prompt, not user friendly. #324

Open
wants to merge 60 commits into from
@sharonjl

Forcing of approval prompt, not user friendly.

Removed:
access_type
approval_prompt

bigokro and others added some commits
@bigokro bigokro Added facebook canvas steps cb811cd
@bigokro bigokro Added tarball for use with npm b1c9dd4
@bigokro bigokro Tarball wasn't zipped c8926df
@bigokro bigokro Added Fecebook canvas support via new step sequences 498c57c
@bigokro bigokro Updated tarball with latest version 9d4d2d3
@bigokro bigokro Minor cleanup work 4aa9a6b
@bigokro bigokro Moved Facebook Canvas into separate submodule. Did all TODOs. 3f43659
@bigokro bigokro Updated tarball d943210
@bigokro bigokro Minor update to README 7bc2895
@philippkueng philippkueng fix for issue #244 where the tumblr module is returning an undefined …
…user when there are multiple tumblelogs associated to the account.
491f836
@jonathana jonathana Added Meetup OAuth2 support c9098d5
@jonathana jonathana Meetup OAuth2 support added. Docs update. 3a6dfe5
gkr corrected a typo in readme code sample 61e9558
@jonathana jonathana cleaned up a variable name that did not get fixed when copying over t…
…he existing module to make this one
0d241f2
@kaizenpack kaizenpack added smarterer oauth 0b504c9
@akinsella akinsella Add support for RunKeeper HealthGraph API 25d4ae4
@akinsella akinsella Runkeeper documentation Update 950559d
@cortfr cortfr Fix for 'this.redirect is missing' in openid 5375cf4
@cortfr cortfr Added yahoohybrid bd56ab3
@ebaizel ebaizel password was not being deleted. be51e02
@jacksonp jacksonp Changed example scope for Google OAuth2 to one that works. 40ef8aa
@bnoguchi Merge pull request #280 from jacksonp/master
Readme Fix for Google OAuth2
545751c
@bnoguchi Merge pull request #275 from ebaizel/patch-2
password was not being deleted.
fd7d567
@kaizenpack kaizenpack Merge branch 'master' of https://github.com/bnoguchi/everyauth 1b986b6
@kaizenpack kaizenpack added smarterer to README 9794626
@kaizenpack kaizenpack added full detail section ae046f3
@kaizenpack kaizenpack fixed indentation issue f792d7a
@hostalerye hostalerye Now using Github api v3 be7c423
@bnoguchi Merge pull request #281 from kaizenpack/master
include smarterer oauth
784547f
@bnoguchi Merge pull request #282 from hostalerye/master
Changed github apiHost url and fetchOAuthUser to work with github api v3
9f2c438
@cortfr cortfr Added proper AttributeExchange name for yahoohybrid 31063ba
@blakmatrix blakmatrix [fix] Changed require('sys') to require('util') for compatibility wit…
…h node v0.8
8aa92a4
@sstrigler sstrigler gracefully detect and handle when user declines authorization 46ca603
@hstove hstove added dailycred fafc486
@hstove hstove ready for push 66fc876
@hstove hstove added dailycred to providers, finished touches 7ce6393
@bnoguchi Merge pull request #302 from hstove/master
added provider for dailycred.com
dee15f4
@justan justan added sina weibo to providers 20d643b
@LuukvE LuukvE Spotted bug in the example code; saving a vimeo user a8f4961
@hstove hstove fixed broken links e545e24
@bnoguchi Merge pull request #316 from hstove/master
Fixed broken links
dc4a591
@bnoguchi Merge pull request #314 from LuukvE/master
Fixed bug in the example code; saving a vimeo user
c5ee5fe
@bnoguchi Merge pull request #311 from justan/master
Added provider for weibo.com
8c11710
@bnoguchi Merge branch 'master' of https://github.com/akinsella/everyauth into …
…akinsella-master

Conflicts:
	README.md
	example/conf.js
	example/server.js
	example/views/home.jade
c9c8da4
@bnoguchi 0.2.33 c6471ba
@bnoguchi Merge pull request #288 from node-migrator-bot/clean
Hi! I fixed some calls to "sys" for you!
5b20c19
@bnoguchi Merge pull request #264 from gkrcode/master
corrected a typo in readme code sample
772e7c0
@bnoguchi Merge branch 'meetup_oauth2' of https://github.com/jonathana/everyauth
…into jonathana-meetup_oauth2

Conflicts:
	example/conf.js
	example/server.js
	example/views/home.jade
31fa26e
@bnoguchi Merge branch 'master' of github.com:bnoguchi/everyauth d560187
@bnoguchi Merge pull request #272 from cortfr/yahoohybrid
Added yahoohybrid
bf495f7
@bnoguchi Merge pull request #261 from philippkueng/patch-1
fix for issue #244 where the tumblr module is returning an undefined user when there are multiple tumblelogs associated to the account.
1409241
@bnoguchi Merge pull request #247 from bigokro/master
Rudimentary support for the Facebook Canvas
89d4e83
@bnoguchi Rm tarball 61ccea8
@bnoguchi Merge pull request #290 from sstrigler/master
fix for #289
e06116f
@bnoguchi Add instructions for installing the express3 version of everyauth. (C…
…loses GH-274)
e04500d
@bnoguchi Merge branch 'master' of github.com:bnoguchi/everyauth f481674
@bnoguchi Remove duplicate Mendeley item in README a667fd8
@bnoguchi 0.2.34 d9d9a80
@Raynos

This silently broke my code. If your going to breaking changes bump the minor version

@bnoguchi
Owner

Sorry about that. I unpublished back to 0.2.32. All new changes since then are now in a newly published 0.3.0.

@sharonjl sharonjl Forcing of approval prompt, not user friendly.
Forcing of approval prompt, not user friendly.

Removed:
access_type
approval_prompt
bc35383
@fabriziomoscon

Hi @bnoguchi,
this is an awesome library. I can see you are very busy keeping all the pull requests sorted and therefore I don't blame you of forgetting stuff, but I might just mention that most probably the README.md should also contain these code snippets
#303
when it comes to the instructions to help install on express3? Am I right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 21, 2012
  1. @bigokro

    Added facebook canvas steps

    bigokro authored
  2. @bigokro

    Added tarball for use with npm

    bigokro authored
  3. @bigokro

    Tarball wasn't zipped

    bigokro authored
  4. @bigokro
  5. @bigokro
  6. @bigokro

    Minor cleanup work

    bigokro authored
Commits on Apr 28, 2012
  1. @bigokro
  2. @bigokro

    Updated tarball

    bigokro authored
Commits on Apr 29, 2012
  1. @bigokro

    Minor update to README

    bigokro authored
Commits on May 11, 2012
  1. @philippkueng

    fix for issue #244 where the tumblr module is returning an undefined …

    philippkueng authored
    …user when there are multiple tumblelogs associated to the account.
Commits on May 17, 2012
  1. @jonathana

    Added Meetup OAuth2 support

    jonathana authored
  2. @jonathana
Commits on May 19, 2012
  1. corrected a typo in readme code sample

    gkr authored
Commits on May 23, 2012
  1. @jonathana

    cleaned up a variable name that did not get fixed when copying over t…

    jonathana authored
    …he existing module to make this one
Commits on May 24, 2012
  1. @kaizenpack

    added smarterer oauth

    kaizenpack authored
Commits on May 26, 2012
  1. @akinsella
  2. @akinsella
Commits on May 31, 2012
  1. @cortfr
  2. @cortfr

    Added yahoohybrid

    cortfr authored
Commits on Jun 6, 2012
  1. @ebaizel
Commits on Jun 10, 2012
  1. @jacksonp
Commits on Jun 11, 2012
  1. Merge pull request #280 from jacksonp/master

    authored
    Readme Fix for Google OAuth2
  2. Merge pull request #275 from ebaizel/patch-2

    authored
    password was not being deleted.
Commits on Jun 12, 2012
  1. @kaizenpack
Commits on Jun 13, 2012
  1. @kaizenpack

    added smarterer to README

    kaizenpack authored
  2. @kaizenpack

    added full detail section

    kaizenpack authored
  3. @kaizenpack

    fixed indentation issue

    kaizenpack authored
  4. @hostalerye

    Now using Github api v3

    hostalerye authored
  5. Merge pull request #281 from kaizenpack/master

    authored
    include smarterer oauth
  6. Merge pull request #282 from hostalerye/master

    authored
    Changed github apiHost url and fetchOAuthUser to work with github api v3
  7. @cortfr
Commits on Jun 23, 2012
  1. @blakmatrix
Commits on Jun 25, 2012
  1. @sstrigler
Commits on Jul 9, 2012
  1. @hstove

    added dailycred

    hstove authored
Commits on Jul 14, 2012
  1. @hstove

    ready for push

    hstove authored
  2. @hstove
  3. Merge pull request #302 from hstove/master

    authored
    added provider for dailycred.com
Commits on Jul 23, 2012
  1. @justan

    added sina weibo to providers

    justan authored
Commits on Jul 28, 2012
  1. @LuukvE
Commits on Aug 3, 2012
  1. @hstove

    fixed broken links

    hstove authored
Commits on Aug 8, 2012
  1. Merge pull request #316 from hstove/master

    authored
    Fixed broken links
  2. Merge pull request #314 from LuukvE/master

    authored
    Fixed bug in the example code; saving a vimeo user
  3. Merge pull request #311 from justan/master

    authored
    Added provider for weibo.com
  4. Merge branch 'master' of https://github.com/akinsella/everyauth into …

    authored
    …akinsella-master
    
    Conflicts:
    	README.md
    	example/conf.js
    	example/server.js
    	example/views/home.jade
  5. 0.2.33

    authored
  6. Merge pull request #288 from node-migrator-bot/clean

    authored
    Hi! I fixed some calls to "sys" for you!
  7. Merge pull request #264 from gkrcode/master

    authored
    corrected a typo in readme code sample
  8. Merge branch 'meetup_oauth2' of https://github.com/jonathana/everyauth

    authored
    …into jonathana-meetup_oauth2
    
    Conflicts:
    	example/conf.js
    	example/server.js
    	example/views/home.jade
  9. Merge pull request #272 from cortfr/yahoohybrid

    authored
    Added yahoohybrid
  10. Merge pull request #261 from philippkueng/patch-1

    authored
    fix for issue #244 where the tumblr module is returning an undefined user when there are multiple tumblelogs associated to the account.
  11. Merge pull request #247 from bigokro/master

    authored
    Rudimentary support for the Facebook Canvas
  12. Rm tarball

    authored
  13. 0.2.34

    authored
  14. 0.3.0

    authored
Commits on Aug 12, 2012
  1. @sharonjl

    Forcing of approval prompt, not user friendly.

    sharonjl authored
    Forcing of approval prompt, not user friendly.
    
    Removed:
    access_type
    approval_prompt
This page is out of date. Refresh to see the latest.
View
2  .gitignore
@@ -5,3 +5,5 @@ issues
IRC.md
playground.js
CHANGES
+npm-debug.log
+.idea
View
118 README.md
@@ -50,14 +50,22 @@ So far, `everyauth` enables you to login via:
<td> <a href="https://github.com/ufssf">ufssf</a>
<tr> <td> <img src="http://static.mailchimp.com/www/downloads/brand-assets/Freddie_Light_Background.png" style="vertical-align:middle" width="16px"> Mailchimp
<td> <a href="http://github.com/wnadeau">Winfred Nadeau</a>
+ <tr> <td> <img src="http://github.com/bnoguchi/everyauth/raw/master/media/meetup.ico" style="vertical-align:middle"> Meetup
+ <td> <a href="http://github.com/jonathana">Jonathan Altman</a>
<tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/mendeley.ico" style="vertical-align:middle"> Mendeley
<td> <a href="https://github.com/edy-b">Eduard Baun</a>
+ <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/smarterer.ico" style="vertical-align:middle"> Smarterer
+ <td> <a href="https://github.com/kaizenpack">kaizenpack</a>
+ <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/runkeeper.ico" style="vertical-align:middle"> RunKeeper
+ <td> <a href="https://github.com/akinsella">Alexis Kinsella</a>
</tbody>
<tbody id=misc>
<tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/box.ico" style="vertical-align:middle"> Box.net <td>
<tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/openid.ico" style="vertical-align:middle" width="16px" height="16px"> OpenId <td> <a href="https://github.com/rocketlabsdev">RocketLabs Development</a>, <a href="https://github.com/starfishmod">Andrew Mee, <a href="https://github.com/bnoguchi">Brian Noguchi</a>
<tr> <td> LDAP (experimental; not production-tested) <td>
<tr> <td> Windows Azure Access Control Service (ACS)<td> <a href="https://github.com/darrenzully">Dario Renzulli</a>, <a href="https://github.com/jpgarcia">Juan Pablo Garcia</a>, <a href="https://github.com/woloski">Matias Woloski</a> from <a href="http://blogs.southworks.net/">Southworks</a>
+ <tr><td><img src='https://www.dailycred.com/public/img/favicon.ico' style="vertical-align:middle">Dailycred <td> <a href='https://github.com/hstove'>Hank Stoever</a> at <a href='https://dailycred.com'>Dailycred.com</a>
+ <tr><td><img src='http://www.sinaimg.cn/blog/developer/wiki/LOGO_16x16.png' style="vertical-align:middle">Sina Weibo<td> <a href='https://github.com/justan'>justan</a>
</tbody>
</table>
@@ -76,8 +84,15 @@ So far, `everyauth` enables you to login via:
## Installation
+
+If you are using Connect 1.x or Express 2.x, install via:
+
$ npm install everyauth
+If you are using Express 3.x, install via:
+
+ $ npm install git://github.com/bnoguchi/everyauth.git#express3
+
## Quick Start
Using everyauth comes down to just 2 simple steps if using Connect
or 3 simple steps if using Express:
@@ -445,6 +460,28 @@ everyauth.facebook
// rest of configuration
```
+### Facebook Canvas Pages
+For apps that can be embedded in Facebook via the canvas page, you can use the
+facebookCanvas submodule:
+
+```javascript
+everyauth.facebookCanvas
+ .canvasPath('CANVAS URL MINUS HOSTNAME') // Default is '/auth/facebook/canvas'
+ .canvasPage('CANVAS PAGE'); // Generally http://apps.facebook.com/APP-NAME
+```
+
+Note that you must also configure the usual Facebook configurations described
+above in order for this to work.
+
+You can tell if the user logged in via the canvas interface using the following test:
+
+```javascript
+if (everyauth.facebookCanvas) {
+ // Do something different
+}
+```
+
+
## Twitter OAuth
```javascript
@@ -794,7 +831,7 @@ everyauth.password
var promise = this.Promise()
, password = newUserAttrs.password;
- delete newUserAttrs[password]; // Don't store password
+ delete newUserAttrs.password; // Don't store password
newUserAttrs.salt = bcrypt.genSaltSync(10);
newUserAttrs.hash = bcrypt.hashSync(password, salt);
@@ -1065,10 +1102,10 @@ var everyauth = require('everyauth')
everyauth.google
.appId('YOUR CLIENT ID HERE')
.appSecret('YOUR CLIENT SECRET HERE')
- .scope('https://www.google.com/m8/feeds') // What you want access to
+ .scope('https://www.googleapis.com/auth/userinfo.profile') // What you want access to
.handleAuthCallbackError( function (req, res) {
// If a user denies your app, Google will redirect the user to
- // /auth/facebook/callback?error=access_denied
+ // /auth/google/callback?error=access_denied
// This configurable route handler defines how you want to respond to
// that.
// If you do not configure this, everyauth renders a default fallback
@@ -2112,6 +2149,35 @@ connect(
).listen(3000);
```
+### RunKeeper OAuth (2.0)
+
+You will first need to [register your application](http://runkeeper.com/partner/applications) to get the appId and appSecret.
+
+```javascript
+everyauth.runkeeper
+ .appId('YOUR CONSUMER KEY HERE')
+ .consumerSecret('YOUR CONSUMER SECRET HERE')
+ .findOrCreateUser( function (sess, accessToken, accessSecret, user) {
+ // find or create user logic goes here
+ //
+ // e.g.,
+ // return usersByRunKeeperId[user.userID] || (usersByRunKeeperId[user.userID] = user);
+ })
+ .redirectPath('/');
+
+var routes = function (app) {
+ // Define your routes here
+};
+
+connect(
+ connect.bodyParser()
+ , connect.cookieParser()
+ , connect.session({secret: 'whodunnit'})
+ , everyauth.middleware()
+ , connect.router(routes);
+).listen(3000);
+```
+
### OpenID protocol
OpenID protocol allows you to use an openid auth request. You can read more information about it here http://openid.net/
@@ -2195,6 +2261,40 @@ connect(
).listen(3000);
```
+### Smarterer
+
+You will need to register for an app id [here](http://www.smarterer.com/). Implementation details follow the same pattern as with other
+oauth2 implementations.
+
+```javascript
+
+var everyauth = require('everyauth')
+ , connect = require('connect');
+
+everyauth.smarterer
+ .appId('YOUR APP ID')
+ .appSecret('YOUR APP SECRET')
+ .findOrCreateUser(function(session, accessToken, accessTokenSecret, userData) {
+ // find or create user logic goes here
+ // userData.userName will contain the smarterer username for the authenticated user
+ // userData.badges will contain the scores on quizes
+ })
+ .redirectPath('/');
+
+var routes = function (app) {
+ // Define your routes here
+};
+
+connect(
+ connect.bodyParser()
+ , connect.cookieParser()
+ , connect.session({secret: 'whodunnit'})
+ , everyauth.middleware()
+ , connect.router(routes);
+).listen(3000);
+```
+
+
### Box.net
```javascript
@@ -2341,6 +2441,18 @@ object whose parameter name keys map to description values:
everyauth.box.configurable();
```
+### Dailycred OAuth
+
+```javascript
+everyauth.dailycred
+ .appId(conf.dc.appId)
+ .findOrCreateUser( function (session, accessToken, accessTokenExtra, dcUserMetadata) {
+ return usersByDcId[dcUserMetadata.id] ||
+ (usersByDcId[dcUserMetadata.id] = addUser('dailycred', dcUserMetadata));
+ })
+ .redirectPath('/');
+```
+
## Configuring a Module
everyauth was built with powerful configuration needs in mind.
View
17 example/conf.js
@@ -1,5 +1,9 @@
module.exports = {
- fb: {
+ dc: {
+ appId: '7ab1a53d-9d0e-4eeb-af62-76a5e1a83af9',
+ appSecret: '88bee747-c1ef-4851-be60-84d53dd474ad-88495db2-5db0-47c8-ad77-9e92db7e308c',
+ }
+ , fb: {
appId: '111565172259433'
, appSecret: '85f7e0a0cc804886180b887c1f04a3c1'
}
@@ -116,4 +120,15 @@ module.exports = {
consumerKey: 'Enter your consumer key here'
, consumerSecret: 'Enter your consumer secret here'
}
+ , weibo: {
+ appId: '3350967939'
+ , appSecret: 'ef7f0a836d0ef315dca53e8d73816cc0'
+ }
+ , runkeeper: {
+ appId: 'Enter your client/app id here'
+ , appSecret: 'Enter your client/app secret here'
+ , meetup: {
+ appId: 'nurgg46uqquq3eqa957ivnddv9'
+ , appSecret: '6spfeab72gc8f89l735i391rr3'
+ }
};
View
3,091 example/npm-debug.log
3,091 additions, 0 deletions not shown
View
42 example/server.js
@@ -51,6 +51,10 @@ var usersBySoundCloudId = {};
var usersByMailchimpId = {};
var usersMailruId = {};
var usersByMendeleyId = {};
+var usersByDcId = {};
+var usersByWeiboId = {};
+var usersByRunKeeperId = {};
+var usersByMeetupId = {};
var usersByLogin = {
'brian@example.com': addUser({ login: 'brian@example.com', password: 'password'})
};
@@ -59,7 +63,15 @@ everyauth.everymodule
.findUserById( function (id, callback) {
callback(null, usersById[id]);
});
-
+
+everyauth.dailycred
+ .appId(conf.dc.appId)
+ .findOrCreateUser( function (session, accessToken, accessTokenExtra, dcUserMetadata) {
+ return usersByDcId[dcUserMetadata.id] ||
+ (usersByDcId[dcUserMetadata.id] = addUser('dailycred', dcUserMetadata));
+ })
+ .redirectPath('/');
+
everyauth.azureacs
.identityProviderUrl('https://acssample1.accesscontrol.windows.net/v2/wsfederation/')
.entryPath('/auth/azureacs')
@@ -271,7 +283,7 @@ everyauth.vimeo
.consumerSecret(conf.vimeo.consumerSecret)
.findOrCreateUser( function (sess, accessToken, accessSecret, vimeoUser) {
return usersByVimeoId[vimeoUser.id] ||
- (usersByVimeoId[vimeoUser.id] = vimeoUser);
+ (usersByVimeoId[vimeoUser.id] = addUser('vimeo', vimeoUser));
})
.redirectPath('/')
@@ -379,6 +391,14 @@ everyauth.mendeley
})
.redirectPath('/');
+everyauth.runkeeper
+ .appId(conf.runkeeper.appId)
+ .appSecret(conf.runkeeper.appSecret)
+ .findOrCreateUser(function(sess, accessToken, accessSecret, user) {
+ return usersByRunKeeperId[user.userID] || (usersByRunKeeperId[user.userID] = addUser('runkeeper', user));
+ })
+ .redirectPath('/');
+
everyauth
.soundcloud
.appId(conf.soundcloud.appId)
@@ -410,6 +430,24 @@ everyauth
(usersByMailchimpId[mailchimpUser.user_id] = addUser('mailchimp', mailchimpUser));
})
.redirectPath("/");
+
+everyauth
+ .weibo
+ .appId(conf.weibo.appId)
+ .appSecret(conf.weibo.appSecret)
+ .findOrCreateUser( function (session, accessToken, accessTokenExtra, weiboUser){
+ return usersByWeiboId[weiboUser.uid] ||
+ (usersByWeiboId[weiboUser.uid] = addUser('weibo', weiboUser));
+ })
+ .redirectPath("/");
+
+everyauth.meetup
+ .appId(conf.meetup.appId)
+ .appSecret(conf.meetup.appSecret)
+ .findOrCreateUser(function(sess, accessToken, accessSecret, user) {
+ return usersByMeetupId[user.id] || (usersByMeetupId[user.id] = addUser('meetup', user));
+ })
+ .redirectPath('/');
var app = express.createServer(
express.bodyParser()
View
20 example/views/home.jade
@@ -45,6 +45,9 @@
#readability-login
a(href='/auth/readability', style='border: 0px')
img(style='border: 0px', src='https://www.readability.com/media/images/logo_chair.png')
+ #meetup-login
+ a(href='/auth/meetup', style='border: 0px')
+ img(style='border: 0px', src='http://img2.meetupstatic.com/img/header/logo.png')
#dropbox-login
a(href='/auth/dropbox', style='border: 0px')
img(src='https://www.dropbox.com/static/16890/images/logo.png')
@@ -86,11 +89,18 @@
#mendeley-login
a(href='/auth/mendeley', style='border: 0px')
img(src='http://d1rktifm8krpj.cloudfront.net/graphics/commonnew/logo-mendeley_1248201417297118.png', title='Login with Mendeley')
+ #runkeeper-login
+ a(href='/auth/runkeeper', style='border: 0px')
+ img(src='http://d2b4ufapzmnxpw.cloudfront.net/build/3572/static/kronos/images/logo.png', title='Login with Runkeeper')
#openid-login
form#openid(action='/auth/openid')
label(for='openid_identifier') OpenID Identifier: &nbsp;
input(type='text', name='openid_identifier')
input(type='submit') Login
+ #dailycred-login
+ a(href='/auth/dailycred') Login with Dailycred
+ #weibo-login
+ a(href='/auth/weibo') Login with sina weibo
- else
h2 Authenticated
- if (everyauth.facebook)
@@ -177,5 +187,15 @@
- if (everyauth.mendeley)
h3 Mendeley User Data
p= JSON.stringify(everyauth.mendeley.user)
+ - if (everyauth['dailycred'])
+ p= JSON.stringify(everyauth.dailycred.user.email)
+ - if (everyauth['weibo'])
+ p= JSON.stringify(everyauth.weibo.user)
+ - if (everyauth.runkeeper)
+ h3 Runkeeper User Data
+ p= JSON.stringify(everyauth.runkeeper.user)
+ - if (everyauth.meetup)
+ h3 Meetup User Data
+ p= JSON.stringify(everyauth.meetup.user)
h3
a(href='/logout') Logout
View
61 lib/modules/dailycred.js
@@ -0,0 +1,61 @@
+var oauthModule = require('./oauth2')
+ , url = require('url');
+
+var dc = module.exports =
+oauthModule.submodule('dailycred')
+
+ .apiHost('https://www.dailycred.com')
+ .oauthHost('https://www.dailycred.com')
+
+ .authPath('https://www.dailycred.com/oauth/authorize')
+ .accessTokenPath('/oauth/access_token')
+ .entryPath('/auth/dailycred')
+ .callbackPath('/auth/dailycred/callback')
+
+ .authCallbackDidErr( function (req) {
+ var parsedUrl = url.parse(req.url, true);
+ return parsedUrl.query && !!parsedUrl.query.error;
+ })
+ .handleAuthCallbackError( function (req, res) {
+ var parsedUrl = url.parse(req.url, true)
+ , errorDesc = parsedUrl.query.error_description;
+ if (res.render) {
+ res.render(__dirname + '/../views/auth-fail.jade', {
+ errorDescription: errorDesc
+ });
+ } else {
+ // TODO Replace this with a nice fallback
+ throw new Error("You must configure handleAuthCallbackError if you are not using express");
+ }
+ })
+
+ .fetchOAuthUser( function (accessToken) {
+ var p = this.Promise();
+ this.oauth.get(this.apiHost() + '/graph/me.json', accessToken, function (err, data) {
+ if (err) return p.fail(err);
+ var oauthUser = JSON.parse(data);
+ p.fulfill(oauthUser);
+ })
+ return p;
+ })
+ .moduleErrback( function (err, seqValues) {
+ if (err instanceof Error) {
+ var next = seqValues.next;
+ return next(err);
+ } else if (err.extra) {
+ var facebookResponse = err.extra.res
+ , serverResponse = seqValues.res;
+ serverResponse.writeHead(
+ facebookResponse.statusCode
+ , facebookResponse.headers);
+ serverResponse.end(err.extra.data);
+ } else if (err.statusCode) {
+ var serverResponse = seqValues.res;
+ serverResponse.writeHead(err.statusCode);
+ serverResponse.end(err.data);
+ } else {
+ console.error(err);
+ throw new Error('Unsupported error type');
+ }
+ });
+
View
76 lib/modules/facebookCanvas.js
@@ -0,0 +1,76 @@
+var facebook = require('./facebook')
+ , crypto = require('crypto');
+
+var fb = module.exports =
+ facebook.submodule("facebookCanvas")
+ .configurable({
+ canvasPage: 'specify the URL configured for your Facebook Canvas Page via https://developers.facebook.com/apps/'
+ })
+ .post('canvasPath',
+ 'the path configured for the Facebook canvas interface ("Canvas URL"), minus the hostname')
+ .step('fetchOAuthUserFromSignedRequest')
+ .description('handles the signed request from Facebook and returns the oauth user')
+ .accepts('req res')
+ .promises('oauthUser accessToken extra')
+ .canBreakTo('authCallbackErrorSteps')
+ .canBreakTo('requestAuthorizationSteps')
+ .step('getSession')
+ .accepts('req')
+ .promises('session')
+ .step('findOrCreateUser')
+ .accepts('session accessToken extra oauthUser')
+ .promises('user')
+ .step('compile')
+ .accepts('accessToken extra oauthUser user')
+ .promises('auth')
+ .step('addToSession')
+ .accepts('session auth')
+ .promises(null)
+ .step('sendResponse')
+ .accepts('res')
+ .promises(null)
+
+ .canvasPath('/auth/facebook/canvas')
+
+ .fetchOAuthUserFromSignedRequest( function (req, res) {
+ var signed_request = req.param('signed_request').split('.');
+ var signature = signed_request[0].replace(/_/g, '/').replace(/-/g, '+');
+ var data = signed_request[1];
+ var decoded = new Buffer(data, 'base64').toString('utf8');
+ var oauthUser = JSON.parse(decoded);
+
+ if (oauthUser.algorithm !== 'HMAC-SHA256') {
+ return this.breakTo('authCallbackErrorSteps', req, res);
+ }
+
+ var calculated = crypto.createHmac('sha256', this._appSecret).update(data).digest('base64');
+ if (calculated != signature+"=") {
+ return this.breakTo('authCallbackErrorSteps', req, res);
+ }
+
+ if (!oauthUser.user_id || oauthUser.user_id === null) {
+ // Need to get authorization first
+ return this.breakTo('requestAuthorizationSteps', req, res);
+ }
+
+ // Dummy values used to satisfy subsequent steps
+ var accessToken = "access_token";
+ var extra = "extra";
+
+ var p = this.Promise();
+ p.fulfill(oauthUser, accessToken, extra);
+ return p;
+ })
+
+ .stepseq('requestAuthorizationSteps')
+ .step('getCanvasAuthUri')
+ .accepts('req res')
+ .promises('authUri')
+ .step('requestAuthUri')
+ .accepts('res authUri')
+ .promises(null)
+
+ .getCanvasAuthUri( function (req, res) {
+ var authUri = "http://www.facebook.com/dialog/oauth?client_id="+ this._appId + "&redirect_uri=" + encodeURI(this._canvasPage);
+ return authUri;
+ });
View
6 lib/modules/github.js
@@ -7,7 +7,7 @@ oauthModule.submodule('github')
})
.oauthHost('https://github.com')
- .apiHost('https://github.com/api/v2/json')
+ .apiHost('https://api.github.com')
.authPath('/login/oauth/authorize')
.accessTokenPath('/login/oauth/access_token')
@@ -21,9 +21,9 @@ oauthModule.submodule('github')
.fetchOAuthUser( function (accessToken) {
var p = this.Promise();
- this.oauth.get(this.apiHost() + '/user/show', accessToken, function (err, data) {
+ this.oauth.get(this.apiHost() + '/user', accessToken, function (err, data) {
if (err) return p.fail(err);
- var oauthUser = JSON.parse(data).user;
+ var oauthUser = JSON.parse(data);
p.fulfill(oauthUser);
})
return p;
View
4 lib/modules/google.js
@@ -23,9 +23,7 @@ oauthModule.submodule('google')
.callbackPath('/auth/google/callback')
.authQueryParam({
- access_type: 'offline'
- , approval_prompt: 'force'
- , scope: function () {
+ scope: function () {
return this._scope && this.scope();
}
})
View
32 lib/modules/meetup.js
@@ -0,0 +1,32 @@
+var oauthModule = require('./oauth2')
+ , querystring= require('querystring');
+
+var meetup = module.exports =
+oauthModule.submodule('meetup')
+
+ .oauthHost('https://secure.meetup.com')
+ .apiHost('https://api.meetup.com/2')
+
+ .entryPath('/auth/meetup')
+ .callbackPath('/auth/meetup/callback')
+
+ .authPath('/oauth2/authorize')
+ .authQueryParam('response_type', 'code')
+
+ .accessTokenHttpMethod('post')
+ .accessTokenPath('/oauth2/access')
+ .postAccessTokenParamsVia('data')
+ .accessTokenParam('grant_type', 'authorization_code')
+
+ .fetchOAuthUser( function (accessToken) {
+ var p = this.Promise();
+ this.oauth.get(this.apiHost() + '/member/self', accessToken, function (err, data) {
+ if (err) return p.fail(err.error_message);
+ var oauthUser = JSON.parse(data);
+ p.fulfill(oauthUser);
+ })
+ return p;
+ })
+ .convertErr( function (data) {
+ return new Error(data.error_message);
+ });
View
3  lib/modules/openid.js
@@ -45,6 +45,7 @@ everyModule.submodule('openid')
.accepts('res')
.promises(null)
.sendToAuthenticationUri(function(req,res) {
+ var that = this;
// Automatic hostname detection + assignment
if (!this._myHostname || this._alwaysDetectHostname) {
@@ -53,7 +54,7 @@ everyModule.submodule('openid')
this.relyingParty.authenticate(req.query[this.openidURLField()], false, function(err,authenticationUrl){
if(err) return p.fail(err);
- this.redirect(res, authenticationUrl);
+ that.redirect(res, authenticationUrl);
});
})
.getSession( function(req) {
View
39 lib/modules/runkeeper.js
@@ -0,0 +1,39 @@
+var oauthModule = require('./oauth2')
+ , request = require('request');
+
+var runkeeper = module.exports =
+oauthModule.submodule('runkeeper')
+ .configurable({
+ scope: 'specify types of access: (no scope), non-expiring'
+ })
+ .apiHost('https://api.runkeeper.com')
+ .oauthHost('https://runkeeper.com')
+ .authPath('/apps/authorize')
+ .accessTokenPath('/apps/token')
+ .entryPath('/auth/runkeeper')
+ .callbackPath('/auth/runkeeper/callback')
+ .authQueryParam('response_type', 'code')
+ .authQueryParam('scope', function () {
+ return this._scope && this.scope();
+ })
+ .accessTokenHttpMethod('post')
+ .postAccessTokenParamsVia('data')
+ .accessTokenParam('grant_type', 'authorization_code')
+ .fetchOAuthUser(function (accessToken) {
+ console.log("Access Token: ", accessToken);
+ var promise = this.Promise();
+ request.get({
+ url: this.apiHost() + '/user'
+ , headers: {
+ 'Authorization': 'Bearer ' + accessToken
+ }
+ }, function (err, res, body) {
+ if (err) return promise.fail(err);
+ if (parseInt(res.statusCode / 100, 10) !== 2) {
+ return promise.fail(body);
+ }
+ return promise.fulfill(JSON.parse(body));
+ });
+
+ return promise;
+ });
View
30 lib/modules/smarterer.js
@@ -0,0 +1,30 @@
+var oauthModule = require('./oauth2')
+ , querystring= require('querystring');
+
+var smarterer = module.exports =
+oauthModule.submodule('smarterer')
+ .oauthHost('https://smarterer.com')
+ .apiHost('https://smarterer.com')
+
+ .entryPath('/auth/smarterer')
+ .callbackPath('/auth/smarterer/callback')
+
+ .authQueryParam('callback_url', function() {
+ return this._myHostname + this._callbackPath;
+ })
+
+ .accessTokenParam('grant_type', 'authorization_code')
+
+
+ .fetchOAuthUser( function (accessToken) {
+ var p = this.Promise();
+ this.oauth.get(this.apiHost() + '/api/badges', accessToken, function (err, data) {
+ if (err) return p.fail(err.error_message);
+ var oauthUser = JSON.parse(data);
+ p.fulfill(oauthUser);
+ })
+ return p;
+ })
+ .convertErr( function (data) {
+ return new Error(data.error_message);
+ });
View
28 lib/modules/tumblr.js
@@ -1,7 +1,8 @@
var oauthModule = require('./oauth')
- , Parser = require('xml2js').Parser;
+ , Parser = require('xml2js').Parser
+ , url = require('url');
-var twitter = module.exports =
+var tumblr = module.exports =
oauthModule.submodule('tumblr')
.apiHost('http://www.tumblr.com/api')
.oauthHost('http://www.tumblr.com')
@@ -14,13 +15,32 @@ oauthModule.submodule('tumblr')
if (err) return promise.fail(err);
var parser = new Parser();
parser.on('end', function (result) {
- var oauthUser = result.tumblelog['@'];
+ var oauthUser;
+ if(result.tumblelog instanceof Array){
+ oauthUser = result.tumblelog[0]['@'];
+ } else {
+ oauthUser = result.tumblelog['@'];
+ }
promise.fulfill(oauthUser);
});
parser.parseString(data);
});
return promise;
})
+ .authCallbackDidErr( function (req) {
+ var parsedUrl = url.parse(req.url, true);
+ return !parsedUrl.query || !parsedUrl.query.oauth_token;
+ })
+ .handleAuthCallbackError( function (req, res) {
+ if (res.render) {
+ res.render(__dirname + '/../views/auth-fail.jade', {
+ errorDescription: 'The user denied your request'
+ });
+ } else {
+ // TODO Replace this with a nice fallback
+ throw new Error("You must configure handleAuthCallbackError if you are not using express");
+ }
+ })
.convertErr( function (data) {
- return data.data;
+ return new Error(data.data);
});
View
74 lib/modules/weibo.js
@@ -0,0 +1,74 @@
+var oauthModule = require('./oauth2')
+ , querystring= require('querystring')
+ , request = require('request');
+
+var weibo = module.exports =
+oauthModule.submodule('weibo')
+ .configurable({
+ scope: "There's no idea about weibo's scope"
+ })
+
+ //fetch weibo user needs userid in extra
+ .step('fetchOAuthUser')
+ .accepts('accessToken extra')
+ .promises('oauthUser')
+
+ .oauthHost('https://api.weibo.com')
+ .apiHost('https://api.weibo.com')
+
+ .authPath('/oauth2/authorize')
+ .authQueryParam('response_type', 'code')
+
+ .accessTokenPath('/oauth2/access_token')
+ .accessTokenParam('grant_type', '')
+ .postAccessTokenParamsVia('data')
+
+ .entryPath('/auth/weibo')
+ .callbackPath('/auth/weibo/callback')
+
+ .authQueryParam('scope', function () {
+ return this._scope && this.scope();
+ })
+
+ .getAccessToken( function (code) {
+ var p = this.Promise()
+ , url = this._oauthHost + this._accessTokenPath
+ , opts = { url: url };
+
+ opts.form = {
+ client_id: this._appId
+ , redirect_uri: this._myHostname + this._callbackPath
+ , code: code
+ , client_secret: this._appSecret
+ };
+
+ request.post( opts, function(err, res, body){
+ var data;
+ if (err) {
+ p.fail(err);
+ } else {
+ data = JSON.parse(body); // sina weibo return a JSON with text/plain
+ p.fulfill(data.access_token, data);
+ delete data.access_token;
+ }
+ });
+ return p;
+ })
+ .fetchOAuthUser( function (accessToken, extra) {
+ var p = this.Promise();
+ var uid = extra.uid;
+ var url = this.apiHost() + "/2/users/show.json?uid=" + uid;
+
+ this.oauth.get(url, accessToken, function (err, user) {
+ if (err) {
+ p.fail(err);
+ }else{
+ p.fulfill(JSON.parse(user));
+ }
+ });
+
+ return p;
+ })
+ .convertErr( function (err) {
+ return new Error(err.data ? err.data : err);
+ });
View
62 lib/modules/yahoohybrid.js
@@ -0,0 +1,62 @@
+var openidModule = require('./openid')
+ , OAuth = require('oauth').OAuth
+ , oid = require('openid')
+ , extractHostname = require('../utils').extractHostname;
+
+var yahoohybrid = module.exports =
+openidModule.submodule('yahoohybrid')
+ .configurable({
+ consumerKey: 'Consumer Key'
+ , consumerSecret: 'Consumer Secret'
+ })
+ .definit( function () {
+ this.relyingParty =
+ new oid.RelyingParty(this._myHostname + this._callbackPath, null, false, false, [
+ new oid.AttributeExchange({
+ 'http://axschema.org/contact/email': 'required'
+ , 'http://axschema.org/namePerson/first': 'required'
+ , 'http://axschema.org/namePerson/last': 'required'
+ , 'http://axschema.org/namePerson': 'required'
+ })
+ , new oid.OAuthHybrid({
+ consumerKey: this._consumerKey
+ })
+ ]);
+
+ this.oauth = new OAuth(
+ "https://api.login.yahoo.com/oauth/v2/get_request_token"
+ , "https://api.login.yahoo.com/oauth/v2/get_token"
+ , this.consumerKey()
+ , this.consumerSecret()
+ , '1.0', null, 'HMAC-SHA1');
+ })
+ .verifyAttributes(function (req,res) {
+ var p = this.Promise()
+ oauth = this.oauth;
+ this.relyingParty.verifyAssertion(req, function (err, userAttributes) {
+ if(err) return p.fail(err);
+ oauth.getOAuthAccessToken(userAttributes['request_token'], undefined, function (err, oauthAccessToken, oauthAccessTokenSecret) {
+ if (err) return p.fail(err);
+ userAttributes['access_token'] = oauthAccessToken;
+ userAttributes['access_token_secret'] = oauthAccessTokenSecret;
+ p.fulfill(userAttributes)
+ });
+ });
+ return p;
+ })
+ .sendToAuthenticationUri(function (req, res) {
+
+ // Automatic hostname detection + assignment
+ if (!this._myHostname || this._alwaysDetectHostname) {
+ this.myHostname(extractHostname(req));
+ }
+
+ var self = this;
+
+ this.relyingParty.authenticate('http://me.yahoo.com', false, function (err,authenticationUrl){
+ if(err) return p.fail(err);
+ self.redirect(res, authenticationUrl);
+ });
+ })
+ .entryPath('/auth/yahoohybrid')
+ .callbackPath('/auth/yahoohybrid/callback');
View
BIN  media/meetup.ico
Binary file not shown
View
BIN  media/runkeeper.ico
Binary file not shown
View
BIN  media/smarterer.ico
Binary file not shown
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "everyauth",
"description": "Auth solution (password, facebook, & more) for your node.js Connect & Express apps",
- "version": "0.2.32",
+ "version": "0.3.0",
"homepage": "https://github.com/bnoguchi/everyauth/",
"repository": {
"type": "git",
View
2  test/util/expect.js
@@ -10,7 +10,7 @@ var expect = require('expect.js');
var Assertion = expect.Assertion
, statusCodes = require('http').STATUS_CODES
, j = function(elem){ return '[jQuery ' + i(elem.selector.replace(/^ *\* */, '')) + ']'; }
- , i = require('sys').inspect;
+ , i = require('util').inspect;
/**
* Number strings.
Something went wrong with that request. Please try again.