This PR introduces JWT (JSON Web Token) authentication for Stirling-PDF, allowing for stateless authentication capabilities alongside the existing session-based authentication system. ### Key Features & Changes JWT Authentication System - Core Service: JwtService.java - Token generation, validation, and cookie management - Authentication Filter: JwtAuthenticationFilter.java - Request interceptor for JWT validation - Key Management: KeyPersistenceService.java + KeyPairCleanupService.java - RSA key rotation and persistence - Frontend: jwt-init.js - Client-side JWT handling and URL cleanup Security Integration - SAML2: JwtSaml2AuthenticationRequestRepository.java - JWT-backed SAML request storage - OAuth2: Updated CustomAuthenticationSuccessHandler. java, CustomOAuth2AuthenticationSuccessHandler.java & CustomSaml2AuthenticationSuccessHandler.java for JWT integration - Configuration: Enhanced SecurityConfiguration.java with JWT filter chain Infrastructure - Caching: CacheConfig.java - Caffeine cache for JWT keys - Database: New JwtVerificationKey.java entity for key storage - Error Handling: JwtAuthenticationEntryPoint.java for unauthorized access ### Challenges Encountered - Configured SecurityConfiguration to use either `UsernamePasswordAuthenticationFilter` or `JWTAuthenticationFilter` based on whether JWTs are enabled to prevent the former intercepting requests while in stateless mode. - Removed the `.defaultSuccessUrl("/")` from login configuration as its inclusion was preventing overriding the use of the `CustomAuthenticationSuccessHandler` and preventing proper authentication flows. --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [x] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [x] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [x] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [x] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) <img width="599" height="515" alt="Screenshot 2025-07-10 at 13 35 56" src="https://github.com/user-attachments/assets/4126b752-ad0d-4ffa-b295-6714c43381e1" /> <img width="392" height="376" alt="Screenshot 2025-07-10 at 13 36 10" src="https://github.com/user-attachments/assets/c681bc43-68ff-4934-8245-d544e2ad7b9c" /> <img width="1870" height="986" alt="eb750e8c3954fc47b2dd2e6e76ddb7d5" src="https://github.com/user-attachments/assets/fca9b23d-b0b6-4884-8a26-98a441b641ef" /> <img width="1299" height="702" alt="Screenshot 2025-07-10 at 13 30 57" src="https://github.com/user-attachments/assets/9415d8bf-fac4-4d38-8c3a-985d043d1076" /> ### Testing (if applicable) - [x] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ludy <Ludy87@users.noreply.github.com> Co-authored-by: EthanHealy01 <80844253+EthanHealy01@users.noreply.github.com> Co-authored-by: Ethan <ethan@MacBook-Pro.local> Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> |
||
---|---|---|
.claude | ||
.devcontainer | ||
.github | ||
.vscode | ||
app | ||
devGuide | ||
devTools | ||
docs | ||
exampleYmlFiles | ||
gradle/wrapper | ||
images | ||
scripts | ||
testing | ||
.editorconfig | ||
.git-blame-ignore-revs | ||
.gitattributes | ||
.gitignore | ||
.pre-commit-config.yaml | ||
build.gradle | ||
CONTRIBUTING.md | ||
DATABASE.md | ||
Dockerfile | ||
Dockerfile.dev | ||
Dockerfile.fat | ||
Dockerfile.ultra-lite | ||
gradle.properties | ||
gradlew | ||
gradlew.bat | ||
HowToUseOCR.md | ||
launch4jConfig.xml | ||
LICENSE | ||
README.md | ||
SECURITY.md | ||
settings.gradle |
Stirling-PDF
Stirling-PDF is a robust, locally hosted web-based PDF manipulation tool using Docker. It enables you to carry out various operations on PDF files, including splitting, merging, converting, reorganizing, adding images, rotating, compressing, and more. This locally hosted web application has evolved to encompass a comprehensive set of features, addressing all your PDF requirements.
All files and PDFs exist either exclusively on the client side, reside in server memory only during task execution, or temporarily reside in a file solely for the execution of the task. Any file downloaded by the user will have been deleted from the server by that point.
Homepage: https://stirlingpdf.com
All documentation available at https://docs.stirlingpdf.com/
Features
- 50+ PDF Operations
- Parallel file processing and downloads
- Dark mode support
- Custom download options
- Custom 'Pipelines' to run multiple features in a automated queue
- API for integration with external scripts
- Optional Login and Authentication support (see here for documentation)
- Database Backup and Import (see here for documentation)
- Enterprise features like SSO (see here for documentation)
PDF Features
Page Operations
- View and modify PDFs - View multi-page PDFs with custom viewing, sorting, and searching. Plus, on-page edit features like annotating, drawing, and adding text and images. (Using PDF.js with Joxit and Liberation fonts)
- Full interactive GUI for merging/splitting/rotating/moving PDFs and their pages
- Merge multiple PDFs into a single resultant file
- Split PDFs into multiple files at specified page numbers or extract all pages as individual files
- Reorganize PDF pages into different orders
- Rotate PDFs in 90-degree increments
- Remove pages
- Multi-page layout (format PDFs into a multi-paged page)
- Scale page contents size by set percentage
- Adjust contrast
- Crop PDF
- Auto-split PDF (with physically scanned page dividers)
- Extract page(s)
- Convert PDF to a single page
- Overlay PDFs on top of each other
- PDF to a single page
- Split PDF by sections
Conversion Operations
- Convert PDFs to and from images
- Convert any common file to PDF (using LibreOffice)
- Convert PDF to Word/PowerPoint/others (using LibreOffice)
- Convert HTML to PDF
- Convert PDF to XML
- Convert PDF to CSV
- URL to PDF
- Markdown to PDF
Security & Permissions
- Add and remove passwords
- Change/set PDF permissions
- Add watermark(s)
- Certify/sign PDFs
- Sanitize PDFs
- Auto-redact text
Other Operations
- Add/generate/write signatures
- Split by Size or PDF
- Repair PDFs
- Detect and remove blank pages
- Compare two PDFs and show differences in text
- Add images to PDFs
- Compress PDFs to decrease their filesize (using qpdf)
- Extract images from PDF
- Remove images from PDF
- Extract images from scans
- Remove annotations
- Add page numbers
- Auto-rename files by detecting PDF header text
- OCR on PDF (using Tesseract OCR)
- PDF/A conversion (using LibreOffice)
- Edit metadata
- Flatten PDFs
- Get all information on a PDF to view or export as JSON
- Show/detect embedded JavaScript
📖 Get Started
Visit our comprehensive documentation at docs.stirlingpdf.com for:
- Installation guides for all platforms
- Configuration options
- Feature documentation
- API reference
- Security setup
- Enterprise features
Supported Languages
Stirling-PDF currently supports 40 languages!
Stirling PDF Enterprise
Stirling PDF offers an Enterprise edition of its software. This is the same great software but with added features, support and comforts. Check out our Enterprise docs
🤝 Looking to contribute?
Join our community: