openstf / stf

Control and manage Android devices from your browser.

Home Page:https://openstf.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mock auth response ForbiddenError: invalid csrf token

qiuhuilu opened this issue · comments

image

I deploy use docker,and when i login it returns csrf invalid error,The request like image。
run command is stf auth-mock --app-url http://${STF_HOST}/ --port 3101
thx for help

Hi I'am facing the same issue

ForbiddenError: invalid csrf token
at csrf (/app/node_modules/csurf/index.js:112:19)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/app/node_modules/express/lib/router/index.js:317:13)
at /app/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/app/node_modules/express/lib/router/index.js:335:12)
at next (/app/node_modules/express/lib/router/index.js:275:10)
at /app/node_modules/body-parser/lib/read.js:130:5
at invokeCallback (/app/node_modules/raw-body/index.js:224:16)
at done (/app/node_modules/raw-body/index.js:213:7)
at IncomingMessage.onEnd (/app/node_modules/raw-body/index.js:273:7)
at emitNone (events.js:106:13)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

put a if condition to check of the jwt token exsist

app.get("/auth/logout/:sid", function (req, res) {
    if(req.params.sid !='' && req.params.sid != undefined && req.params.sid != 'undefined' ){
    const jwt_decode = require("jwt-decode");
    var token = "e." + req.params.sid + ".S";
    var decoded = jwt_decode(token);
    var log = logger.createLogger("auth-mock");
    log.info("Logout Successful", decoded.jwt.name);
    res.render("index");
    }else{
      res.render("index");
    }
  });