Skip to content

Commit 67bf8bd

Browse files
Merge pull request #40 from episerver/feature/preview-token
Implements preview tokens
2 parents 2d73b6d + d8f7c5b commit 67bf8bd

File tree

21 files changed

+6748
-10781
lines changed

21 files changed

+6748
-10781
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Users referenced in this file will automatically be requested as reviewers for PRs that modify the given paths.
2+
23
# See https://help.github.com/articles/about-code-owners/
34

45
# Default owners for everything in this repo
5-
* @hennys @shahramshahram @johanpetersson @jbearfoot @pergunsarfs @tidyui
6+
7+
- @episerver/cms-delivery

samples/music-festival-vue-decoupled/README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,41 @@ Content is fetched from Optimizely using the Content Delivery API: https://world
99
## Prerequisites
1010

1111
This project uses:
12-
* Node.js 18+
13-
* .NET SDK 6+
14-
* SQL Server 2016 Express LocalDB ([download here](https://www.microsoft.com/en-us/sql-server/sql-server-downloads))
12+
13+
- Node.js 18+
14+
- .NET SDK 9+
15+
- SQL Server 2016 Express LocalDB ([download here](https://www.microsoft.com/en-us/sql-server/sql-server-downloads))
1516

1617
## Setup and Run
1718

1819
1. Run `setup.cmd`. You can re-run `setup.cmd` at any time to reset the backend with a fresh database.
1920
2. Open terminal for `./backend` and run `dotnet run`.
20-
* Navigate to http://localhost:8081/.
21-
* Create an admin user. If the UI is not displayed automatically, navigate to http://localhost:8081/util/register.
22-
* Now you can access http://localhost:8081/episerver/cms.
21+
- Navigate to http://localhost:8081/.
22+
- Create an admin user. If the UI is not displayed automatically, navigate to http://localhost:8081/util/register.
23+
- Now you can access http://localhost:8081/episerver/cms.
2324
3. Since we reference two NPM modules locally, we need to install them first (this is not needed if you install the modules from npmjs.com).
24-
* Open terminal for `../../src/@episerver/content-definitions` and run `npm install` (only needed first run).
25-
* Open terminal for `../../src/@episerver/content-delivery` and run `npm install` (only needed first run).
25+
- Open terminal for `../../src/@episerver/content-definitions` and run `npm install` (only needed first run).
26+
- Open terminal for `../../src/@episerver/content-delivery` and run `npm install` (only needed first run).
2627
4. Open terminal for `./frontend` and run `npm install` (only needed first run).
27-
* Run `npm run serve`.
28-
* Navigate to http://localhost:8080/.
28+
- Run `npm run serve`.
29+
- Navigate to http://localhost:8080/.
2930

3031
## Notable files
3132

3233
### Vuex store modules
3334

34-
* [epiContext.js](frontend/src/store/modules/epiContext.js): makes `inEditMode` and `isEditable` flags available to the OPE helpers.
35-
* [epiDataModel.js](frontend/src/store/modules/epiDataModel.js): the module that stores and updates the model object to be displayed on every component.
35+
- [epiContext.js](frontend/src/store/modules/epiContext.js): makes `inEditMode` and `isEditable` flags available to the OPE helpers.
36+
- [epiDataModel.js](frontend/src/store/modules/epiDataModel.js): the module that stores and updates the model object to be displayed on every component.
3637

3738
### On-Page Editing helpers
3839

39-
* [epiBootstrap.js](frontend/src/epiBootstrap.js): registers the `contentSaved` and `epiReady` message handlers that updates the vuex store.
40-
* [epiEdit.js](frontend/src/directives/epiEdit.js): a directive that can be added on components to make them optionally editable (e.g. `<span v-epi-edit="Name">`), through `isEditable` and `epiDisableEditing`.
41-
* [EpiProperty.vue](frontend/src/components/EpiProperty.vue): a component that renders a button to edit a property (e.g. `<epi-property property-name="Name">`).
40+
- [epiBootstrap.js](frontend/src/epiBootstrap.js): registers the `contentSaved` and `epiReady` message handlers that updates the vuex store.
41+
- [epiEdit.js](frontend/src/directives/epiEdit.js): a directive that can be added on components to make them optionally editable (e.g. `<span v-epi-edit="Name">`), through `isEditable` and `epiDisableEditing`.
42+
- [EpiProperty.vue](frontend/src/components/EpiProperty.vue): a component that renders a button to edit a property (e.g. `<epi-property property-name="Name">`).
4243

4344
### Routing helpers
4445

45-
* [EpiPageComponentSelector.vue](frontend/src/components/EpiPageComponentSelector.vue): loads the Vue page component and owns its model.
46-
* [EpiBlockComponentSelector.vue](frontend/src/components/EpiBlockComponentSelector.vue): loads the Vue block component.
47-
* [EpiLink.vue](frontend/src/components/EpiLink.vue): regular links when in OPE and Vue router links otherwise.
48-
* [EpiViewModeLink.vue](frontend/src/components/EpiViewModeLink.vue): disables links completely when in OPE.
46+
- [EpiPageComponentSelector.vue](frontend/src/components/EpiPageComponentSelector.vue): loads the Vue page component and owns its model.
47+
- [EpiBlockComponentSelector.vue](frontend/src/components/EpiBlockComponentSelector.vue): loads the Vue block component.
48+
- [EpiLink.vue](frontend/src/components/EpiLink.vue): regular links when in OPE and Vue router links otherwise.
49+
- [EpiViewModeLink.vue](frontend/src/components/EpiViewModeLink.vue): disables links completely when in OPE.
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<RootNamespace>MusicFestival.Backend</RootNamespace>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="EPiServer.CMS" Version="12.23.0" />
12-
<PackageReference Include="EPiServer.ContentDefinitionsApi" Version="3.9.0" />
13-
<PackageReference Include="EPiServer.ContentDeliveryApi.Cms" Version="3.9.0" />
14-
<PackageReference Include="EPiServer.OpenIDConnect" Version="3.9.0" />
15-
<PackageReference Include="EPiServer.OpenIDConnect.UI" Version="3.9.0" />
11+
<PackageReference Include="EPiServer.CMS" Version="12.32.5" />
12+
<PackageReference Include="EPiServer.ContentDeliveryApi.Cms" Version="3.12.2" />
1613
</ItemGroup>
1714

1815
</Project>

samples/music-festival-vue-decoupled/backend/Startup.cs

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
using EPiServer.Cms.UI.AspNetIdentity;
33
using EPiServer.ContentApi.Cms;
44
using EPiServer.ContentApi.Core.DependencyInjection;
5-
using EPiServer.ContentDefinitionsApi;
65
using EPiServer.Core;
7-
using EPiServer.OpenIDConnect;
6+
using EPiServer.Security;
87
using EPiServer.ServiceLocation;
98
using EPiServer.Web;
109
using EPiServer.Web.Routing;
@@ -41,39 +40,9 @@ public void ConfigureServices(IServiceCollection services)
4140
.Add("narrow", "Narrow", "u-md-size1of3", string.Empty, "epi-icon__layout--one-third");
4241
});
4342

44-
services.AddOpenIDConnect<ApplicationUser>(
45-
useDevelopmentCertificate: true,
46-
signingCertificate: null,
47-
encryptionCertificate: null,
48-
createSchema: true,
49-
options =>
50-
{
51-
options.RequireHttps = !_webHostingEnvironment.IsDevelopment();
52-
53-
options.Applications.Add(new OpenIDConnectApplication
54-
{
55-
ClientId = "frontend",
56-
Scopes = { "openid", "offline_access", "profile", "email", "roles", ContentDeliveryApiOptionsDefaults.Scope },
57-
PostLogoutRedirectUris = { _frontendUri },
58-
RedirectUris =
59-
{
60-
new Uri(_frontendUri, "/login-callback"),
61-
new Uri(_frontendUri, "/login-renewal"),
62-
},
63-
});
64-
65-
options.Applications.Add(new OpenIDConnectApplication
66-
{
67-
ClientId = "cli",
68-
ClientSecret = "cli",
69-
Scopes = { ContentDefinitionsApiOptionsDefaults.Scope },
70-
});
71-
});
72-
73-
services.AddOpenIDConnectUI();
43+
services.Configure<UIOptions>(options => options.UsePreviewTokens = true);
7444

75-
services.AddContentDefinitionsApi(OpenIDConnectOptionsDefaults.AuthenticationScheme);
76-
services.AddContentDeliveryApi(OpenIDConnectOptionsDefaults.AuthenticationScheme);
45+
services.AddContentDeliveryApi(PreviewTokenOptions.SchemeName);
7746
services.ConfigureForContentDeliveryClient();
7847

7948
services.AddHostedService<ProvisionDatabase>();
@@ -90,9 +59,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
9059
app.UseRouting();
9160

9261
app.UseCors(b => b
93-
.WithOrigins(new[] { "http://localhost:8080" })
62+
.WithOrigins(["http://localhost:8080"])
9463
.WithExposedContentDeliveryApiHeaders()
95-
.WithExposedContentDefinitionApiHeaders()
9664
.WithHeaders("Authorization")
9765
.AllowAnyMethod()
9866
.AllowCredentials());

samples/music-festival-vue-decoupled/backend/properties/launchSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"MusicFestival.Backend": {
44
"commandName": "Project",
5-
"dotnetRunMessages": "true",
5+
"dotnetRunMessages": true,
66
"launchBrowser": true,
77
"applicationUrl": "http://localhost:8081",
88
"launchUrl": "episerver/cms",
@@ -11,4 +11,4 @@
1111
}
1212
}
1313
}
14-
}
14+
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
VUE_APP_CONTENT_DELIVERY_API=http://localhost:8081
2-
VUE_APP_LOGIN_AUTHORITY=http://localhost:8081
3-
VUE_APP_LOGIN_CLIENT_ID=frontend
1+
VUE_APP_CONTENT_DELIVERY_API=http://localhost:8081
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
VUE_APP_CONTENT_DELIVERY_API=http://localhost:8081
2-
VUE_APP_LOGIN_AUTHORITY=http://localhost:8081
3-
VUE_APP_LOGIN_CLIENT_ID=frontend
1+
VUE_APP_CONTENT_DELIVERY_API=http://localhost:8081

samples/music-festival-vue-decoupled/frontend/MusicFestival.Frontend.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.Build.NoTargets/3.0.4">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
66
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
77
<EnableNETAnalyzers>false</EnableNETAnalyzers>

0 commit comments

Comments
 (0)