Repository navigation
Pass an explicit context to Cms, Common and two-factor services - #937
Merged
KrzysztofPajak merged 9 commits intoOct 17, 2026
Merged
Conversation
added 8 commits
October 17, 2026 07:18
- Keep the display order of pages read for a store - Show group-limited pages and news in the admin search - Skip the knowledge base store filter for an empty store id and keep reads including hidden records out of a groupless customer's cache entry - Leave customer groups out of page, knowledge base and home-page news cache keys when the ACL is off - Guard the store in GenerateCodeSetup and the customer in AuthorizeAction; load the customer's groups once there - Build the catalog access once in the knowledge base keyword search and take article parents from the loaded categories - Flatten the ACL and store filters in GetAllNews and GetAllPages
KrzysztofPajak
deleted the
refactor/business-explicit-context-cms-common
branch
October 17, 2026 13:13
This was referenced Oct 17, 2026
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.
Part of the explicit-context work in Business (after #930, #931, #932)
Type: feature
Issue
PageService,NewsService,KnowledgebaseServiceandTwoFactorAuthenticationServiceread the current customer and store fromIContextAccessor.PermissionService.AuthorizeActionandTranslationService.ImportResourcesFromXmldid the same. Outside a request these values are missing or belong to someone else, so results depended on who was calling.While moving the callers, three bugs turned up:
PAGES_ALL_KEYwasstore + ignoreAcl, but the read filters by the current customer's groups. The footer, menu, sitemap and closed-store filter therefore showed every visitor the page list of whoever filled the cache first. A guest could see links to group-limited pages, and a group member could lose them.HOMEPAGE_NEWSMODEL_KEYwaslanguage + store, over a group-filtered news list.GetKnowledgebaseArticles(storeId)ignored itsstoreIdand applied the ambient filter. In the admin tree and the related-articles popup, articles limited to a group the admin is not in, or to another store, were hidden, while the categories on the same screen were all listed.Solution
CatalogAccess(as Catalog and checkout attributes already do):For(customer, storeId)limits the result to the customer's groups, andIncludingHidden(storeId)replacesignoreAcl: true. Web builds it withcontextAccessor.CatalogAccess(), or fromrequest.Customer/request.Storewhere the request carries them. Each caller passes exactly what the service used to read.GenerateCodeSetuptakes theStore, whose company name is the authenticator issuer.AuthorizeActiontakes theCustomer, andPermissionAuthorizeActionAttributepasses the request customer.ImportResourcesFromXmldropped its ambientCreatedBy = CurrentCustomer.Email. The repository overwritesCreatedByfromIAuditInfoProvideron every insert, so the value was never saved, and the read only made the import throw without a current customer.GetTranslationEnum(…, IContextAccessor)overload.ITranslationService.GetResource(string name)andIPermissionService.Authorize(Permission)/Authorize(string)still read the current request: they have about 1,700 call sites. Their docs now say so and point to the explicit overloads.GetKnowledgebaseArticles()returns every article.Breaking changes
IPageService.GetAllPages(CatalogAccess access)replacesGetAllPages(string storeId, bool ignoreAcl = false).INewsService.GetAllNews(CatalogAccess access, int pageIndex = 0, int pageSize = int.MaxValue, bool includeUnpublished = false, string newsTitle = ""):ignoreAcl→access,showHidden→includeUnpublished.IKnowledgebaseService:GetPublicKnowledgebaseCategory,GetPublicKnowledgebaseCategories,GetPublicKnowledgebaseArticles(),GetPublicKnowledgebaseArticle,GetPublicKnowledgebaseArticlesByCategory,GetPublicKnowledgebaseArticlesByKeyword,GetPublicKnowledgebaseCategoriesByKeywordandGetHomepageKnowledgebaseArticlestake a trailingCatalogAccess access.GetKnowledgebaseArticles()lost its unusedstoreIdand no longer filters.ITwoFactorAuthenticationService.GenerateCodeSetup(secretKey, customer, store, language, type).IPermissionService.AuthorizeAction(permissionSystemName, permissionActionName, customer).TranslateExtensions.GetTranslationEnum<T>(T, ITranslationService, IContextAccessor).PageService,NewsService,KnowledgebaseServiceandTwoFactorAuthenticationServiceno longer takeIContextAccessor.PAGES_ALL_KEYandHOMEPAGE_NEWSMODEL_KEYhave a third segment, the customer group ids. The invalidation prefixes are unchanged.Testing
Automated: the solution builds, and
dotnet test GrandNode.slnxpasses (22 projects). New tests cover:IncludingHiddennext toFor;includeUnpublished;IncludingHidden;AuthorizeActionfor the given customer;Manual: