Recent

Author Topic: fpWebFile and session/cookie  (Read 981 times)

Trenatos

  • Hero Member
  • *****
  • Posts: 535
    • MarcusFernstrom.com
fpWebFile and session/cookie
« on: May 13, 2020, 01:20:08 am »
I'm trying to figure out how to use fpWebFile to serve static content, while also limiting access.

I have /app and /app/members, serving files is easy with fpWebFile but I can't figure out how to run a handler for every request to /app/members/* to check if the user is authenticated and either allow access or return a 401.

Is there a way to do this with static file/fpWebFile, so I don't have to deal with the entire request manually? IE. mimetypes, checking path, loading the file into content, etc.
« Last Edit: May 15, 2020, 10:37:26 pm by Trenatos »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: fpWebFile and session/cookie
« Reply #1 on: May 14, 2020, 12:29:47 am »
You can make your own TFPCustomFileModule descendant that overrides HandleRequest (check the authentication etc. here and call the inherited HandleRequest to actually respond with the file content) then assign it to DefaultFileModuleClass.

Trenatos

  • Hero Member
  • *****
  • Posts: 535
    • MarcusFernstrom.com
Re: fpWebFile and session/cookie
« Reply #2 on: May 15, 2020, 10:37:15 pm »
That's an interesting idea, I think I'll give that a go, thanks Leledumbo

Thaddy

  • Hero Member
  • *****
  • Posts: 14381
  • Sensorship about opinions does not belong here.
Re: fpWebFile and session/cookie
« Reply #3 on: May 15, 2020, 10:46:35 pm »
static files only need to be readonly, but when further access rights are required leledumbo's suggestion is very good.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018