Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: extend afterScan to receive HTTP request headers (?) #710

Open
jlbribeiro opened this issue Dec 29, 2023 · 0 comments
Open

Comments

@jlbribeiro
Copy link

jlbribeiro commented Dec 29, 2023

First of all, thank you @sbs20 for your work on this project.

I'm thinking of setting up this project with a couple of family scanners; I want, however, to be able to sort the scanned files by user, with no user intervention.
I respect the goal of this project is to keep it lean, and introducing the concept of users feels out-of-scope for you (even though there's a basic auth mechanism). Given the response to #357, and taking into account the introduction of afterScan (#483), I'm trying to come up with something that leverages the hooks mechanism, while keeping it fairly generic/extensible.

As far as I can tell (and please correct me if I'm wrong), the afterScan hook looks like the one I'm looking for, but it only receives information concerning the file that was just scanned.

I was thinking of something along these lines:

  • Put some proxy in front of scanservjs that performs some form of authentication; might be basic auth, might be single sign-on, ...
  • This proxy would forward the request to scanservjs with additional headers (e.g. X-Forwarded-For, X-authentik-username, ...)
  • A user triggers a scan action via the Scanservjs UI.
  • afterScan receives the file information after the scan, along with the original HTTP request headers that triggered the scan.
  • Custom user code can do whatever operation it wants, this time with the original request information tied to the resulting file.

This, however, relies on scanservjs propagating the HTTP request headers from user click to afterScan; I'm not sure this is the best way of achieving this, so I'm hoping you have better suggestions. The reason for going with HTTP headers is because it feels "fairly" generic, since it allows other ways of sorting/enhancing files (deciding other processing pipelines based on this).

Some use-cases:

  • user-specific Scan2Mail;
  • output files to user-specific directories (by moving them after scan); this ties nicely with document processing systems (Papermerge/Paperless-ngx);
  • per-user "delivery pipeline", i.e. a mix of all of the above: some prefer files stored in NAS, some prefer cloud storage, some prefer e-mail.

Again, thank you very much for your work, and wishes of a happy holiday season.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant