Skip to content

Commit 2854e0f

Browse files
authored
Merge pull request #2 from unic/feature/add-urlmapper-roles
Add UrlMapper roles
2 parents bce1526 + f4fc2f0 commit 2854e0f

File tree

47 files changed

+360
-149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+360
-149
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Redirects can be defined with Regex patterns, allowing you to be even more speci
2424

2525
For example, if you would like to have a "wildcard" matching, you can define the term as `^mytest`, which will result in all of the following requests being a match: `https://mysite.com/test`, `https://mysite.com/testing`, `https://mysite.com/test-redirect`.
2626

27+
### Regex Captures
28+
29+
Capture groups can be defined when the regex feature has been enabled for a redirect. Capture groups can be used for example for transfering incoming query strings to the defined target.
30+
31+
The following term definition matches incoming terms for `global-capture` and transfers all query strings to the target (if any have been provided): `^global-capture([?].*)?`
32+
2733
### Bulk Import
2834

2935
A Sitecore PowerShell script is included allowing Authors to upload a CSV containing redirect definitions.

be/etc/import/example-import-file.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ site;local redirect 3;urlmapper-jss-app;urlmapper-jss-app;;;any;en;local-redirec
1616
site;local redirect 3;urlmapper-jss-app;urlmapper-jss-app;;;any;de-ch;local-redirect-three-de;/graphql/sample-2;
1717

1818
site;local redirect to different site 1;integration-site;urlmapper-jss-app;;;any;de-ch;local-redirect-to-different-site-one-de;/graphql/sample-1;
19+
20+
global;global capture 1;;;;x;any;en;^global-capture([?].*)?;https://www.google.com;Transfers all query strings to the target url;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
Unicorn.Roles.DataProvider.config
3+
4+
This file configures the Unicorn roles event handlers. The events write updated serialized roles to disk when they are changed or added.
5+
6+
This file should be removed in ANY deployed instance (CE or CD) that does not act as a source for serialized role updates.
7+
Generally speaking that's anywhere other than a developer workstation, so your CI process (you have one, right?) should remove this file during the build.
8+
9+
http://github.com/kamsar/Unicorn
10+
-->
11+
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
12+
<sitecore role:require="Standalone">
13+
<events>
14+
<event name="role:created">
15+
<handler type="Unicorn.Roles.Events.UnicornRolesEventHandler, Unicorn.Roles" method="RoleCreated" />
16+
</event>
17+
<event name="role:deleted">
18+
<handler type="Unicorn.Roles.Events.UnicornRolesEventHandler, Unicorn.Roles" method="RoleRemoved" />
19+
</event>
20+
<event name="roles:relationsRemoved">
21+
<handler type="Unicorn.Roles.Events.UnicornRolesEventHandler, Unicorn.Roles" method="RolesInRolesRemoved" />
22+
</event>
23+
<event name="roles:rolesAdded">
24+
<handler type="Unicorn.Roles.Events.UnicornRolesEventHandler, Unicorn.Roles" method="RolesInRolesAltered" />
25+
</event>
26+
<event name="roles:rolesRemoved">
27+
<handler type="Unicorn.Roles.Events.UnicornRolesEventHandler, Unicorn.Roles" method="RolesInRolesAltered" />
28+
</event>
29+
</events>
30+
</sitecore>
31+
</configuration>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!--
2+
Unicorn.Roles.config
3+
4+
Configures Unicorn to be capable of syncing security roles as well as Sitecore items.
5+
See Unicorn.Configs.Default.Roles.config.example for details of how to include roles and how they sync.
6+
7+
This file should be present on all environments where Unicorn will be expected to sync roles.
8+
Normally this would be development and Content Editing (CE) environments.
9+
It should not hurt anything if left in a CD environment, but it may be removed.
10+
11+
http://github.com/kamsar/Unicorn
12+
-->
13+
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
14+
<sitecore role:require="Standalone or ContentManagement">
15+
<unicorn>
16+
<defaults>
17+
<!-- Note: do not colocate serialized items and serialized roles in the same folder -->
18+
<roleDataStore physicalRootPath="$(dataFolder)\Unicorn\Unicorn.Roles\$(configurationName)" type="Unicorn.Roles.Data.FilesystemRoleDataStore, Unicorn.Roles" singleInstance="true"/>
19+
<roleLoader type="Unicorn.Roles.Loader.RoleLoader, Unicorn.Roles" singleInstance="true" />
20+
<roleLoaderLogger type="Unicorn.Roles.Loader.DefaultRoleLoaderLogger, Unicorn.Roles" singleInstance="true" />
21+
22+
<roleSerializationFormatter type="Unicorn.Roles.Formatting.YamlRoleSerializationFormatter, Unicorn.Roles" singleInstance="true" />
23+
24+
<!--
25+
If you set RemoveOrphans to true, role syncing will delete matching roles that are not serialized, like item syncing does.
26+
If set to false, roles are only ever added or updated (similar to New Items Only item syncing but updates are also synced)
27+
-->
28+
<roleSyncConfiguration removeOrphans="true" type="Unicorn.Roles.Loader.DefaultRoleSyncConfiguration, Unicorn.Roles" singleInstance="true" />
29+
</defaults>
30+
</unicorn>
31+
32+
<pipelines>
33+
<unicornSyncComplete>
34+
<processor type="Unicorn.Roles.Pipelines.UnicornSyncComplete.SyncRoles, Unicorn.Roles" />
35+
</unicornSyncComplete>
36+
<unicornReserializeComplete>
37+
<processor type="Unicorn.Roles.Pipelines.UnicornReserializeComplete.ReserializeRoles, Unicorn.Roles" />
38+
</unicornReserializeComplete>
39+
</pipelines>
40+
</sitecore>
41+
</configuration>

