EUROPE'S LEADING AEM DEVELOPER CONFERENCE
28th - 30th SEPTEMBER 2020
Escape the defaults
Configuring Sling to behave like AEM as a Cloud Service
Robert Munteanu, Adobe
Slides revision: 20200827-b88ebd4
1
About me
2
Outline
Why change the defaults?
Separation of content and apps
Principal-based authentication
Pre-authenticating system users
Removing the OSGi installer
Demo
3
Why change the defaults?
4
One size does not fit allOne size does not fit allOne size does not fit allOne size does not fit allOne size does not fit all
Sling does not prescribe how to deploySling does not prescribe how to deploySling does not prescribe how to deploySling does not prescribe how to deploySling does not prescribe how to deploy
configurationsconfigurationsconfigurationsconfigurationsconfigurations
Sling does not prescribe how to deploy codeSling does not prescribe how to deploy codeSling does not prescribe how to deploy codeSling does not prescribe how to deploy codeSling does not prescribe how to deploy code
Sling does not enforce separation of content andSling does not enforce separation of content andSling does not enforce separation of content andSling does not enforce separation of content andSling does not enforce separation of content and
codecodecodecodecode
Sling does not choose a persistence mechansimSling does not choose a persistence mechansimSling does not choose a persistence mechansimSling does not choose a persistence mechansimSling does not choose a persistence mechansim
for youfor youfor youfor youfor you
5
CRX DE Lite is a development toolCRX DE Lite is a development toolCRX DE Lite is a development toolCRX DE Lite is a development toolCRX DE Lite is a development tool
Ask it...Ask it...Ask it...Ask it...Ask it...
 What ACEs are defined for this node?What ACEs are defined for this node?What ACEs are defined for this node?What ACEs are defined for this node?What ACEs are defined for this node?
 What is content structure of the repository?What is content structure of the repository?What is content structure of the repository?What is content structure of the repository?What is content structure of the repository?
But not...But not...But not...But not...But not...
 What revision of the code am I running?What revision of the code am I running?What revision of the code am I running?What revision of the code am I running?What revision of the code am I running?
 Do I have the same code version on allDo I have the same code version on allDo I have the same code version on allDo I have the same code version on allDo I have the same code version on all
instances?instances?instances?instances?instances?
 How can I deploy a quick fix in production?How can I deploy a quick fix in production?How can I deploy a quick fix in production?How can I deploy a quick fix in production?How can I deploy a quick fix in production?
