Skip to content

Commit

Permalink
Revert "Testing a new slack module for more flexible scopes"
Browse files Browse the repository at this point in the history
This reverts commit edd516a.
  • Loading branch information
avoidwork committed Aug 18, 2017
1 parent 1b35756 commit 6d33353
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 54 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ OAuth2 authentication will create `/auth`, `/auth/oauth2`, & `/auth/oauth2/callb
```

### Slack
Slack authentication will create `/auth`, `/auth/slack`, & `/auth/slack/callback` routes. `auth(accessToken, scopes, team, { bot, incomingWebhook }, { user: userProfile , team: teamProfile }, callback)` must execute `callback(err, user)`. Default scopes are `["identity.basic", "identity.email", "identity.team", "identity.avatar"]`.
Slack authentication will create `/auth`, `/auth/slack`, & `/auth/slack/callback` routes. `auth(accessToken, refreshToken, profile, callback)` must execute `callback(err, user)`.

```
{
Expand All @@ -270,6 +270,7 @@ Slack authentication will create `/auth`, `/auth/slack`, & `/auth/slack/callback
"client_id": "", /* Get this from Slack */
"client_secret": "", /* Get this from Slack */
"scope": [], /* Custom scopes */
"skipUserProfile": false /* Gets User profile if false, requires identity scope */
},
"protect": ["/private"]
}
Expand Down
15 changes: 5 additions & 10 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const path = require("path"),
LocalStrategy = require("passport-local").Strategy,
OAuth2Strategy = require("passport-oauth2").Strategy,
SAMLStrategy = require("passport-saml").Strategy,
SlackStrategy = require("@aoberoi/passport-slack").default.Strategy,
SlackStrategy = require("passport-slack").Strategy,
TwitterStrategy = require("passport-twitter").Strategy,
RedisStore = require("connect-redis")(session),
all = "all";
Expand Down Expand Up @@ -507,7 +507,9 @@ function auth (obj, config) {
if (config.auth.slack.enabled) {
passport.use(new SlackStrategy({
clientID: config.auth.slack.client_id,
clientSecret: config.auth.slack.client_secret
clientSecret: config.auth.slack.client_secret,
scope: config.auth.slack.scope.length > 0 ? config.auth.slack.scope : void 0,
skipUserProfile: config.auth.slack.skipUserProfile !== void 0 ? config.auth.slack.skipUserProfile : void 0
}, (accessToken, refreshToken, profile, done) => {
delay(() => {
config.auth.slack.auth(accessToken, refreshToken, profile, (err, user) => {
Expand All @@ -521,14 +523,7 @@ function auth (obj, config) {
}));

obj.get("/auth/slack", middleware.asyncFlag);
obj.get("/auth/slack", passport.authenticate("slack", {
scope: ["identity.basic", "identity.email", "identity.team", "identity.avatar"]
}));

if (config.auth.slack.scope.length > 0) {
obj.get("/auth/slack", passport.authenticate("slack", {scope: config.auth.slack.scope}));
}

obj.get("/auth/slack", passport.authenticate("slack"));
obj.get("/auth/slack/callback", middleware.asyncFlag);
obj.get("/auth/slack/callback", passport.authenticate("slack", {failureRedirect: "/login"}));
obj.get("/auth/slack/callback", redirect);
Expand Down
80 changes: 39 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tensō is an elastic REST API gateway for node.js",
"version": "5.1.9",
"version": "5.1.8",
"homepage": "http://avoidwork.github.io/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand All @@ -21,7 +21,6 @@
"test": "grunt test"
},
"dependencies": {
"@aoberoi/passport-slack": "^1.0.5",
"coap": "~0.21.0",
"connect-redis": "~3.3.0",
"cookie-parser": "~1.4.3",
Expand All @@ -40,6 +39,7 @@
"passport-local": "~1.0.0",
"passport-oauth2": "~1.3.0",
"passport-saml": "~0.15.0",
"passport-slack": "0.0.7",
"passport-twitter": "~1.0.4",
"precise": "^1.1.0",
"retsu": "~2.0.3",
Expand Down

0 comments on commit 6d33353

Please sign in to comment.