Giter VIP home page Giter VIP logo

Comments (6)

ottomao avatar ottomao commented on May 18, 2024 1

这个需求可能是需要“对使用AnyProxy的用户做权限控制”。我觉得这个优先级不高。

from anyproxy.

LiuWeiMr avatar LiuWeiMr commented on May 18, 2024 1

Hi @Vbubblery
请问这里面的用户验证是不是指header中的authorization?
如果是header中的信息,目前直接放入header中就可以使用,如果是想在rule中拦截并加入验证信息,应该可以自己对rule进行二次开发,所以可否描述一下用户验证的使用场景?

实现basic author重写了beforeSendRequest 方法:
*beforeSendRequest (requestDetail) {
console.log(requestDetail._req.headers);
if (!requestDetail || !requestDetail._req.headers || !requestDetail._req.headers["Proxy-Authorization"]) {
return {
response: {
statusCode: 407,
header: {
'Proxy-Authenticate': 'Basic'
}
}
};
}
}
该方法http请求可以验证身份,但是HTTPS请求出错了

qq 20181016185422

其中beforeDealHttpsRequest方法如下:
*beforeDealHttpsRequest(requestDetail) {
console.log(requestDetail._req.headers);

        return true;
    },

from anyproxy.

dawoodaijaz97 avatar dawoodaijaz97 commented on May 18, 2024 1

Hi,
this is my code for Basic Auth, I am getting an error message "Send final response failed:Can not read property 'transfer-encoding' of undefined"

can anyone help me with the authentication!!!! pls

  • beforeSendRequest(requestDetail) {

      const Base64 = require('js-base64').Base64;
      if (!requestDetail || !requestDetail._req.headers || !requestDetail._req.headers["Proxy-Authorization"]) {
          
          return {
              response: {
                  statusCode: 407,
                  header: { 'Proxy-Authenticate': 'Basic' }
              }
          };
      } else {
          let auth = requestDetail._req.headers["Proxy-Authorization"];
          auth = auth.split(" ");
          auth = Base64.decode(auth[1]);
          auth = auth.split(":");
          let username = auth[0];
          let password = auth[1];
          if (username === "dawood" && password === "google123") {
              return {
                  response: {
                      statusCode: 200,
    
                  }
              };
          }}
    

from anyproxy.

codingfishman avatar codingfishman commented on May 18, 2024

Hi @Vbubblery
请问这里面的用户验证是不是指header中的authorization?
如果是header中的信息,目前直接放入header中就可以使用,如果是想在rule中拦截并加入验证信息,应该可以自己对rule进行二次开发,所以可否描述一下用户验证的使用场景?

from anyproxy.

lijinma avatar lijinma commented on May 18, 2024

@ottomao 我也有这个需求,原因是代理开在服务器上面,如果没有 basic auth,这个代理就很容易被别人扫到。

from anyproxy.

lijinma avatar lijinma commented on May 18, 2024

@ottomao 兄弟,可以讲讲实现的思路吗?我自己实现试试。

from anyproxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.