Skip to content

Commit 82e5857

Browse files
authored
CG-5970: Cannot get accessToken (#40)
CG-5970: Cannot get accessToken --- ### Deployment: To apply changes and make it visible to customers, there are two parts that need to be deployed: * MF backend: need to merge this PR and then trigger the GitHub action * MF frontend: go to Vercel and update the environment variable. The frontend will be deployed automatically once the PR is merged to the `main` branch ### Changes * Add supported callback URL in MF backend. * Upgrade dependencies for MF backend. * Upgrade dependencies for MF frontend. * Remove redundant components. * Correct callback URL for EpiserverOIDCProvider. * Rotate AZURE_AD_CLIENT_SECRET for Azure AD in the local environment. ~### Issue~ ~There's one unresolved issue when building the source code:~ ~<img width="1234" alt="image" src="https://github.com/episerver/content-graph-js-sdk/assets/8802680/bbfe18f5-bf95-4494-a1b2-bda3848e8c9c">~ The issue is resolved by change typescript-react-query to typescript-graphql-request
1 parent 54cfdb5 commit 82e5857

File tree

19 files changed

+4043
-2862
lines changed

19 files changed

+4043
-2862
lines changed

.github/workflows/deploy-backend.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ jobs:
2727
repository: musicfestival
2828

2929
- name: Publish to Registry
30-
uses: elgohr/Publish-Docker-Github-Action@master
30+
uses: elgohr/Publish-Docker-Github-Action@v5
3131
with:
3232
name: musicfestival
3333
username: ${{ steps.ecr.outputs.username }}
3434
password: ${{ steps.ecr.outputs.password }}
3535
registry: musicfestivalacr.azurecr.io
3636
workdir: samples/musicfestival-backend-dotnet
37+
buildoptions: "--compress --force-rm"
3738
tags: "latest"

samples/musicfestival-backend-dotnet/MusicFestival.Backend.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="EPiServer.CMS" Version="12.22.4" />
11+
<PackageReference Include="EPiServer.CMS" Version="12.23.0" />
1212
<PackageReference Include="EPiServer.ContentDefinitionsApi" Version="3.9.0" />
1313
<PackageReference Include="EPiServer.ContentDeliveryApi.Cms" Version="3.9.0" />
14+
<PackageReference Include="EPiServer.ContentDeliveryApi.Core" Version="3.9.0" />
1415
<PackageReference Include="EPiServer.ContentManagementApi" Version="3.9.0" />
15-
<PackageReference Include="EPiServer.OpenIDConnect" Version="3.8.0" />
16-
<PackageReference Include="EPiServer.OpenIDConnect.UI" Version="3.8.0" />
16+
<PackageReference Include="EPiServer.OpenIDConnect" Version="3.9.0" />
17+
<PackageReference Include="EPiServer.OpenIDConnect.UI" Version="3.9.0" />
1718
<PackageReference Include="Optimizely.ContentGraph.Cms" Version="3.4.0" />
1819
</ItemGroup>
1920
</Project>

samples/musicfestival-backend-dotnet/Startup.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public void ConfigureServices(IServiceCollection services)
8787
new Uri(baseUri, "/"),
8888
new Uri(baseUri, "/login-callback"),
8989
new Uri(baseUri, "/login-renewal"),
90+
new Uri(baseUri, "/api/auth/callback/optimizely_cms"),
9091
},
9192
});
9293

@@ -147,7 +148,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
147148
app.UseStaticFiles();
148149
app.UseRouting();
149150
app.UseCors(b => b
150-
.WithOrigins(new[] { $"{_frontendUri}" })
151+
.WithOrigins(new[] { $"{_frontendUri}", "*" })
151152
.WithExposedContentDeliveryApiHeaders()
152153
.WithExposedContentDefinitionApiHeaders()
153154
.WithHeaders("Authorization")

samples/musicfestival-frontend-nextjs/.env.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
NEXTAUTH_URL=http://localhost:3000/
22
AZURE_AD_CLIENT_ID=355bdf4f-d596-4db7-8efe-8e3bc24a3611
3-
AZURE_AD_CLIENT_SECRET=dBo8Q~qaopwwO-O3gL_Hv58HQHTJ1faWPpFxudcl
3+
AZURE_AD_CLIENT_SECRET=eOn8Q~KxYudVYDmBs6OYYb9xolWvv~I1LdB1nbSc
44
AZURE_AD_TENANT_ID=7c4a1b79-4b8e-4ac7-b7e1-c5c3c5a4c139
55
OKTA_CLIENT_ID=0oa7c6ejkpzJ0CtcS1d7
66
OKTA_ISSUER=https://prep.login.optimizely.com

samples/musicfestival-frontend-nextjs/components/Login-Callback.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

samples/musicfestival-frontend-nextjs/components/LoginBtn.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { Session } from "next-auth"
22
import { useSession, signIn, signOut } from "next-auth/react"
33

4-
type ExtendedSession = Session & {
5-
token: any
4+
export type ExtendedSession = Session & {
5+
token?: any
66
}
77

88
export default function Component() {
9-
const { data: session } = useSession()
9+
const { data: session, status } = useSession()
1010
const extendedSession: ExtendedSession = session as ExtendedSession
11-
if (extendedSession) {
11+
if (extendedSession && status === "authenticated") {
12+
const userName = extendedSession.token?.user?.name || extendedSession.token?.name
1213
return (
1314
<div className="btn">
14-
<button onClick={() => signOut()}>{extendedSession.token?.token?.user?.name}</button>
15+
<button onClick={() => signOut()}>{userName}</button>
1516
</div>
1617
)
1718
}

samples/musicfestival-frontend-nextjs/components/PageComponent/LandingPageComponent.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function LandingPage({ content }: LandingPageProps) {
2929
(() => {
3030
const contentItem = mainContentAreaItem?.ContentLink?.Expanded
3131
if (contentItem?.__typename === "ImageFile") {
32-
console.log('contentItem', contentItem?.Url)
3332
return (
3433
<div className="Grid-cell u-md-size1of2" key={mainContentAreaItemIdx}>
3534
<div className="Page-container ImageFile">

samples/musicfestival-frontend-nextjs/components/PageComponent/LoginCallbackPageComponent.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)