Dynamically managing web.config for authorization?

倾然丶 夕夏残阳落幕 提交于 2019-12-25 10:03:19

问题


I'm using a CMS (N2) to manage a new website. The CMS includes functionality for uploading files using the filesystem (not binary in DB, which is also possible, but I want to use filesystem). Some of the subfolders in the uploads directory need to be secured. This can be done using authorization elements in (a sub) web.config as stated here.

Users and roles are managed through the admin interface and are managed by my CMS administrator. Some roles are added dynamically based on certain functionality in the website. Therefore I would like to keep my ~/upload/xxx subfolder security dynamic as well. What is a good solution for dynamically managing authorization based on web.config?


回答1:


One way to accomplish this would be to specify a <location path="MyFolder">...</location> in order to open up a specific folder to anyone.

It is a best practice to put these at the bottom of your web.config file and should give you the flexibility you are looking for.

Here's the MSDN page for the location Element: http://msdn.microsoft.com/en-us/library/b6x6shw7.aspx

Good luck!

Matti




回答2:


Not to do it. Point.

Make your own data file, and plug in a provider to read this, if you dont have a database, use a database otherwise. YOu don want web.config changes to interfere with development / upload changes. VERY nice anti-pattern.



来源:https://stackoverflow.com/questions/5275150/dynamically-managing-web-config-for-authorization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!