Collapse store Url/SecureUrl/SslEnabled onto a single Url - #834
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: feature
Issue
A store describes one address with three fields:
Url,SecureUrlandSslEnabled. 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 asSecurityConfig.UseHttpsRedirection,UseHstsandUseForwardedHeaders(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 URLnever produce an address the store does not already have.Solution
Store.Urlbecomes the single address field and holds the full URL including the scheme.SslEnabledandSecureUrlare removed from the entity,StoreDto,StoreModel,StoreValidatorand the admin view (together with the JS that toggled#pnlSecureUrl).Urlstays on the entity for the one reason it is genuinely needed: emails,sitemap.xml,robots.txtand order PDFs are built outside a request and have noRequest.Schemeto read.Two places were not a straight substitution:
GetProductDetailsPageHandlerrewrotehttp://tohttps://inside the share button code when SSL was on. Removed — a mixed-content workaround from before HSTS.SslEnabled; it now takes the scheme fromnew Uri(store.Url).Scheme, with identical behavior.The validator accepts any absolute
http/httpsURL, so dev and intranet installations can still run over plain http. Startup/security configuration is untouched.MigrationStoreSingleUrl(2.4) copies the primaryDomainHosturl back ontoStore.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-unmappedSslEnabled/SecureUrlelements are left in the documents: the globalIgnoreExtraElementsConventionskips them on read, and they disappear on the next store save.Breaking changes
Store.SslEnabledandStore.SecureUrlare removed from the domain entity. Plugins or custom code reading them will not compile.StoreDto.SslEnabledandStoreDto.SecureUrlare removed from the API module, so the store endpoint's payload shape changes.StoreModel.SslEnabled/StoreModel.SecureUrlare removed, which affects admin view overrides and anyIValidatorConsumer<StoreModel>.Admin.Configuration.Stores.Fields.SslEnabled,.SslEnabled.Hint2,.SecureUrland.SecureUrl.WrongFormatare removed;.Url.WrongFormathas a new message, shipped inen_240.xml.Testing
httpsand confirm Administration → Configuration → Stores → edit shows a singleURL of the storefield, with noSSL enabledcheckbox and noSecure URLfield.https://yourhost/. Open theDomainstab and confirm the primary domain's url matches, with a trailing/./sitemap.xmland confirm every<loc>useshttps://yourhost/. Request/robots.txtand confirm theSitemap:andHost:lines do too.https://.yourhost(no scheme) and withftp://yourhost/— both must be rejected with the URL format message.http://localhost:5001/must be accepted.SslEnabled: trueandSecureUrl: "https://yourhost/"whileUrlis"http://yourhost/". Run the 2.4 upgrade and confirmStore.Urlis nowhttps://yourhost/, then re-check steps 3 and 4.Security.UseHttpsRedirectiontotrueinappsettings.json, request the storefront overhttp, and confirm the 301 tohttps.🤖 Generated with Claude Code