PR uses custom policies to combine several policies with access rights
set.
Since a map was in the path, user API for custom policies needed an
extension to preserve policy ID order. The existing function returning a
map didn't handle json decode errors properly and go semantics when
looping over maps don't preserve this order, but it's random so tests
would fail. Verified with task stress.
TT-12897 Merge path based permissions when combining policies (#6597)
User description
TT-12897
PR uses custom policies to combine several policies with access rights set.
Since a
map
was in the path, user API for custom policies needed an extension to preserve policy ID order. The existing function returning a map didn't handle json decode errors properly and go semantics when looping over maps don't preserve this order, but it's random so tests would fail. Verified withtask stress
.Issue: https://tyktech.atlassian.net/browse/TT-12897
PR Type
Bug fix, Enhancement, Tests
Description
MergeAllowedURLs
to merge allowed URLs efficiently.Store
to use a slice for policies, and introducedStoreMap
for unordered policy storage.GetCustomPolicies
to preserve policy order.MergeAllowedURLs
.stress
task for running stress tests.Changes walkthrough 📝
apply.go
Enhance policy application logic and logging
internal/policy/apply.go
MergeAllowedURLs
function to merge allowed URLs.Logger
function to return alogrus.Entry
.session.CustomPolicies()
tosession.GetCustomPolicies()
.store.go
Refactor Store to use slice for policies
internal/policy/store.go
Store
to use a slice for policies.store_map.go
Add StoreMap for unordered policy storage
internal/policy/store_map.go
StoreMap
for unordered policy storage.StoreMap
.util.go
Introduce MergeAllowedURLs and remove unused functions
internal/policy/util.go
MergeAllowedURLs
function for merging URL access specs.copyAllowedURLs
andcontains
functions.custom_policies.go
Enhance custom policies handling with order preservation
user/custom_policies.go
GetCustomPolicies
to preserve policy order.CustomPolicies
to useGetCustomPolicies
.apply_test.go
Update tests for policy application
internal/policy/apply_test.go
policy.Service
in tests.Apply
method is tested withassert.NoError
.util_test.go
Add tests for MergeAllowedURLs function
internal/policy/util_test.go - Added tests for `MergeAllowedURLs` function.
Taskfile.yml
Update Taskfile with stress test task
internal/policy/Taskfile.yml
stress
task for running stress tests.default
task to includetest
.Co-authored-by: Tit Petric tit@tyk.io