I have a scenario where I'm not really sure my approach is the best one, and I would appreciate feedback / suggestions.
scenario: I have a bunch of flash based (swf) 'modules' which are hosted in my aspnet application. Each flash has it's own directory on the filesystem, which contains assets for the flash. Consider this simplified site structure:
/webapp/index.aspx
/webapp/flash/flash1/flash.swf
/webapp/flash/flash1/someimage.jpg
/webapp/flash/flash1/someclip.mp3
/webapp/flash/flash2/flash.swf
/webapp/flash/flash2/someimage.jpg
/webapp/flash/flash2/someclip.mp3
etcetera
where the naming convention is /webapp/flash/flash[ID]/
I want to implement a security mechanism which checks whether the user should be allowed access* to the files in the subfolder '[ID]' and it's contents.
*insert business logic based on information stored in a SQL database here
I was considering writing a HttpModule which does something like
ProcessRequest(){
if(Request.RawUrl.Contains("/webapp/flash") && !userHasValidLicenseForModule(1)){
Redirect("login.aspx");
}
}
But there's the drawback that HttpModule only works for file extension which are mapped to aspnet (in IIS6). That means I would have to map all possible extensions to that process (.mp3, .jpg etc) which is something I would rather avoid.
I was also considering to use a HttpHandler instead, but the flash file needs to be able to link to it's resources using relative URLs. (so a proxy-like pattern like /webapp/getprotectedstuff.ashx?file=flash1234/flash.swf is not prefered)
Perhaps it's wiser to store the flash files and assets outside of the web root completely. Perhaps there are other strategies I havent thought of.
Use aspnet security and write a custom membership provider?
Any thoughts?