package Ġno . nav . dag p enger . k alk ulator Ċ Ċ import Ġcom . nat pr y ce . kon fig . Configuration Map Ċ import Ġcom . nat pr y ce . kon fig . Configuration Properties Ċ import Ġcom . nat pr y ce . kon fig . Environment Variables Ċ import Ġcom . nat pr y ce . kon fig . Key Ċ import Ġcom . nat pr y ce . kon fig . int Type Ċ import Ġcom . nat pr y ce . kon fig . over riding Ċ import Ġcom . nat pr y ce . kon fig . string Type Ċ import Ġno . nav . dag p enger . aad . api . Client Credentials Client Ċ import Ġno . nav . dag p enger . ktor . auth . ApiKey Verifier Ċ Ċ private Ġval Ġlocal Properties Ġ= ĠConfiguration Map ( ĊĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠ Ġ" API _ GATE WAY _ API _ KEY " Ġto Ġ" h unter 2 ", ĊĠĠĠĠĠĠĠ Ġ" API _ GATE WAY _ URL " Ġto Ġ" http :// localhost /", ĊĠĠĠĠĠĠĠ Ġ" P DL _ API _ SCOPE " Ġto Ġ" api :// dev - f ss . p dl . p dl - api /. default ", ĊĠĠĠĠĠĠĠ Ġ" P DL _ API _ URL " Ġto Ġ" https :// p dl - api . dev - f ss - pub . na is . io / graphql ", ĊĠĠĠĠĠĠĠ Ġ" DP _ PROXY _ SCOPE " Ġto Ġ" api :// dev - f ss . team dag p enger . dp - proxy /. default ", ĊĠĠĠĠĠĠĠ Ġ" DP _ PROXY _ URL " Ġto Ġ" https :// dp - proxy . dev - f ss - pub . na is . io ", ĊĠĠĠĠĠĠĠ Ġ" application . http Port " Ġto Ġ" 8 0 9 9 ", ĊĠĠĠĠĠĠĠ Ġ" application . profile " Ġto Ġ" LOCAL ", ĊĠĠĠĠĠĠĠ Ġ" for sku dd . api . key " Ġto Ġ" h unter 2 ", ĊĠĠĠĠĠĠĠ Ġ" jw ks . issuer " Ġto Ġ" https :// localhost ", ĊĠĠĠĠĠĠĠ Ġ" jw ks . issuer . ny " Ġto Ġ"", ĊĠĠĠĠĠĠĠ Ġ" jw ks . url " Ġto Ġ" https :// localhost ", ĊĠĠĠĠĠĠĠ Ġ" jw ks . url . ny " Ġto Ġ"", ĊĠĠĠĠĠĠĠ Ġ" login service . id port en . discovery . url " Ġto Ġ" https :// localhost ", ĊĠĠĠĠĠĠĠ Ġ" re gel . api . key " Ġto Ġ" re gel Key ", ĊĠĠĠĠĠĠĠ Ġ" re gel . api . secret " Ġto Ġ" super secret " ĊĠĠĠ Ġ) Ċ ) Ċ private Ġval Ġdev Properties Ġ= ĠConfiguration Map ( ĊĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠ Ġ" P DL _ API _ SCOPE " Ġto Ġ" api :// dev - f ss . p dl . p dl - api /. default ", ĊĠĠĠĠĠĠĠ Ġ" P DL _ API _ URL " Ġto Ġ" https :// p dl - api . dev - f ss - pub . na is . io / graphql ", ĊĠĠĠĠĠĠĠ Ġ" DP _ PROXY _ SCOPE " Ġto Ġ" api :// dev - f ss . team dag p enger . dp - proxy /. default ", ĊĠĠĠĠĠĠĠ Ġ" DP _ PROXY _ URL " Ġto Ġ" https :// dp - proxy . dev - f ss - pub . na is . io ", ĊĠĠĠĠĠĠĠ Ġ" application . http Port " Ġto Ġ" 8 0 9 9 ", ĊĠĠĠĠĠĠĠ Ġ" application . profile " Ġto Ġ" DEV ", ĊĠĠĠĠĠĠĠ Ġ" jw ks . issuer " Ġto Ġ" https :// oidc - ver 2 . d ifi . no / id port en - oidc - provider /", ĊĠĠĠĠĠĠĠ Ġ" jw ks . issuer . ny " Ġto Ġ" https :// oidc - ver 2 . d ifi . no / id port en - oidc - provider /", ĊĠĠĠĠĠĠĠ Ġ" jw ks . url " Ġto Ġ" https :// oidc - ver 2 . d ifi . no / id port en - oidc - provider / j wk ", ĊĠĠĠĠĠĠĠ Ġ" jw ks . url . ny " Ġto Ġ" https :// oidc - ver 2 . d ifi . no / id port en - oidc - provider / j wk ", ĊĠĠĠ Ġ) Ċ ) Ċ private Ġval Ġprod Properties Ġ= ĠConfiguration Map ( ĊĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠ Ġ" P DL _ API _ SCOPE " Ġto Ġ" api :// prod - f ss . p dl . p dl - api /. default ", ĊĠĠĠĠĠĠĠ Ġ" P DL _ API _ URL " Ġto Ġ" https :// p dl - api . prod - f ss - pub . na is . io / graphql ", ĊĠĠĠĠĠĠĠ Ġ" DP _ PROXY _ SCOPE " Ġto Ġ" api :// prod - f ss . team dag p enger . dp - proxy /. default ", ĊĠĠĠĠĠĠĠ Ġ" DP _ PROXY _ URL " Ġto Ġ" https :// dp - proxy . prod - f ss - pub . na is . io ", ĊĠĠĠĠĠĠĠ Ġ" application . http Port " Ġto Ġ" 8 0 9 9 ", ĊĠĠĠĠĠĠĠ Ġ" application . profile " Ġto Ġ" PRO D ", ĊĠĠĠĠĠĠĠ Ġ" jw ks . issuer " Ġto Ġ" https :// oidc . d ifi . no / id port en - oidc - provider /", ĊĠĠĠĠĠĠĠ Ġ" jw ks . issuer . ny " Ġto Ġ" https :// oidc . d ifi . no / id port en - oidc - provider /", ĊĠĠĠĠĠĠĠ Ġ" jw ks . url " Ġto Ġ" https :// oidc . d ifi . no / id port en - oidc - provider / j wk ", ĊĠĠĠĠĠĠĠ Ġ" jw ks . url . ny " Ġto Ġ" https :// oidc . d ifi . no / id port en - oidc - provider / j wk ", ĊĠĠĠ Ġ) Ċ ) Ċ Ċ data Ġclass ĠConfiguration ( ĊĠĠĠ Ġval Ġapplication : ĠApplication Ġ= ĠApplication (), ĊĠĠĠ Ġval Ġauth : ĠAuth Ġ= ĠAuth () Ċ ) Ġ{ ĊĠĠĠ Ġclass ĠAuth ( ĊĠĠĠĠĠĠĠ Ġre gel Api Secret : ĠString Ġ= Ġconfig ()[ Key (" re gel . api . secret ", Ġstring Type )], ĊĠĠĠĠĠĠĠ Ġre gel ApiKey Plain : ĠString Ġ= Ġconfig ()[ Key (" re gel . api . key ", Ġstring Type )] ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġre gel ApiKey Ġ= ĠApi Key Verifier ( re gel Api Secret ). generate ( re gel ApiKey Plain ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġdata Ġclass ĠApplication ( ĊĠĠĠĠĠĠĠ Ġval Ġprofile : ĠProfile Ġ= Ġconfig ()[ Key (" application . profile ", Ġstring Type )]. let Ġ{ ĠProfile . valueOf ( it ) Ġ}, ĊĠĠĠĠĠĠĠ Ġval Ġhttp Port : ĠInt Ġ= Ġconfig ()[ Key (" application . http Port ", Ġint Type )], ĊĠĠĠĠĠĠĠ Ġval Ġid port en Discovery Url : ĠString Ġ= Ġconfig ()[ Key (" login service . id port en . discovery . url ", Ġstring Type )], ĊĠĠĠĠĠĠĠ Ġval Ġj w ks Url : ĠString Ġ= Ġconfig ()[ Key (" jw ks . url ", Ġstring Type )], ĊĠĠĠĠĠĠĠ Ġval Ġj w ks Issuer : ĠString Ġ= Ġconfig ()[ Key (" jw ks . issuer ", Ġstring Type )], ĊĠĠĠĠĠĠĠ Ġval Ġj w ks Url Ny : ĠString Ġ= Ġconfig ()[ Key (" jw ks . url . ny ", Ġstring Type )], ĊĠĠĠĠĠĠĠ Ġval Ġj w ks Issuer Ny : ĠString Ġ= Ġconfig ()[ Key (" jw ks . issuer . ny ", Ġstring Type )], ĊĠĠĠĠĠĠĠ Ġval Ġname : ĠString Ġ= Ġ" dp - k alk ulator - api ", ĊĊĠĠĠĠĠĠĠ Ġval Ġp dl Api BaseUrl : ĠString Ġ= Ġconfig ()[ Key (" P DL _ API _ URL ", Ġstring Type )], ĊĠĠĠĠĠĠĠ Ġval Ġfor sku dd ApiKey : ĠString Ġ= Ġconfig ()[ Key (" for sku dd . api . key ", Ġstring Type )], ĊĠĠĠĠĠĠĠ Ġval ĠbasePath : ĠString Ġ= Ġconfig (). getOrElse ( Key (" app . base path ", Ġstring Type ), Ġ"/ ar be id / dag p enger / k alk ulator - api "), ĊĠĠĠĠĠĠĠ Ġval Ġdp Proxy Url : ĠString Ġ= Ġconfig ()[ Key (" DP _ PROXY _ URL ", Ġstring Type )] Ġ+ Ġ"/ proxy / v 1 / re gel api ", ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġtoken Provider () Ġ= ĠClient Credentials Client ( config ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġscope Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġadd ( config ()[ Key (" P DL _ API _ SCOPE ", Ġstring Type )]) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfun Ġdp Proxy Token Provider () Ġ= ĠClient Credentials Client ( config ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġscope Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġadd ( config ()[ Key (" DP _ PROXY _ SCOPE ", Ġstring Type )]) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ enum Ġclass ĠProfile Ġ{ ĊĠĠĠ ĠLOCAL , ĠDEV , ĠPRO D Ċ } Ċ Ċ fun Ġconfig () Ġ= Ġwhen Ġ( System . getenv (" NA IS _ CLUSTER _ NAME ") Ġ?: ĠSystem . getProperty (" NA IS _ CLUSTER _ NAME ")) Ġ{ ĊĠĠĠ Ġ" dev - gcp " Ġ-> ĠConfiguration Properties . system Properties () Ġoverriding Ġdev Properties Ġoverriding ĠEnvironment Variables ĊĠĠĠ Ġ" prod - gcp " Ġ-> ĠConfiguration Properties . system Properties () Ġoverriding Ġprod Properties Ġoverriding ĠEnvironment Variables ĊĠĠĠ Ġelse Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ ĠConfiguration Properties . system Properties () Ġoverriding Ġlocal Properties Ġoverriding ĠEnvironment Variables ĊĠĠĠ Ġ} Ċ } Ċ