6
Better ways of asking ...
$ kubectl describe deployment sling-starter
Containers:
main:
Image: apache/sling-starter:1.0-cafebafe
$ kubectl apply -f deployments/sling-starter.yaml
$ rpm -q sling-starter
sling-starter-1.0_cafebabe-1.noarch
$ rpm -Uvh sling-start-1.1_sodadude-1.noarch
$ curl http://sling-starter.example.org/version
1.0-cafebabe
7
Prevent mistakes
8
Separation of content and apps
9
The composite node store
Clear separation of code from
content
Enforces read-only status of
code and (mostly) configuration
Allows swapping in a separate
node store (with restart)
10
Generating /libs and /apps
Must be a NodeStore
Must reflect the state of the deployment:
Nodes
Principals
Indexes
Access Control entries
Coming from:
Repoinit
Content Packages
Sling Content Loader
Java code - Bundle Activator, Install Hooks, ... 11
Generating /libs and /appsGenerating /libs and /appsGenerating /libs and /appsGenerating /libs and /appsGenerating /libs and /apps
Start SlingStart SlingStart SlingStart SlingStart Sling
Wait for it to be (System) ReadyWait for it to be (System) ReadyWait for it to be (System) ReadyWait for it to be (System) ReadyWait for it to be (System) Ready
Stop SlingStop SlingStop SlingStop SlingStop Sling
Save the repositorySave the repositorySave the repositorySave the repositorySave the repository
12
Principal-based authentication
13
Resource-based authentication
14
Principal-based authentication
15
Benefits
Easy to inspect access control entries for a given
principal
Access control entries independent of the
existence of their target
Much simpler packaging story in content
packages
16
Usage
FileVault
rep:PrincipalBasedMixin
rep:PrincipalPolicy
rep:PrincipalEntry
Repoinit
create service user sling-readall with path system/sling
set principal ACL for sling-readall
allow jcr:read on /
end
17
Pre-authenticating system users
18
Reminder: loginAdministrative
19
Reminder: service user mappings
// uses bundle name, no subservice, default workspace
slingRepository.loginService(null, null);
// uses bundle name, 'scripts' subservice, default workspace
slingRepository.loginService("scripts", null);
"o.a.s.....ServiceUserMapperImpl.amended~i18n":{
"user.mapping":[
"org.apache.sling.i18n=sling-i18n"
]
},
"o.a.s.....ServiceUserMapperImpl.amended~servletsresolver":{
"user.mapping":[
"o.a.s.servlets.resolver:console=sling-readall",
"o.a.s.servlets.resolver:scripts=sling-scripting"
]
}
20
Duplicated system user privileges
set ACL for sling-mapping
allow jcr:read on /
end
set ACL for sling-i18n
allow jcr:read on /
end
set ACL for sling-jcr-install
allow jcr:read on /
allow rep:write on /apps/sling/install
end
21
Pre-authenticated loginPre-authenticated loginPre-authenticated loginPre-authenticated loginPre-authenticated login
Supply all principals at login in timeSupply all principals at login in timeSupply all principals at login in timeSupply all principals at login in timeSupply all principals at login in time
Faster by skipping authenticationFaster by skipping authenticationFaster by skipping authenticationFaster by skipping authenticationFaster by skipping authentication
Allows mapping a service to multiple usersAllows mapping a service to multiple usersAllows mapping a service to multiple usersAllows mapping a service to multiple usersAllows mapping a service to multiple users
22
Pre-authenticated system users
create service user sling-readall
set ACL for sling-readall
allow jcr:read on /
end
create service user sling-jcr-install
set ACL for sling-jcr-install
allow rep:write on /apps/sling/install
end
"o.a.s.....ServiceUserMapperImpl.amended~i18n":{
"user.mapping":[
"org.apache.sling.i18n=[sling-readall]"
]
}, "o.a.s.....ServiceUserMapperImpl.amended~~jcr-install":{
"user.mapping":[
"o.a.s.installer.provider.jcr=[sling-jcr-install,⏎
sling-readall]"
]
}
23
Removing the OSGi installer
24
The OSGi installer...The OSGi installer...The OSGi installer...The OSGi installer...The OSGi installer...
installsinstallsinstallsinstallsinstalls
bundlesbundlesbundlesbundlesbundles
configurationsconfigurationsconfigurationsconfigurationsconfigurations
content packagescontent packagescontent packagescontent packagescontent packages
fromfromfromfromfrom
filesystemfilesystemfilesystemfilesystemfilesystem
launchpadlaunchpadlaunchpadlaunchpadlaunchpad
JCR repositoryJCR repositoryJCR repositoryJCR repositoryJCR repository
25
The OSGi installer...
is a dynamic component
reconciles application state from multiple
sources
is not needed in a statically defined/immutable
application
... we are buiding immutable applications
26
FM: Installing bundles
{
"bundles":[
{
"id":"org.apache.aries:org.apache.aries.util:1.1.3",
"start-order":"1"
}
]
}
27
FM: Installing configurations
{
"configurations": {
"o.a.s.jcr.davex.impl.servlets.SlingDavExServlet":{
"alias":"/server"
}
}
}
28
FM: Installing content packages
 content packages are by default
forwarded to the OSGi installer
{
"content-packages:ARTIFACTS|true": [
"o.a.s:sling-slingshot-apps-pkg:zip:1.0-SNAPSHOT",
"o.a.s:sling-slingshot-content-pkg:zip:1.0-SNAPSHOT"
]
}
<workspaceFilter version="1.0">
<filter root="/libs/slingshot/config"/>
<filter root="/apps/bundles/install/bundle.jar"/>
</workspaceFilter>
29
Content Package to Feature Model
Handles nested artifacts inside content
packages
OSGi bundles
OSGi configurations
Other content packages
Converts access control configurations
System Users
Access control entries (resource-based)
No support for principal-based access control
entries 30
Conversion result
{
"id":"o.a.s:sling-slingshot-apps-pkg:slingosgifeature:1.0",
"bundles":[
"o.a.s:o.a.s.sample.slingshot:0.9.1"
], "configurations": {
"o.a.s....ServiceUserMapperImpl.amended~slingshot": {
"o.a.s.sample.slingshot=[slingshot-service]"
}
}, "content-packages:ARTIFACTS|true":[
"o.a.s:sling-slingshot-apps-pkg:zip:cp2fm-converted:1.0"
], "repoinit:TEXT|true":[
"create service user slingshot-service"
]
}
31
Alternative Package Registry
o.a.j.vault....FSPackageRegistry
Stores packages in the filesystem
Can be assembled without a JCR repository
Relies on an existing execution plan
Plan prepared by the Sling Content Deployment
Extension
32
Demo
33
Demo recap
Sling Docker image using
the feature model
the composite node store
Docker updates
done with a simple restart
preserving the 'content' part of the repository
Removing the OSGi installer using the content-
package converter
34
Resources
(Sling) Content Package to Feature Model
Converter
(Sling) Content Deployment Extension
(Oak) Composite Node Store
(Oak) Principal-Based Authentication
(Oak) Pre-Authenticated Login
35

