This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from DmitrySumaroka/master
Auth-proxy to work with passport-drupal and Drupal OAuth authentication strategy
- Loading branch information
Showing
11 changed files
with
125 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
authenticationStrategies: | ||
DrupalOAuth: | ||
providerURL: "http://yourdruplasite.com/" | ||
consumerKey: "YOUR_KEY" | ||
consumerSecret: "YOUR_SECRET" | ||
requestTokenURL: "http://yourdruplasite.com/oauth/request_token" | ||
accessTokenURL: "http://yourdruplasite.com/oauth/access_token" | ||
userAuthorizationURL: "http://yourdruplasite/oauth/authorize" | ||
resourceURL: "http://yourdruplasite/rest/system/connect/user/info" | ||
resourceEndpoint: "rest/system/connect" # <-- thats the default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
authenticationStrategies: | ||
GoogleOAuth2: | ||
# Note this option does not work with `@gmail.com` addresses, you would need to leave it empty. | ||
allowedDomains: | ||
- "howardtyson.com" | ||
allowedDomains: YOUR_DOMAINS | ||
# Note if you leave this empty and populate only the domain everyone in your apps domain will have access. | ||
allowedEmails: | ||
- "howard@howardtyson.com" | ||
allowedEmails: YOUR_EMAILS | ||
googleClientId: CHANGE ME | ||
googleClientSecret: CHAGNE ME | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
DStrategy = require('passport-drupal').DrupalStrategy; | ||
|
||
module.exports = {}; | ||
module.exports.attach = function(passport, app, config, pluginConfig, logger) { | ||
|
||
passport.use(new DStrategy({ | ||
consumerKey: pluginConfig.consumerKey, | ||
consumerSecret: pluginConfig.consumerSecret, | ||
providerURL: pluginConfig.providerURL, | ||
resourceEndpoint: config.resourceEndpoint, // <---- optional. Defaults to `rest/system/connect` | ||
callbackURL: config.host + ":" + config.port + "/auth/drupal/callback", | ||
requestTokenURL: pluginConfig.requestTokenURL, | ||
accessTokenURL: pluginConfig.accessTokenURL, | ||
userAuthorizationURL: pluginConfig.userAuthorizationURL, | ||
resourceURL: pluginConfig.resourceURL | ||
}, | ||
function(token, tokenSecret, profile, done) { | ||
profile.oauth = { token: token, token_secret: tokenSecret }; | ||
done(null, profile); | ||
} | ||
)); | ||
|
||
config.routeWhiteList.push('/auth/drupal'); | ||
config.routeWhiteList.push('/auth/drupal/callback'); | ||
|
||
app.get('/auth/drupal', | ||
passport.authenticate('drupal'), | ||
function(req, res) { | ||
// The request will be redirected to the Drupal website for | ||
// authentication, so this function will not be called. | ||
}); | ||
|
||
app.get('/auth/drupal/callback', | ||
passport.authenticate('drupal', { failureRedirect: config.loginPath }), | ||
function(req, res) { | ||
if (req.session.redirectTo) { | ||
res.redirect(req.session.redirectTo); | ||
|
||
}else{ | ||
res.redirect('/'); | ||
} | ||
}); | ||
|
||
|
||
app.get('/error', function(req, res) { | ||
res.writeHead(200); | ||
res.end("Could not sign in"); | ||
}); | ||
} | ||
module.exports.renderLogin = function() { | ||
return '<a href="/auth/drupal">Login with Drupal</a>'; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
0 info it worked if it ends with ok | ||
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] | ||
2 info using npm@1.4.21 | ||
3 info using node@v0.10.30 | ||
4 verbose node symlink /usr/bin/node | ||
5 verbose run-script [ 'prestart', 'start', 'poststart' ] | ||
6 info prestart auth-proxy@0.0.0 | ||
7 info start auth-proxy@0.0.0 | ||
8 verbose unsafe-perm in lifecycle true | ||
9 info auth-proxy@0.0.0 Failed to exec start script | ||
10 error auth-proxy@0.0.0 start: `bin/auth-proxy` | ||
10 error Exit status 8 | ||
11 error Failed at the auth-proxy@0.0.0 start script. | ||
11 error This is most likely a problem with the auth-proxy package, | ||
11 error not with npm itself. | ||
11 error Tell the author that this fails on your system: | ||
11 error bin/auth-proxy | ||
11 error You can get their info via: | ||
11 error npm owner ls auth-proxy | ||
11 error There is likely additional logging output above. | ||
12 error System Linux 3.8.0-29-generic | ||
13 error command "/usr/bin/node" "/usr/bin/npm" "start" | ||
14 error cwd /var/www/auth-proxy | ||
15 error node -v v0.10.30 | ||
16 error npm -v 1.4.21 | ||
17 error code ELIFECYCLE | ||
18 verbose exit [ 1, true ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters