-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from danskernesdigitalebibliotek/DDFBRA-97-fro…
…ntend-hent-konfig-objekt-fra-backend-og-persister-i-applikationen_config-loading-in-go-config Move dplcms config loading to the config system
- Loading branch information
Showing
20 changed files
with
310 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
NEXT_PUBLIC_GRAPHQL_SCHEMA_ENDPOINT_DPL_CMS=http://dapple-cms.docker/graphql | ||
NEXT_PUBLIC_GRAPHQL_BASIC_TOKEN_DPL_CMS=Z3JhcGhxbF9jb25zdW1lcjp0ZXN0 | ||
|
||
NEXT_PUBLIC_GRAPHQL_SCHEMA_ENDPOINT_FBI=https://temp.fbi-api.dbc.dk/ereolgo/graphql | ||
// WILL BE REPLACED WITH DYNAMIC TOKEN | ||
NEXT_PUBLIC_LIBRARY_TOKEN=XXX | ||
NEXT_PUBLIC_APP_URL=http://localhost:3000 | ||
|
||
UNILOGIN_BASIC_AUTH_HEADER=XXX | ||
UNILOGIN_SESSION_SECRET=XXX | ||
|
||
UNILOGIN_API_URL=https://et-broker.unilogin.dk | ||
UNILOGIN_WELKNOWN_URL=https://et-broker.unilogin.dk/auth/realms/broker/.well-known/openid-configuration | ||
UNILOGIN_REFRESH_TOKEN_URL=https://et-broker.unilogin.dk/auth/realms/broker/protocol/openid-connect/token | ||
UNILOGIN_CLIENT_ID=https://stg.ereolengo.itkdev.dk/ | ||
UNILOGIN_CLIENT_SECRET=XXX | ||
UNILOGIN_SESSION_SECRET=ZIKj+BiUbpitnDO8TeptXnQKsZmh2uGHMR1Wd4GplhE= | ||
|
||
NEXT_PUBLIC_APP_URL=https://localhost:3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,39 @@ | ||
import { generators } from "openid-client" | ||
|
||
import { getUniloginClient } from "@/lib/session/oauth/uniloginClient" | ||
import { | ||
getOpenIdClientUniloginClientConfig, | ||
getUniloginClient, | ||
} from "@/lib/session/oauth/uniloginClient" | ||
import { getSession } from "@/lib/session/session" | ||
|
||
export const revalidate = 1 | ||
|
||
export async function GET() { | ||
const configResponse = await fetch(`${process.env.NEXT_PUBLIC_APP_URL}/auth/config`) | ||
if (!configResponse.ok) { | ||
throw new Error("Failed to fetch config") | ||
} | ||
const config = await configResponse.json() | ||
const uniloginConfig = config?.dplConfiguration?.unilogin | ||
|
||
const session = await getSession() | ||
session.code_verifier = generators.codeVerifier() | ||
|
||
const client = await getUniloginClient({ | ||
client_id: uniloginConfig.unilogin_api_client_id, | ||
client_secret: uniloginConfig.unilogin_api_client_secret, | ||
redirect_uri: `${process.env.NEXT_PUBLIC_APP_URL}/auth/callback/unilogin`, | ||
wellKnownUrl: uniloginConfig.unilogin_api_wellknown_url, | ||
}) | ||
session.code_verifier = generators.codeVerifier() | ||
|
||
const code_challenge = generators.codeChallenge(session.code_verifier) | ||
|
||
const openIdClientConfig = await getOpenIdClientUniloginClientConfig() | ||
|
||
if ( | ||
!openIdClientConfig || | ||
!openIdClientConfig.scope || | ||
!openIdClientConfig.redirect_uri || | ||
!openIdClientConfig.audience | ||
) { | ||
throw new Error("Unilogin client config is invalid.") | ||
} | ||
|
||
const client = await getUniloginClient() | ||
|
||
const url = client.authorizationUrl({ | ||
scope: "openid", | ||
audience: process.env.UNILOGIN_API_URL, | ||
redirect_uri: `${process.env.NEXT_PUBLIC_APP_URL}/auth/callback/unilogin`, | ||
scope: openIdClientConfig.scope, | ||
audience: openIdClientConfig.audience, | ||
redirect_uri: openIdClientConfig.redirect_uri, | ||
code_challenge, | ||
code_challenge_method: "S256", | ||
}) | ||
|
||
await session.save() | ||
|
||
return Response.redirect(url) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.