be/src/Unic.UrlMapper2.Integration.Website/code/Unic.UrlMapper2.Integration.Website.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
<PackageReference Include="Unicorn">
8585
<Version>4.1.1</Version>
8686
</PackageReference>
87+
<PackageReference Include="Unicorn.Roles">
88+
<Version>4.1.1</Version>
89+
</PackageReference>
8790
</ItemGroup>
8891
<ItemGroup>
8992
<ProjectReference Include="..\..\Unic.UrlMapper2\code\Unic.UrlMapper2.csproj">
@@ -125,6 +128,12 @@
125128
<ItemGroup>
126129
<Content Include="App_Config\Include\UrlMapper2.Integration.Website\UrlMapper2.Integration.Website.Logging.config" />
127130
</ItemGroup>
131+
<ItemGroup>
132+
<Content Include="App_Config\Include\Unicorn\Unicorn.Roles.config" />
133+
</ItemGroup>
134+
<ItemGroup>
135+
<Content Include="App_Config\Include\Unicorn\Unicorn.Roles.DataProvider.config" />
136+
</ItemGroup>
128137
<PropertyGroup>
129138
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
130139
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

be/src/Unic.UrlMapper2.Integration.Website/code/packages.lock.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@
109109
"Unicorn.Core": "4.1.1"
110110
}
111111
},
112+
"Unicorn.Roles": {
113+
"type": "Direct",
114+
"requested": "[4.1.1, )",
115+
"resolved": "4.1.1",
116+
"contentHash": "7imDlDNLuzvEVS6b9nd1PbMVIHRybtycruQVlReC+WnfWNjpHa/cuxznoez6Ht5mUi5M+nyxMMW2qnF03YPdRw==",
117+
"dependencies": {
118+
"Unicorn": "4.1.1",
119+
"Unicorn.Roles.Core": "4.1.1"
120+
}
121+
},
112122
"Configy": {
113123
"type": "Transitive",
114124
"resolved": "1.0.0",
@@ -632,6 +642,16 @@
632642
"Rainbow.Storage.Yaml": "2.1.1"
633643
}
634644
},
645+
"Unicorn.Roles.Core": {
646+
"type": "Transitive",
647+
"resolved": "4.1.1",
648+
"contentHash": "0gBlv+ZhVA/cKCp4jNrA0ZaT32vC7Z8HaaN65HniYyabpOHYpn5mSudJyZE/wYnH21CJDT2yBOz7TbeGXCXdrw==",
649+
"dependencies": {
650+
"Configy": "1.0.0",
651+
"Rainbow.Core": "2.1.1",
652+
"Unicorn.Core": "4.1.1"
653+
}
654+
},
635655
"WebActivatorEx": {
636656
"type": "Transitive",
637657
"resolved": "2.0.3",

be/src/Unic.UrlMapper2.Integration.Website/serialization/Global Redirects/Redirects/Imported Redirects.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ DB: master
77
SharedFields:
88
- ID: "814bdd80-36de-46fa-938c-46ceaf5d9722"
99
Hint: Last Import Date
10-
Value: 20200207T090942
10+
Value: 20200319T090444
1111
Languages:
1212
- Language: "de-CH"
1313
Versions:

be/src/Unic.UrlMapper2.Integration.Website/serialization/Global Redirects/Redirects/Imported Redirects/2020.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
ID: "e41f99c3-6f9c-4676-8ab4-bd4693617d03"
2+
ID: "f574ec6f-90d7-4fa4-aedf-90aa70122162"
33
Parent: "c4cb89d8-fb85-4c3f-8cb4-690d3cde7314"
44
Template: "adb6ca4f-03ef-4f47-b9ac-9ce2ba53ff97"
55
Path: /sitecore/content/Redirects/Imported Redirects/2020
@@ -11,4 +11,4 @@ Languages:
1111
Fields:
1212
- ID: "25bed78c-4957-4165-998a-ca1b52f67497"
1313
Hint: __Created
14-
Value: 20200207T080941Z
14+
Value: 20200319T080443Z

be/src/Unic.UrlMapper2.Integration.Website/serialization/Global Redirects/Redirects/Imported Redirects/2020/02.yml renamed to be/src/Unic.UrlMapper2.Integration.Website/serialization/Global Redirects/Redirects/Imported Redirects/2020/03.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
ID: "4eb55e10-5a46-4e1a-b0bc-c0ff75b30575"
3-
Parent: "e41f99c3-6f9c-4676-8ab4-bd4693617d03"
2+
ID: "cccfbe6d-3527-427f-add7-4030518356af"
3+
Parent: "f574ec6f-90d7-4fa4-aedf-90aa70122162"
44
Template: "adb6ca4f-03ef-4f47-b9ac-9ce2ba53ff97"
5-
Path: /sitecore/content/Redirects/Imported Redirects/2020/02
5+
Path: /sitecore/content/Redirects/Imported Redirects/2020/03
66
DB: master
77
Languages:
88
- Language: en
@@ -11,4 +11,4 @@ Languages:
1111
Fields:
1212
- ID: "25bed78c-4957-4165-998a-ca1b52f67497"
1313
Hint: __Created
14-
Value: 20200207T080941Z
14+
Value: 20200319T080443Z

be/src/Unic.UrlMapper2.Integration.Website/serialization/Global Redirects/Redirects/Imported Redirects/2020/02/07.yml renamed to be/src/Unic.UrlMapper2.Integration.Website/serialization/Global Redirects/Redirects/Imported Redirects/2020/03/19.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
ID: "11b2bd61-fa99-4299-b09e-59d9f8da5c8d"
3-
Parent: "4eb55e10-5a46-4e1a-b0bc-c0ff75b30575"
2+
ID: "b20ecc4a-7632-4d99-baf9-b402c34c3f23"
3+
Parent: "cccfbe6d-3527-427f-add7-4030518356af"
44
Template: "adb6ca4f-03ef-4f47-b9ac-9ce2ba53ff97"
5-
Path: /sitecore/content/Redirects/Imported Redirects/2020/02/07
5+
Path: /sitecore/content/Redirects/Imported Redirects/2020/03/19
66
DB: master
77
Languages:
88
- Language: en
@@ -11,4 +11,4 @@ Languages:
1111
Fields:
1212
- ID: "25bed78c-4957-4165-998a-ca1b52f67497"
1313
Hint: __Created
14-
Value: 20200207T080941Z
14+
Value: 20200319T080443Z

0 commit comments

Comments
 (0)