Escape the defaults - Configure Sling like AEM as a Cloud Service

  • 1.
    EUROPE'S LEADING AEMDEVELOPER CONFERENCE 28th - 30th SEPTEMBER 2020 Escape the defaults Configuring Sling to behave like AEM as a Cloud Service Robert Munteanu, Adobe Slides revision: 20200827-b88ebd4 1
  • 2.
  • 3.
    Outline Why change thedefaults? Separation of content and apps Principal-based authentication Pre-authenticating system users Removing the OSGi installer Demo 3
  • 4.
    Why change thedefaults? 4
  • 5.
    One size doesnot fit allOne size does not fit allOne size does not fit allOne size does not fit allOne size does not fit all Sling does not prescribe how to deploySling does not prescribe how to deploySling does not prescribe how to deploySling does not prescribe how to deploySling does not prescribe how to deploy configurationsconfigurationsconfigurationsconfigurationsconfigurations Sling does not prescribe how to deploy codeSling does not prescribe how to deploy codeSling does not prescribe how to deploy codeSling does not prescribe how to deploy codeSling does not prescribe how to deploy code Sling does not enforce separation of content andSling does not enforce separation of content andSling does not enforce separation of content andSling does not enforce separation of content andSling does not enforce separation of content and codecodecodecodecode Sling does not choose a persistence mechansimSling does not choose a persistence mechansimSling does not choose a persistence mechansimSling does not choose a persistence mechansimSling does not choose a persistence mechansim for youfor youfor youfor youfor you 5
  • 6.
    CRX DE Liteis a development toolCRX DE Lite is a development toolCRX DE Lite is a development toolCRX DE Lite is a development toolCRX DE Lite is a development tool Ask it...Ask it...Ask it...Ask it...Ask it...  What ACEs are defined for this node?What ACEs are defined for this node?What ACEs are defined for this node?What ACEs are defined for this node?What ACEs are defined for this node?  What is content structure of the repository?What is content structure of the repository?What is content structure of the repository?What is content structure of the repository?What is content structure of the repository? But not...But not...But not...But not...But not...  What revision of the code am I running?What revision of the code am I running?What revision of the code am I running?What revision of the code am I running?What revision of the code am I running?  Do I have the same code version on allDo I have the same code version on allDo I have the same code version on allDo I have the same code version on allDo I have the same code version on all instances?instances?instances?instances?instances?  How can I deploy a quick fix in production?How can I deploy a quick fix in production?How can I deploy a quick fix in production?How can I deploy a quick fix in production?How can I deploy a quick fix in production? 6
  • 7.
    Better ways ofasking ... $ kubectl describe deployment sling-starter Containers: main: Image: apache/sling-starter:1.0-cafebafe $ kubectl apply -f deployments/sling-starter.yaml $ rpm -q sling-starter sling-starter-1.0_cafebabe-1.noarch $ rpm -Uvh sling-start-1.1_sodadude-1.noarch $ curl http://sling-starter.example.org/version 1.0-cafebabe 7
  • 8.
  • 9.
  • 10.
    The composite nodestore Clear separation of code from content Enforces read-only status of code and (mostly) configuration Allows swapping in a separate node store (with restart) 10
  • 11.
    Generating /libs and/apps Must be a NodeStore Must reflect the state of the deployment: Nodes Principals Indexes Access Control entries Coming from: Repoinit Content Packages Sling Content Loader Java code - Bundle Activator, Install Hooks, ... 11
  • 12.
    Generating /libs and/appsGenerating /libs and /appsGenerating /libs and /appsGenerating /libs and /appsGenerating /libs and /apps Start SlingStart SlingStart SlingStart SlingStart Sling Wait for it to be (System) ReadyWait for it to be (System) ReadyWait for it to be (System) ReadyWait for it to be (System) ReadyWait for it to be (System) Ready Stop SlingStop SlingStop SlingStop SlingStop Sling Save the repositorySave the repositorySave the repositorySave the repositorySave the repository 12
  • 13.
  • 14.
  • 15.
  • 16.
    Benefits Easy to inspectaccess control entries for a given principal Access control entries independent of the existence of their target Much simpler packaging story in content packages 16
  • 17.
    Usage FileVault rep:PrincipalBasedMixin rep:PrincipalPolicy rep:PrincipalEntry Repoinit create service usersling-readall with path system/sling set principal ACL for sling-readall allow jcr:read on / end 17
  • 18.
  • 19.
  • 20.
    Reminder: service usermappings // uses bundle name, no subservice, default workspace slingRepository.loginService(null, null); // uses bundle name, 'scripts' subservice, default workspace slingRepository.loginService("scripts", null); "o.a.s.....ServiceUserMapperImpl.amended~i18n":{ "user.mapping":[ "org.apache.sling.i18n=sling-i18n" ] }, "o.a.s.....ServiceUserMapperImpl.amended~servletsresolver":{ "user.mapping":[ "o.a.s.servlets.resolver:console=sling-readall", "o.a.s.servlets.resolver:scripts=sling-scripting" ] } 20
  • 21.
    Duplicated system userprivileges set ACL for sling-mapping allow jcr:read on / end set ACL for sling-i18n allow jcr:read on / end set ACL for sling-jcr-install allow jcr:read on / allow rep:write on /apps/sling/install end 21
  • 22.
    Pre-authenticated loginPre-authenticated loginPre-authenticatedloginPre-authenticated loginPre-authenticated login Supply all principals at login in timeSupply all principals at login in timeSupply all principals at login in timeSupply all principals at login in timeSupply all principals at login in time Faster by skipping authenticationFaster by skipping authenticationFaster by skipping authenticationFaster by skipping authenticationFaster by skipping authentication Allows mapping a service to multiple usersAllows mapping a service to multiple usersAllows mapping a service to multiple usersAllows mapping a service to multiple usersAllows mapping a service to multiple users 22
  • 23.
    Pre-authenticated system users createservice user sling-readall set ACL for sling-readall allow jcr:read on / end create service user sling-jcr-install set ACL for sling-jcr-install allow rep:write on /apps/sling/install end "o.a.s.....ServiceUserMapperImpl.amended~i18n":{ "user.mapping":[ "org.apache.sling.i18n=[sling-readall]" ] }, "o.a.s.....ServiceUserMapperImpl.amended~~jcr-install":{ "user.mapping":[ "o.a.s.installer.provider.jcr=[sling-jcr-install,⏎ sling-readall]" ] } 23
  • 24.
    Removing the OSGiinstaller 24
  • 25.
    The OSGi installer...TheOSGi installer...The OSGi installer...The OSGi installer...The OSGi installer... installsinstallsinstallsinstallsinstalls bundlesbundlesbundlesbundlesbundles configurationsconfigurationsconfigurationsconfigurationsconfigurations content packagescontent packagescontent packagescontent packagescontent packages fromfromfromfromfrom filesystemfilesystemfilesystemfilesystemfilesystem launchpadlaunchpadlaunchpadlaunchpadlaunchpad JCR repositoryJCR repositoryJCR repositoryJCR repositoryJCR repository 25
  • 26.
    The OSGi installer... isa dynamic component reconciles application state from multiple sources is not needed in a statically defined/immutable application ... we are buiding immutable applications 26
  • 27.
  • 28.
    FM: Installing configurations { "configurations":{ "o.a.s.jcr.davex.impl.servlets.SlingDavExServlet":{ "alias":"/server" } } } 28
  • 29.
    FM: Installing contentpackages  content packages are by default forwarded to the OSGi installer { "content-packages:ARTIFACTS|true": [ "o.a.s:sling-slingshot-apps-pkg:zip:1.0-SNAPSHOT", "o.a.s:sling-slingshot-content-pkg:zip:1.0-SNAPSHOT" ] } <workspaceFilter version="1.0"> <filter root="/libs/slingshot/config"/> <filter root="/apps/bundles/install/bundle.jar"/> </workspaceFilter> 29
  • 30.
    Content Package toFeature Model Handles nested artifacts inside content packages OSGi bundles OSGi configurations Other content packages Converts access control configurations System Users Access control entries (resource-based) No support for principal-based access control entries 30
  • 31.
    Conversion result { "id":"o.a.s:sling-slingshot-apps-pkg:slingosgifeature:1.0", "bundles":[ "o.a.s:o.a.s.sample.slingshot:0.9.1" ], "configurations":{ "o.a.s....ServiceUserMapperImpl.amended~slingshot": { "o.a.s.sample.slingshot=[slingshot-service]" } }, "content-packages:ARTIFACTS|true":[ "o.a.s:sling-slingshot-apps-pkg:zip:cp2fm-converted:1.0" ], "repoinit:TEXT|true":[ "create service user slingshot-service" ] } 31
  • 32.
    Alternative Package Registry o.a.j.vault....FSPackageRegistry Storespackages in the filesystem Can be assembled without a JCR repository Relies on an existing execution plan Plan prepared by the Sling Content Deployment Extension 32
  • 33.
  • 34.
    Demo recap Sling Dockerimage using the feature model the composite node store Docker updates done with a simple restart preserving the 'content' part of the repository Removing the OSGi installer using the content- package converter 34
  • 35.
    Resources (Sling) Content Packageto Feature Model Converter (Sling) Content Deployment Extension (Oak) Composite Node Store (Oak) Principal-Based Authentication (Oak) Pre-Authenticated Login 35