WebSeal 反向代理背后的 .Net Web 应用程序
我们目前正在设计一个解决方案,该解决方案将作为 WebSeal 反向代理后面的 .Net Web 应用程序运行。
我在网上看到了一些评论,人们对此遇到了各种问题,例如重写视图状态。
问题是:有人实施了这种技术组合并让它发挥作用吗?
We are currently designing a solution that will run as a .Net Web application behind a WebSeal reverse proxy.
I have seen some comments on the net where people have had various problems with this, for example rewriting of viewstate.
Question is: Has anyone implemented this combination of techologies and got it to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 WEBSEAL 后面创建了一个 ASP.NET 应用程序。经过大量的研究、开发和测试,它是有效的。
我建议一些问题来帮助您:
IIS 和 ASP.NET 不区分大小写
(“...Login.aspx”和“...login.aspx”都指向同一页面);默认情况下,webseal 区分大小写。因此,您应该将 WEBSEAL 连接设置为不区分大小写或检查任何单个链接(页面、javascript、图像)
内部链接,写为服务器相对 URL > 不会提供服务
WEBSEAL 更改引用您的应用程序的任何链接,但不会更改到其他应用程序的链接。
写为服务器相对 URL 而不是应用程序相对 URL 的内部链接不会更改(WEBSEAL 无法识别它是同一个应用程序)并且不会提供服务( WEBSEAL 拒绝未修改的链接)。
第一条规则是检查任何单个链接并将其设为应用程序相对 URL。
查看渲染的 HTML,如果您发现
<.. href=/ everything>
:此 ia 服务器相对 URL 并且它是错误的。查看隐藏代码,如果使用
"= ~/ everything"
就很好了。如果您使用"= / everything"
或ResolveUrl(..)
那就不好了。但这还不够:AJAX 将大量 JavaScript 和代码放入 ScriptResource.axd 和 WebResource.axd 中,并创建服务器相对 URL 来链接它们。此链接不受程序员控制,并且没有简单的方法可以更改它们。
简单的解决方案(如果可能):解决问题将 WEBSEAL 连接设置为透明。
硬解决方案:编写以下代码(感谢这个答案)
这会拦截到页面的流,并将所有出现的“/WebResource.axd”或“ScriptResource.axd”替换为“../../WebResource.axd”和“../../ScriptResource.axd” "
开发代码以获取实际的 WEBSEAL 用户
WEBSEAL 已配置为将用户名放入 HTTP_IV_USER 中。我创建了 Webseal\Login.aspx 表单以编程方式读取它。
现在,为了使该用户成为 CurrentUser,我放置了一个隐藏的 asp.Login
并以编程方式单击该按钮。
当 LoginButton 触发时,应用程序读取 UserName(从 WEBSEAL 变量设置)并密码(硬编码)。所以我实现了自定义会员资格提供程序验证用户并设置当前主体。
web.config 中的更改
loginUrl是 FormsAuthentication 类将重定向到的登录页面的 URL。它已设置为 WEBSEAL 门户:未经身份验证的用户和注销按钮将重定向到门户。
由于Webseal/login.aspx不是默认登录页面,authorization 标签向未经过身份验证的用户授予访问权限:
应用程序设置为使用自定义成员资格提供程序:
调试设置为关闭:
就是这样!
I made an ASP.NET application workin behind WEBSEAL. After lot of study and development and test it works.
I suggest some issues to help you:
IIS and ASP.NET are case insensitive
("...Login.aspx" and "...login.aspx" both lead to the same page); by default webseal is case sensitive. So you should set WEBSEAL junction to be case insensitive or check any single link (page, javascript, image)
Internal links, written as server relative URLs won't be served
WEBSEAL changes any link referring your application but doesn't change links to other applications.
Internal links, written as server relative URLs instead of application relative URLs won't be changed (WEBSEAL doesn't recognize it's the same application) and won't be served (WEBSEAL rejects links that are not modified).
First rule is to check any single link and make it an application relative URL .
Look at rendered HTML if you find
<.. href=/ anything>
: this i a server relative URL and it is bad.Look in the Code Behind if you use
"= ~/ anything"
it is good. If you use"= / anything"
ORResolveUrl(..)
it is bad.But this is not enough: AJAX puts loads of javascript and code inside ScriptResource.axd and WebResource.axd and creates server relative URL to link it. This links are not controlled by programmers and there is no easy way to change them.
Easy solution (if possible): solve the problem setting WEBSEAL junction to be transparent.
Hard solution: write the following code (thanks to this answer)
This intercepts the stream to the page and replaces all occurrences of "/WebResource.axd" or "ScriptResource.axd" with "../../WebResource.axd" and "../../ScriptResource.axd"
Develop code to get actual WEBSEAL user
WEBSEAL has been configured to put username inside HTTP_IV_USER. I created Webseal\Login.aspx form to read it programmatically.
Now, in order to make this user the CurrentUser I put an hidden asp.Login
and clicked the button programmatically
When LoginButton fires, application reads UserName (set from WEBSEAL variable) and password (hard coded). So i implemented a custom membership provider that validates users and sets current Principal.
Changes in web.config
loginUrl is the URL for the login page that the FormsAuthentication class will redirect to. It has been set to WEBSEAL portal: not authenticated user and logout button will redirect to portal.
Since Webseal/login.aspx is NOT default login page, authorization tag grants access to not authenticated users:
Application is set to use custom membership providers:
Debug is set to off:
that's all folks!
我最初在通过 WebSeal 访问 ASP.Net 应用程序时遇到了一些问题。我在开发服务器上运行该网站。对我有用的是在配置文件中关闭调试的情况下部署应用程序。
打开调试后,有一些 AJAX 调用在我直接访问该站点时可以正常工作,但在通过 WebSeal 访问时会失败。一旦我关闭调试,一切工作正常。
此外,由于 WebSeal 需要匿名身份验证,因此我们无法使用 Windows 身份验证。
I initially has some issues with the ASP.Net app when accessed through WebSeal. I was running the site on a development server. What worked for me was to deploy the application with debugging turned off in the config file.
With debugging turned on, there were some AJAX calls that would work fine when I accessed the site directly but would fail when access through WebSeal. Once I turned the debugging off, everything work fine.
Also, because WebSeal requires anonymous authentication, we couldn't have used Windows Authentication.