Skip to content

Implements preview tokens #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>MusicFestival.Backend</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EPiServer.CMS" Version="12.23.0" />
<PackageReference Include="EPiServer.ContentDefinitionsApi" Version="3.9.0" />
<PackageReference Include="EPiServer.ContentDeliveryApi.Cms" Version="3.9.0" />
<PackageReference Include="EPiServer.OpenIDConnect" Version="3.9.0" />
<PackageReference Include="EPiServer.OpenIDConnect.UI" Version="3.9.0" />
<PackageReference Include="EPiServer.CMS" Version="12.32.5" />
<PackageReference Include="EPiServer.ContentDeliveryApi.Cms" Version="3.12.2" />
</ItemGroup>

</Project>
40 changes: 4 additions & 36 deletions samples/music-festival-vue-decoupled/backend/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
using EPiServer.Cms.UI.AspNetIdentity;
using EPiServer.ContentApi.Cms;
using EPiServer.ContentApi.Core.DependencyInjection;
using EPiServer.ContentDefinitionsApi;
using EPiServer.Core;
using EPiServer.OpenIDConnect;
using EPiServer.Security;
using EPiServer.ServiceLocation;
using EPiServer.Web;
using EPiServer.Web.Routing;
Expand Down Expand Up @@ -41,39 +40,9 @@ public void ConfigureServices(IServiceCollection services)
.Add("narrow", "Narrow", "u-md-size1of3", string.Empty, "epi-icon__layout--one-third");
});

services.AddOpenIDConnect<ApplicationUser>(
useDevelopmentCertificate: true,
signingCertificate: null,
encryptionCertificate: null,
createSchema: true,
options =>
{
options.RequireHttps = !_webHostingEnvironment.IsDevelopment();

options.Applications.Add(new OpenIDConnectApplication
{
ClientId = "frontend",
Scopes = { "openid", "offline_access", "profile", "email", "roles", ContentDeliveryApiOptionsDefaults.Scope },
PostLogoutRedirectUris = { _frontendUri },
RedirectUris =
{
new Uri(_frontendUri, "/login-callback"),
new Uri(_frontendUri, "/login-renewal"),
},
});

options.Applications.Add(new OpenIDConnectApplication
{
ClientId = "cli",
ClientSecret = "cli",
Scopes = { ContentDefinitionsApiOptionsDefaults.Scope },
});
});

services.AddOpenIDConnectUI();
services.Configure<UIOptions>(options => options.UsePreviewTokens = true);

services.AddContentDefinitionsApi(OpenIDConnectOptionsDefaults.AuthenticationScheme);
services.AddContentDeliveryApi(OpenIDConnectOptionsDefaults.AuthenticationScheme);
services.AddContentDeliveryApi(PreviewTokenOptions.SchemeName);
services.ConfigureForContentDeliveryClient();

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

app.UseCors(b => b
.WithOrigins(new[] { "http://localhost:8080" })
.WithOrigins(["http://localhost:8080"])
.WithExposedContentDeliveryApiHeaders()
.WithExposedContentDefinitionApiHeaders()
.WithHeaders("Authorization")
.AllowAnyMethod()
.AllowCredentials());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"MusicFestival.Backend": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:8081",
"launchUrl": "episerver/cms",
Expand All @@ -11,4 +11,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
VUE_APP_CONTENT_DELIVERY_API=http://localhost:8081
VUE_APP_LOGIN_AUTHORITY=http://localhost:8081
VUE_APP_LOGIN_CLIENT_ID=frontend
VUE_APP_CONTENT_DELIVERY_API=http://localhost:8081
4 changes: 1 addition & 3 deletions samples/music-festival-vue-decoupled/frontend/.env.test
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
VUE_APP_CONTENT_DELIVERY_API=http://localhost:8081
VUE_APP_LOGIN_AUTHORITY=http://localhost:8081
VUE_APP_LOGIN_CLIENT_ID=frontend
VUE_APP_CONTENT_DELIVERY_API=http://localhost:8081
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.Build.NoTargets/3.0.4">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<EnableNETAnalyzers>false</EnableNETAnalyzers>
Expand Down
Loading