简体   繁体   English

如何重定向到跨域请求的登录页面?

[英]How can you redirect to a logon page for cross-domain requests?

In an application where I am making cross-domain JSONP requests (using jQuery), when the browser makes the first jsonp request, it pops up a dialog for basic authentication, because that is what the target server requires.在我发出跨域 JSONP 请求(使用 jQuery)的应用程序中,当浏览器发出第一个 jsonp 请求时,它会弹出一个基本身份验证对话框,因为这是目标服务器所需要的。 I would instead like to trap the event and bring up a dialog with a logon page from the server hosting the resource to establish authentication.相反,我想捕获该事件并从托管资源的服务器调出一个带有登录页面的对话框,以建立身份验证。 How can I do this?我怎样才能做到这一点?

I think it is not possible, only option is to disable basic authentication and for end users, shouldn't that be disabled?我认为这是不可能的,唯一的选择是禁用基本身份验证,对于最终用户,不应该禁用吗?

I agree with Adeel... it can't be trapped.我同意 Adeel 的观点……它不能被困住。

However, you can supply the required authentication header manually - to prevent the prompt from ever appearing - if the user has already "logged in" and you know their un/pw on the client side.但是,您可以手动提供所需的身份验证 header - 以防止提示出现 - 如果用户已经“登录”并且您知道他们在客户端的 un/pw。

Per this thread How do I make a JSONP call with JQuery with Basic Authentication? Per this thread How do I make a JSONP call with JQuery with Basic Authentication? it seems like you would need to proxy all the requests through server-side to detect and override http-level authentication challenges.似乎您需要通过服务器端代理所有请求以检测和覆盖 http 级身份验证挑战。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM