Skip to content

Collapse store Url/SecureUrl/SslEnabled onto a single Url - #834

Merged
KrzysztofPajak merged 1 commit into
developfrom
refactor/store-single-url
Sep 12, 2026
Merged

Collapse store Url/SecureUrl/SslEnabled onto a single Url#834
KrzysztofPajak merged 1 commit into
developfrom
refactor/store-single-url

Conversation

@KrzysztofPajak

@KrzysztofPajak KrzysztofPajak commented Sep 12, 2026

Copy link
Copy Markdown
Member

Type: feature

Issue

A store describes one address with three fields: Url, SecureUrl and SslEnabled. Every consumer resolves the effective address the same way — SslEnabled ? SecureUrl : Url — in 15+ places (all DotLiquid drops, GetSitemapXMLCommandHandler, InstallDataRobotsTxt, StoreContextSetter, CommonController, StoreViewModelService, both order PDF templates). There is effectively already only one URL; the pair is just a redundant way of writing it down.

The pair is a leftover from mixed http/https sites, where only login and checkout ran over TLS. That layout is gone — sites are HTTPS end to end — and the store owner is left with a checkbox whose only real effect is to select which of two text boxes is read.

Forcing HTTPS on an incoming http:// request is not the shop's job either: it belongs to the host. GrandNode already exposes it as SecurityConfig.UseHttpsRedirection, UseHsts and UseForwardedHeaders (GrandCommonStartup, ForwardedHeadersStartup), and in production a reverse proxy usually does the 301 + HSTS anyway.

To reproduce the redundancy: open Administration → Configuration → Stores → edit, and note that SSL enabled + Secure URL never produce an address the store does not already have.

Solution

Store.Url becomes the single address field and holds the full URL including the scheme. SslEnabled and SecureUrl are removed from the entity, StoreDto, StoreModel, StoreValidator and the admin view (together with the JS that toggled #pnlSecureUrl).

Url stays on the entity for the one reason it is genuinely needed: emails, sitemap.xml, robots.txt and order PDFs are built outside a request and have no Request.Scheme to read.

Two places were not a straight substitution:

  • GetProductDetailsPageHandler rewrote http:// to https:// inside the share button code when SSL was on. Removed — a mixed-content workaround from before HSTS.
  • The 1.1 domains migration read SslEnabled; it now takes the scheme from new Uri(store.Url).Scheme, with identical behavior.

The validator accepts any absolute http/https URL, so dev and intranet installations can still run over plain http. Startup/security configuration is untouched.

MigrationStoreSingleUrl (2.4) copies the primary DomainHost url back onto Store.Url. That is exactly the value the old ternary produced — the installer, the admin store editor and the 1.1 domains migration all wrote the resolved address there — so an installation that ran on HTTPS keeps generating HTTPS links. Stores without a usable primary domain are logged as a warning rather than guessed at. The now-unmapped SslEnabled/SecureUrl elements are left in the documents: the global IgnoreExtraElementsConvention skips them on read, and they disappear on the next store save.

Breaking changes

  • Store.SslEnabled and Store.SecureUrl are removed from the domain entity. Plugins or custom code reading them will not compile.
  • StoreDto.SslEnabled and StoreDto.SecureUrl are removed from the API module, so the store endpoint's payload shape changes.
  • StoreModel.SslEnabled / StoreModel.SecureUrl are removed, which affects admin view overrides and any IValidatorConsumer<StoreModel>.
  • The localization resources Admin.Configuration.Stores.Fields.SslEnabled, .SslEnabled.Hint2, .SecureUrl and .SecureUrl.WrongFormat are removed; .Url.WrongFormat has a new message, shipped in en_240.xml.
  • Behavior for existing data is preserved by the 2.4 migration.

Testing

  1. Install a fresh store over https and confirm Administration → Configuration → Stores → edit shows a single URL of the store field, with no SSL enabled checkbox and no Secure URL field.
  2. Save the store with https://yourhost/. Open the Domains tab and confirm the primary domain's url matches, with a trailing /.
  3. Request /sitemap.xml and confirm every <loc> uses https://yourhost/. Request /robots.txt and confirm the Sitemap: and Host: lines do too.
  4. Place an order and check the queued order email — the store link and the product links must be https://.
  5. Download the order PDF and confirm the store logo renders (it is fetched through the store url).
  6. Try saving the store with yourhost (no scheme) and with ftp://yourhost/ — both must be rejected with the URL format message. http://localhost:5001/ must be accepted.
  7. Upgrade path: take a 2.3 database whose store has SslEnabled: true and SecureUrl: "https://yourhost/" while Url is "http://yourhost/". Run the 2.4 upgrade and confirm Store.Url is now https://yourhost/, then re-check steps 3 and 4.
  8. Confirm forcing HTTPS still works where it belongs: set Security.UseHttpsRedirection to true in appsettings.json, request the storefront over http, and confirm the 301 to https.

🤖 Generated with Claude Code

A store carried three fields to describe one address - Url, SecureUrl and
SslEnabled - and every consumer resolved it the same way, as
`SslEnabled ? SecureUrl : Url`. The pair is a leftover from mixed
http/https sites, where only login and checkout ran over TLS.

Store.Url now holds the full address including the scheme, and it stays
on the entity only because emails, sitemap.xml, robots.txt and order PDFs
are built outside a request and have no Request.Scheme to read.
Forcing HTTPS on an incoming http:// request is left where it already
lives - SecurityConfig.UseHttpsRedirection/UseHsts/UseForwardedHeaders and
the reverse proxy - not in the store record.

The validator accepts any absolute http(s) url, so dev and intranet
installations can still run over plain http.

MigrationStoreSingleUrl (2.4) copies the primary DomainHost url back onto
Store.Url: the installer, the admin store editor and the 1.1 domains
migration all wrote the resolved address there, so an installation that
ran on HTTPS keeps generating HTTPS links.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GrGY1NnCzdkn7wUxbyHzsX
Copilot AI lite review requested due to automatic review settings September 12, 2026 09:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment on lines +68 to +71
catch (Exception ex)
{
logService.LogError(ex, "UpgradeProcess - MigrationStoreSingleUrl (2.4)");
}
@KrzysztofPajak
KrzysztofPajak merged commit 20851fd into develop Sep 12, 2026
6 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the refactor/store-single-url branch September 12, 2026 10:39
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.

2 participants