Skip to content

Commit

Permalink
Feature/login link (#165)
Browse files Browse the repository at this point in the history
* Legger til endepunkt for å redirecte til login

* Defaulter til prodverdier slik at prod ihvertfall blir riktig

* Prøver å force dynamisk henting av login-urls
  • Loading branch information
V1adau authored Dec 17, 2024
1 parent 6446807 commit 3e4d994
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
NEXT_PUBLIC_ENVIRONMENT=localhost
BASE_URL=http://localhost/min-cv
LOGIN_URL=http://localhost

TOKEN_X_CLIENT_ID=local-token-x-client-id
TOKEN_X_PRIVATE_JWK='{"kty":"RSA","alg":"RS256","use":"sig","p":"_xCPvqs85ZZVg460Qfot26rQoNRPTOVDo5p4nqH3ep6BK_5TvoU5LFXd26W-1V1Lc5fcvvftClPOT201xgat4DVtliNtoc8od_tWr190A3AzbsAVFOx0nKa5uhLBxP9SsPM84llp6PXF6QTMGFiPYuoLDaQQqL1K4BbHq3ZzF2M","q":"7QLqW75zkfSDrn5rMoF50WXyB_ysNx6-2SvaXKGXaOn80IR7QW5vwkleJnsdz_1kr04rJws2p4HBJjUFfSJDi1Dapj7tbIwb0a1szDs6Y2fAa3DlzgXZCkoE2TIrW6UITgs14pI_a7RasclE71FpoZ78XNBvj3NmZugkNLBvRjs","d":"f7aT4poed8uKdcSD95mvbfBdb6X-M86d99su0c390d6gWwYudeilDugH9PMwqUeUhY0tdaRVXr6rDDIKLSE-uEyaYKaramev0cG-J_QWYJU2Lx-4vDGNHAE7gC99o1Ee_LXqMDCBawMYyVcSWx7PxGQfzhSsARsAIbkarO1sg9zsqPS4exSMbK8wyCTPgRbnkB32_UdZSGbdSib1jSYyyoAItZ8oZHiltVsZIlA97kS4AGPtozde043NC7Ik0uEzgB5qJ_tR7vW8MfDrBj6da2NrLh0UH-q28dooBO1vEu0rvKZIescXYk9lk1ZakHhhpZaLykDOGzxCpronzP3_kQ","e":"AQAB","qi":"9kMIR6pEoiwN3M6O0n8bnh6c3KbLMoQQ1j8_Zyir7ZIlmRpWYl6HtK0VnD88zUuNKTrQa7-jfE5uAUa0PubzfRqybACb4S3HIAuSQP00_yCPzCSRrbpGRDFqq-8eWVwI9VdiN4oqkaaWcL1pd54IDcHIbfk-ZtNtZgsOlodeRMo","dp":"VUecSAvI2JpjDRFxg326R2_dQWi6-uLMsq67FY7hx8WnOqZWKaUxcHllLENGguAmkgd8bv1F6-YJXNUO3Z7uE8DJWyGNTkSNK1CFsy0fBOdGywi-A7jrZFT6VBRhZRRY-YDaInPyzUkfWsGX26wAhPnrqCvqxgBEQJhdOh7obDE","dq":"7EUfw92T8EhEjUrRKkQQYEK0iGnGdBxePLiOshEUky3PLT8kcBHbr17cUJgjHBiKqofOVNnE3i9nkOMCWcAyfUtY7KmGndL-WIP-FYplpnrjQzgEnuENgEhRlQOCXZWjNcnPKdKJDqF4WAtAgSIznz6SbSQMUoDD8IoyraPFCck","n":"7CU8tTANiN6W_fD9SP1dK2vQvCkf7-nwvBYe5CfANV0_Bb0ZmQb77FVVsl1beJ7EYLz3cJmL8Is1RCHKUK_4ydqihNjEWTyZiQoj1i67pkqk_zRvfQa9raZR4uZbuBxx7dWUoPC6fFH2F_psAlHW0zf90fsLvhB6Aqq3uvO7XXqo8qNl9d_JSG0Rg_2QUYVb0WKmPVbbhgwtkFu0Tyuev-VZ9IzTbbr5wmZwEUVY7YAi73pDJkcZt5r2WjOF_cuIXe-O2vwbOrRgmJfHO9--mVLdATnEyrb6q2oy_75h6JjP-R4-TD1hyoFFoE2gmj-kSS6Z_Gggljs3Aw7--Nh10Q"}'
Expand Down
2 changes: 2 additions & 0 deletions .nais/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ next_public_environment: "dev"
pam_cv_api_audience: "dev-gcp:teampam:pam-cv-api-gcp"
pam_eures_cv_eksport_audience: "dev-gcp:teampam:pam-eures-cv-eksport"
next_public_telemetry_url: "https://telemetry.ekstern.dev.nav.no/collect"
base_url: "https://www.ansatt.dev.nav.no/min-cv"
login_url: "https://login.ekstern.dev.nav.no/oauth2/login"
4 changes: 4 additions & 0 deletions .nais/nais.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ spec:
value: "8095"
- name: NEXT_PUBLIC_ENVIRONMENT
value: {{ next_public_environment }}
- name: BASE_URL
value: {{ base_url }}
- name: LOGIN_URL
value: {{ login_url }}
- name: PAM_CV_API_BASEURL
value: http://pam-cv-api-gcp/pam-cv-api/rest
- name: PAM_CV_API_AUDIENCE
Expand Down
2 changes: 2 additions & 0 deletions .nais/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ next_public_environment: "prod"
pam_cv_api_audience: "prod-gcp:teampam:pam-cv-api-gcp"
pam_eures_cv_eksport_audience: "prod-gcp:teampam:pam-eures-cv-eksport"
next_public_telemetry_url: "https://telemetry.nav.no/collect"
base_url: "https://www.nav.no/min-cv"
login_url: "https://login.nav.no/oauth2/login"
20 changes: 18 additions & 2 deletions src/app/_common/components/Feilside.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,26 @@ export const FeilsideÅrsak = Object.freeze({
},
IKKE_LOGGET_INN: {
tittel: "Du er ikke logget inn",
tekst: 'Du er ikke logget inn. "Min CV" er en innlogget tjeneste. Vennligst logg inn, eller gå tilbake til Nav.no.',
body: (
<BodyLong className={["text-center", styles.mb12]}>
Du er ikke logget inn. "Min CV" er en innlogget tjeneste. Vennligst{" "}
<Link rel="noopener noreferrer" href="/min-cv/api/login" inlineText>
logg inn
</Link>
, eller gå tilbake til Nav.no.
</BodyLong>
),
},
LOGGET_UT: {
tittel: "Du har blitt logget ut",
tekst: "Du har blitt logget ut på grunn av inaktivitet. Vennligst logg inn igjen, eller gå tilbake til Nav.no.",
body: (
<BodyLong className={["text-center", styles.mb12]}>
Du har blitt logget ut på grunn av inaktivitet. Vennligst{" "}
<Link rel="noopener noreferrer" href="/min-cv/api/login" inlineText>
logg inn
</Link>{" "}
igjen, eller gå tilbake til Nav.no.
</BodyLong>
),
},
});
2 changes: 2 additions & 0 deletions src/app/_common/serverConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const hentServerConfigMap = () => ({
euresCvEksport: process.env.PAM_EURES_CV_EKSPORT_AUDIENCE,
},
urls: {
base: process.env.BASE_URL,
login: process.env.LOGIN_URL,
cvApi: process.env.PAM_CV_API_BASEURL,
pamOntologi: process.env.PAM_ONTOLOGI_BASEURL,
euresCvEksport: process.env.PAM_EURES_CV_EKSPORT_BASEURL,
Expand Down
12 changes: 12 additions & 0 deletions src/app/api/login/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { serverConfig } from "@/app/_common/serverConfig";

export const dynamic = "force-dynamic";

export async function GET() {
const loginUrl = serverConfig?.urls.login || "https://login.nav.no/oauth2/login";
const baseUrl = serverConfig?.urls.base || "https://www.nav.no/min-cv";

const loginRedirect = `${loginUrl}?redirect=${baseUrl}&level=Level3`;

return Response.redirect(loginRedirect);
}

0 comments on commit 3e4d994

Please sign in to comment.