Skip to content

Enforce https in URL's used by customers#5728

Merged
christopherholland-workday merged 5 commits intomainfrom
enforce-https
Feb 25, 2026
Merged

Enforce https in URL's used by customers#5728
christopherholland-workday merged 5 commits intomainfrom
enforce-https

Conversation

@christopherholland-workday
Copy link
Contributor

Create a new util that ensures HTTPS is used for various operations, like password reset. Continue to allow HTTP for local testing.

Tested with a new unit test suite.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @christopherholland-workday, 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 significantly enhances the application's security posture by introducing a robust URL utility that enforces HTTPS for all external-facing links, such as those used for password resets, email verification, and user registration. This change centralizes the logic for constructing application URLs, ensuring that sensitive operations are always conducted over secure connections while maintaining flexibility for local development environments. The integration of these utilities across key services ensures consistent and secure URL generation throughout the application.

Highlights

  • New URL Utility Functions: Introduced getSecureAppUrl and getSecureTokenLink in a new url.util.ts file to centralize and standardize URL generation, ensuring security best practices.
  • HTTPS Enforcement: The new getSecureAppUrl function automatically converts http:// URLs to https:// for non-localhost environments, enhancing security for customer-facing links like password resets and verifications. HTTP is still permitted for local development.
  • Account Service Integration: The account.service.ts has been updated to utilize these new secure URL utilities for generating verification, registration, and password reset links, replacing direct string concatenation.
  • Comprehensive Unit Tests: A new unit test suite (url.util.test.ts) has been added to thoroughly validate the behavior of the new URL utility functions across various scenarios, including HTTPS conversion, localhost exceptions, and path handling.
  • Jest Configuration Update: The Jest test regex in jest.config.js was broadened to .*\.test\.tsx?$ to correctly discover the newly added test files.
Changelog
  • packages/server/jest.config.js
    • Updated testRegex from ((\.|/)index\.test)\.tsx?$ to .*\.test\.tsx?$ to include all test files following the *.test.ts naming convention.
  • packages/server/src/enterprise/services/account.service.ts
    • Imported getSecureAppUrl and getSecureTokenLink from the new url.util.
    • Replaced direct URL string construction with getSecureTokenLink for verification links (lines 99, 175).
    • Replaced direct URL string construction with getSecureTokenLink and getSecureAppUrl for registration links (lines 316, 317, 385, 387).
    • Replaced direct URL string construction with getSecureAppUrl for dashboard links (line 413).
    • Replaced direct URL string construction with getSecureTokenLink for password reset links (line 551).
  • packages/server/src/enterprise/utils/url.util.ts
    • Added new file url.util.ts.
    • Exported getSecureAppUrl function: Ensures APP_URL uses HTTPS for non-localhost URLs, converts HTTP to HTTPS if necessary, and appends an optional path. Throws an error if APP_URL is not configured.
    • Exported getSecureTokenLink function: Constructs a secure URL with a token parameter, leveraging getSecureAppUrl to ensure the base URL is secure.
  • packages/server/test/enterprise/utils/url.util.test.ts
    • Added new file url.util.test.ts.
    • Implemented comprehensive unit tests for getSecureAppUrl covering scenarios like HTTPS unchanged, HTTP to HTTPS conversion, and allowing HTTP for various localhost formats (localhost, 127.0.0.1, ::1, 0.0.0.0).
    • Included tests for path appending and handling trailing slashes in getSecureAppUrl.
    • Implemented unit tests for getSecureTokenLink to verify secure link creation, HTTP to HTTPS conversion for token links, and localhost handling.
    • Added security-focused test scenarios to confirm prevention of HTTP links for sensitive operations like password reset, verification, and registration in production-like environments.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new utility to enforce HTTPS for customer-facing URLs, such as those used in password resets and email verifications, while allowing HTTP for local development. The changes are well-implemented by replacing direct URL constructions with calls to the new getSecureAppUrl and getSecureTokenLink functions. A comprehensive test suite has been added for the new utility. My review includes one suggestion to improve the robustness of the new URL utility by adding validation for the APP_URL environment variable to handle potential misconfigurations gracefully.

@christopherholland-workday christopherholland-workday merged commit 2e3dfde into main Feb 25, 2026
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.

3 participants