feat(oga-backend): Secure OGA File Downloads#252
feat(oga-backend): Secure OGA File Downloads#252ginaxu1 wants to merge 3 commits intoOpenNSW:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a critical feature for the OGA application: secure file downloads. It establishes a new API endpoint that acts as a secure proxy, forwarding authenticated requests to a backend service to retrieve sensitive files. This change significantly improves data security by preventing direct exposure of unauthenticated content routes. Additionally, the underlying authentication mechanism has been made more robust by allowing the system to validate tokens against a configurable list of client IDs, accommodating various OGA portal applications. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces two significant improvements. Firstly, it refactors the authentication logic to support multiple client IDs, enhancing the flexibility of token validation. This change is consistently applied across configuration, token parsing, and test files. Secondly, it adds a secure file download endpoint to the OGA service, which acts as an authenticated proxy to the main backend. This is a solid security enhancement. My review focuses on improving the implementation of this new proxy endpoint for better performance and robustness.
…ddress PR Comments
214b793 to
3f6d3ec
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively transitions the OGA file download mechanism to a secure token forwarding model, which is a significant security improvement. The changes to support multiple client IDs in the backend are well-implemented across the configuration, token parsing, and testing layers. The new OGA handler for proxying download requests is a good approach to centralize access control in the NSW backend.
I have one suggestion in oga/internal/handler.go to improve the robustness and security of parsing the JWT for logging purposes. Overall, this is a solid pull request that enhances the security of the application.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
94c0cc0 to
713b04a
Compare
Closes #251
Summary
This PR transitions the OGA Portal from using unauthenticated direct links to a secure Token Forwarding model. By modifying the NSW Backend to accept multiple Client IDs, the system now allows OGA officers to access protected documents using their own WSO2 identity
Changes
NSW Token Validation Refactor
backend/internal/auth/token_parser.goto support a multiple Client IDs validation to bridge the gap betweenTRADER_PORTAL_APPand the variousOGA_PORTAL_APP_*client identifiersTokenExtractorBackend Configuration Strategy
backend/internal/config/config.goto automatically split a comma-separatedAUTH_CLIENT_IDenvironment variable stringdocker-compose.ymlbackend service'sAUTH_CLIENT_IDstring to injectTRADER_PORTAL_APP,OGA_PORTAL_APP_NPQS,OGA_PORTAL_APP_FCAU,OGA_PORTAL_APP_IRDOGA Service Refactor
OGAHandler
HandleGetUploadURLhandler to intercept OGA frontend download requests, attach the officer's Authorization: Bearer , issue the service-to-service GET to the NSW Backend's restricted/api/v1/uploads/{key}endpoint, and stream the response HTTP code and URL (either local filesystem endpoint or S3 presigned URL) back down to the caller UITesting
Unit Tests
Manual testing