Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: bnoguchi/everyauth
...
head fork: iwillwen/everyauth
compare: master
Checking mergeability… Don’t worry, you can still create the pull request.
  • 17 commits
  • 9 files changed
  • 0 commit comments
  • 7 contributors
View
55 README.md
@@ -52,12 +52,15 @@ So far, `everyauth` enables you to login via:
<td> <a href="http://github.com/wnadeau">Winfred Nadeau</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>
</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>
</tbody>
</table>
@@ -794,7 +797,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 +1068,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
@@ -2195,6 +2198,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 +2378,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
6 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'
}
View
3,091 example/npm-debug.log
3,091 additions, 0 deletions not shown
View
11 example/server.js
@@ -51,6 +51,7 @@ var usersBySoundCloudId = {};
var usersByMailchimpId = {};
var usersMailruId = {};
var usersByMendeleyId = {};
+var usersByDcId = {};
var usersByLogin = {
'brian@example.com': addUser({ login: 'brian@example.com', password: 'password'})
};
@@ -59,7 +60,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')
View
4 example/views/home.jade
@@ -91,6 +91,8 @@
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
- else
h2 Authenticated
- if (everyauth.facebook)
@@ -177,5 +179,7 @@
- if (everyauth.mendeley)
h3 Mendeley User Data
p= JSON.stringify(everyauth.mendeley.user)
+ - if (everyauth['dailycred'])
+ p= JSON.stringify(everyauth.dailycred.user.email)
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/api/token.json')
+ .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() + '/oauth/api/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
26 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,30 +21,10 @@ 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;
- })
- .moduleErrback( function (err, seqValues) {
- if (err instanceof Error) {
- var next = seqValues.next;
- return next(err);
- } else if (err.extra) {
- var ghResponse = err.extra.res
- , serverResponse = seqValues.res;
- serverResponse.writeHead(
- ghResponse.statusCode
- , ghResponse.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
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
BIN  media/smarterer.ico
Binary file not shown

No commit comments for this range

Something went wrong with that request. Please try again.