Skip to content

Use the current JWT before each file upload - #6246

Open
bram-atmire wants to merge 1 commit into
DSpace:mainfrom
bram-atmire:fix/3979-upload-jwt-refresh
Open

Use the current JWT before each file upload#6246
bram-atmire wants to merge 1 commit into
DSpace:mainfrom
bram-atmire:fix/3979-upload-jwt-refresh

Conversation

@bram-atmire

Copy link
Copy Markdown
Member

References

Fixes #3979

Description

File uploads now use the current JWT immediately before each file is sent. Previously, ng2-file-upload retained the Authorization value captured when the uploader was initialized, so later uploads on an open submission form could fail after token renewal.

The existing upload callback now updates the library's authToken field using AuthService.buildAuthHeader(). This avoids adding a second Authorization header. The CSRF handling remains independent.

Instructions for Reviewers

  1. Log in and open a submission with a file-upload section.
  2. Upload a file, then keep the form open until the UI renews the JWT (or use a shorter login-token lifetime in a test installation).
  3. Upload another file without reloading the form. Inspect its request: it should contain exactly one Authorization value using the renewed JWT, and the upload should succeed.

This fixes stale credentials on subsequent uploads. It does not change the token attached to a request already in flight or address expiry during a single long SAF upload.

Validation: all 13 focused tests pass (uploader, submission upload, and bitstream replacement). The uploader regression tests verify the actual library's outgoing headers across token renewal and clear cached credentials when authentication disappears. Full ESLint validation passes with warnings only. npm run check-circ-deps passes on the clean source tree, after npm run clean:decorator:registries removes build-generated registries, matching CI's pre-build check.

Checklist

  • Created against main; small change with no new dependencies.
  • Includes regression tests and reviewer instructions.
  • Modified lifecycle method has TypeDoc.
  • No user-interface or translation changes.

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.

File Upload fails if authentication token is refreshed while on submission form (401Unauthorized error)

1 participant