简体   繁体   English

如何处理不正确的代理身份验证凭据

[英]How to handle incorrect proxy-auth credentials

I have an electron app that will sometimes be used behind corporate firewalls. 我有一个电子应用程序,有时会在公司防火墙后面使用。

I have added a login event listener to the app and requesting username and password from the user via a dialog box. 我已经向应用程序添加了登录事件监听器,并通过对话框从用户请求用户名和密码。
It's working fine if the user enters their details correctly the first time, but if there is an error with the first attempt and then the user enters the correct details the second time, the request seems to stall and then timeout. 如果用户第一次正确输入详细信息,则工作正常,但如果第一次尝试输入时出错,然后用户第二次输入正确的详细信息,则请求似乎停顿,然后超时。 If I activate another HTTP request, creating a third auth request, and enter the details correctly, it works. 如果我激活另一个HTTP请求,创建第三个身份验证请求并正确输入详细信息,则它可以工作。

Here is the code from the main process in it's current form: 这是当前流程中来自主流程的代码:

const requestHistory = [];

let onAuthCallback = function (username, password) {
  const lastIndex = requestHistory.length - 1;
  if (lastIndex < 0) {
    return;
  }

  const {callback} = requestHistory[lastIndex];
  callback(username, password);
};

app.on('login', (event, webContents, request, authInfo, callback) => {
  event.preventDefault();
  mainWindow.webContents.send('proxy-auth:req', authInfo);
  requestHistory.push({event, webContents, request, authInfo, callback});
});

ipcMain.on('proxy-auth:userpass', (event, userpass) => {
  console.info('userpass:', userpass);
  const {username, password} = userpass;
  try {
    console.info('proxy-auth with "%s" "%s"', username, password);
    onAuthCallback(username, password);
  } catch (error) {
    console.error('ERROR in `proxy-auth:userpass`:', error);
  }
});

If anyone has any pointers that would be great. 如果有人有任何指针,那就太好了。 At the moment I'm thinking of just ignoring any second request to get this out quickly. 目前,我正在考虑忽略任何其他要求以快速实现这一目标。

Thanks 谢谢

So the answer is that there is currently a bug in Electron 答案是,Electron当前存在错误

https://github.com/electron/electron/issues/16010 https://github.com/electron/electron/issues/16010

That bug report has some suggestions to work around the problem. 该错误报告提供了一些解决该问题的建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在与LRS交互时隐藏或保护身份验证凭据 - How to hide or protect auth credentials in interactions with an LRS 如何通过angular-http-auth传递凭据? - how to pass credentials with angular-http-auth? 如何在 Angular 应用程序中处理 API 凭据? - How to handle API credentials in an Angular app? 如何处理JavaScript中标准函数的错误覆盖? - How to handle incorrect overriding of standard functions in JavaScript? 如何将CognitoAuth身份验证对象转换为AWS-SDK凭证 - How to turn an CognitoAuth auth object into AWS-SDK credentials 如何将凭据存储到本地存储以允许 Firebase Auth 登录 - How to Store Credentials to Local Storage to Allow Firebase Auth to Sign-in 如何从JavaScript / HTML获取基本身份验证凭据? - How does one acquire Basic Auth credentials from JavaScript/HTML? 如何使用凭据提供程序在自定义后端使用 axios 确保身份验证 - How to ensure auth with axios in custom backend with credentials provider XHR之后如何在浏览器缓存中存储基本身份验证凭据 - How to store basic auth credentials in browser cache after XHR 在错误的用户凭据上显示模式 - Display a modal on incorrect user credentials
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM