Skip to content

feat: FORMS-943 Enable File Uploads for Public Forms #1696

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

Conversation

revanth-banala
Copy link
Contributor

Description

Public (anonymous) users were unable to upload files to forms that allow public access. The existing hasFileCreate middleware was blocking all file uploads for users without authentication, even when the form was configured to accept public submissions.

Solution
Updated the hasFileCreate middleware in /src/forms/file/middleware/filePermissions.js to properly handle public form access by:

Allowing authenticated users - Users with idpUserId can upload files to any form (existing behavior)
Checking form configuration for public users - For non-authenticated users, validate that:

Form exists and is active
Form has public identity provider configured

Consistent permission logic - Uses the same identity provider checking pattern as other middleware in the codebase
Maintained existing security for authenticated users

Security Considerations
authenticated users maintain same access
Public forms still require explicit public identity provider configuration
Form must be active for any file uploads

Type of Change

feat (a new feature)

Checklist

  • I have read the CONTRIBUTING doc
  • I have checked that unit tests pass locally with my changes
  • I have run the npm script lint on the frontend and backend
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have approval from the product owner for the contribution in this pull request

Further comments

This comment has been minimized.

@revanth-banala revanth-banala marked this pull request as ready for review June 11, 2025 16:12

This comment has been minimized.

Copy link

Copy link
Collaborator

@usingtechnology usingtechnology left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good @revanth-banala.
The functionality checks out and was able to upload on public form (while not allowing the download after submitted).
Nice work.

@nimya-aot
Copy link
Contributor

nimya-aot commented Jun 16, 2025

@revanth-banala When we try to download the uploaded file after submitting the form, it throws an error. Can you check that? Is it possible to block download or show a proper message?
image

Copy link
Contributor

@abhilash-aot abhilash-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes for Public file Upload looks good

Copy link

@usingtechnology usingtechnology merged commit 8002768 into bcgov:main Jun 17, 2025
7 checks passed
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

Successfully merging this pull request may close these issues.

4 participants