node-slack-events-api icon indicating copy to clipboard operation
node-slack-events-api copied to clipboard

Slack Node SDK signing verification issue in Proxy environment

Open JanmejayPattanaik opened this issue 7 years ago • 1 comments

Description

Hi Team, I am building an APP using Node Slack SDK. I am able to authenticate the user by using auth.test URL and also able to post start up message using im.open or chat.postMessage in the slack.

However, in Proxy environment, I am getting the following error. I am not getting the error message in the no-Proxy setup.

{ Error: Slack request signing verification failed
   at verifyRequestSignature (/opt/app-root/src/node_modules/@slack/events-api/dist/http-handler.js:84:18)
   at /opt/app-root/src/node_modules/@slack/events-api/dist/http-handler.js:189:11
   at <anonymous>
   at process._tickCallback (internal/process/next_tick.js:189:7)
 code: 'SLACKHTTPHANDLER_REQUEST_SIGNATURE_VERIFICATION_FAILURE' } 

Slack package details :

"@slack/client": "^4.8.0", "@slack/events-api": "^2.1.1", "@slack/interactive-messages": "^1.0.2",

Sample Code:

const { WebClient } = require('@slack/client');
const axios = require('axios');
const r = require('request');
const HttpsProxyAgent = require('https-proxy-agent');
const proxyUrl = `${process.env.proxyUrl}:${process.env.proxyPort}`;
var request = r.defaults({'proxy': proxyUrl});

 web: new WebClient(process.env.SLACK_BOT_TOKEN, { agent: new HttpsProxyAgent(proxyUrl) }),

getAuthorizedUser() {
    const AuthStr = 'Bearer '.concat(process.env.SLACK_CLIENT_TOKEN);
    let options  = {
      url:'https://slack.com/api/auth.test?token='+process.env.SLACK_CLIENT_TOKEN,
      headers:{
        'Content-Type':'application/json',
        'Authorization': AuthStr
      },
      json: true
    }

    var context = this;
    request.get(options, function(err, res, body) {  
        if(err){
          console.log("error in code ::: ", err);
        }        
    })
    .on('data', function(data) {
      var locData = JSON.parse(Buffer.from(data).toString());
      context.approver_user_id = locData.user_id;
      context.decisionseeker = locData.user_id;
      context.adminUser();
    })
}

adminUser() {
    var text = `Welcome to app! I'm here to help your team`;
    
    this.web.im.open({user:this.approver_user_id})
      .then((res) => {
        this.web.chat.postMessage({channel:res.channel.id, text, as_user: true, parse: 'full'})}
      )
      .catch((err) => {
        console.log("admin user error code ::: ", err);
      });
  },

As per the Version 4 guide i am using SLACK_SIGNING_SECRET.

What type of issue is this? (place an x in one of the [ ])

  • [ ] bug
  • [ ] enhancement (feature request)
  • [x ] question
  • [ ] documentation related
  • [x ] testing related
  • [x ] discussion

Requirements (place an x in each of the [ ])

  • [x ] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x ] I've read and agree to the Code of Conduct.
  • [x ] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

@slack/events-api version: 4.8.0 node version:8.9.4 OS version(s): Windows 10

Steps to reproduce:

1. 2. 3.

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

JanmejayPattanaik avatar Jan 15 '19 13:01 JanmejayPattanaik

Please don’t create duplicate issues. https://github.com/slackapi/node-slack-interactive-messages/issues/80

aoberoi avatar Jan 15 '19 16:01 aoberoi