Skip to content

Commit

Permalink
Migrin url ympäristökohtaiseksi
Browse files Browse the repository at this point in the history
  • Loading branch information
augustk committed Jan 11, 2024
1 parent 3734f9d commit 4adf629
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/js/controllers/hakutoiveidenMuokkaus.js
Expand Up @@ -34,6 +34,7 @@ export default ['$scope', '$location', '$http', '$cookies', function($scope, $lo
$scope.application = new Hakemus(response.data);
$scope.application.oiliJwt = response.oiliJwt;
$scope.application.migriJwt = response.migriJwt;
$scope.application.migriUrl = response.migriUrl;
$scope.application.token = token;
$scope.application.isHakutoiveidenMuokkaus = true;
const henkilotiedot = response.data.hakemus.answers.henkilotiedot;
Expand Down
3 changes: 2 additions & 1 deletion src/main/js/directives/application.html
Expand Up @@ -77,7 +77,8 @@ <h2>{{application.haku.name }}</h2>

<section class="migri" ng-if="application.showMigriURL()">
<migri migri="application.showMigriURL()"
token="{{application.migriJwt}}">
token="{{application.migriJwt}}"
url="{{application.migriUrl}}">
</migri>
</section>

Expand Down
1 change: 1 addition & 0 deletions src/main/js/directives/applicationList.js
Expand Up @@ -26,6 +26,7 @@ export default ["restResources", function (restResources) {
var application = new Hakemus(json);
application.isHakutoiveidenMuokkaus = false;
application.migriJwt = data.migriJwt
application.migriUrl = data.migriUrl
return application;
});
if($scope.applications.length > 0) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/js/directives/migri.js
Expand Up @@ -5,13 +5,14 @@ export default function () {
restrict: 'E',
scope: {
migri: '&migri',
token: '@token'
token: '@token',
url: '@url'
},
template: require('./migri.html'),
link: function (scope, element, attrs) {
scope.localization = localize;
scope.tokenParam = scope.token ? "?token=" + scope.token : ""
scope.parsedUrl = scope.localization('migri.linkki-pohja') + scope.tokenParam;
scope.parsedUrl = scope.url + scope.tokenParam;
}
}
}
1 change: 1 addition & 0 deletions src/main/js/interceptors/nonSensitiveHakemus.js
Expand Up @@ -29,6 +29,7 @@ export default ['$cookies', function HakemusInterceptor($cookies) {
setBearerToken($cookies, response.data.jsonWebToken);
response.oiliJwt = response.data.oiliJwt;
response.migriJwt = response.data.migriJwt;
response.migriUrl = response.data.migriUrl;
response.data = response.data.response
}
return response
Expand Down
1 change: 1 addition & 0 deletions src/main/js/models/hakemus.js
Expand Up @@ -28,6 +28,7 @@ export default class Hakemus {
};
this.oiliJwt = null;
this.migriJwt = null;
this.migriUrl = null;
this.hakemusSource = json.hakemusSource;
this.previewUrl = json.previewUrl;
}
Expand Down
Expand Up @@ -194,3 +194,5 @@ oppija.base.url.sv={{oppija_base_url_sv}}
omatsivut.kohdejoukot.korkeakoulu={{omatsivut_kohdejoukot_korkeakoulu | default('haunkohdejoukko_12')}}
omatsivut.kohdejoukot.toinen-aste={{omatsivut_kohdejoukot_toinenaste | default('haunkohdejoukko_11,haunkohdejoukko_17,haunkohdejoukko_20,haunkohdejoukko_23,haunkohdejoukko_24')}}
omatsivut.kohdejoukon-tarkenteet.siirtohaku={{omatsivut_kohdejoukontarkenteet_siirtohaku | default('haunkohdejoukontarkenne_1')}}

omatsivut.migri.url={{ omatsivut | default('https://devas08.dev.uma.gov/fiesta-strong-account-esrvweb/chooseapplicationtype') }}
Expand Up @@ -28,6 +28,8 @@ case class ApplicationSettings(config: Config) extends GroupEmailerSettings(conf
leakDetectionThresholdMillis = getLong(config, "omatsivut.db.leakDetectionThresholdMillis")
)

val migriUrl = config.getString("omatsivut.migri.url")

val sessionTimeoutSeconds = getInt(config, "omatsivut.sessionTimeoutSeconds")
val sessionCleanupCronString = getString(config, "omatsivut.sessionCleanupCronString")

Expand Down
Expand Up @@ -73,10 +73,20 @@ trait ApplicationsServletContainer {
val oid = personOid()
hakemusEditori.fetchByPersonOid(request, oid, Fetch) match {
case FullSuccess(hakemukset) =>
Map("allApplicationsFetched" -> true, "applications" -> hakemukset, "migriJwt" -> migriJwt.createMigriJWT(oid))
Map(
"allApplicationsFetched" -> true,
"applications" -> hakemukset,
"migriJwt" -> migriJwt.createMigriJWT(oid),
"migriUrl" -> appConfig.settings.migriUrl
)
case PartialSuccess(hakemukset, exceptions) =>
exceptions.foreach(logger.warn(s"Failed to fetch all applications for oid $oid",_))
Map("allApplicationsFetched" -> false, "applications" -> hakemukset, "migriJwt" -> migriJwt.createMigriJWT(oid))
Map(
"allApplicationsFetched" -> false,
"applications" -> hakemukset,
"migriJwt" -> migriJwt.createMigriJWT(oid),
"migriUrl" -> appConfig.settings.migriUrl
)
case FullFailure(exceptions) =>
exceptions.foreach(logger.error(s"Failed to fetch applications for oid $oid", _))
throw exceptions.head
Expand Down
Expand Up @@ -28,8 +28,17 @@ sealed trait InsecureResponse {
def jsonWebToken: String
}

case class InsecureHakemus(jsonWebToken: String, response: NonSensitiveHakemus) extends InsecureResponse
case class InsecureHakemusInfo(jsonWebToken: String, response: NonSensitiveHakemusInfo, oiliJwt: String = null, migriJwt: String = null) extends InsecureResponse
case class InsecureHakemus(
jsonWebToken: String,
response: NonSensitiveHakemus
) extends InsecureResponse
case class InsecureHakemusInfo(
jsonWebToken: String,
response: NonSensitiveHakemusInfo,
oiliJwt: String = null,
migriJwt: String = null,
migriUrl: String = null
) extends InsecureResponse

trait NonSensitiveApplicationServletContainer {
this: HakemusRepositoryComponent with
Expand All @@ -45,6 +54,7 @@ trait NonSensitiveApplicationServletContainer {
private val hakemusEditori = newEditor(this)
private val jwt = new JsonWebToken(appConfig.settings.hmacKey)
private val migriJwt = new MigriJsonWebToken(appConfig.settings.hmacKeyMigri)
private val migriUrl = appConfig.settings.migriUrl

class UnauthorizedException(msg: String) extends RuntimeException(msg)
class ForbiddenException(msg: String) extends RuntimeException(msg)
Expand Down Expand Up @@ -158,7 +168,8 @@ trait NonSensitiveApplicationServletContainer {
jwt.encode(token),
new NonSensitiveHakemusInfo(hakemus, token.answersFromThisSession),
oiliJwt = jwt.createOiliJwt(personOid),
migriJwt = migriJwt.createMigriJWT(personOid)
migriJwt = migriJwt.createMigriJWT(personOid),
migriUrl = migriUrl
))
}).get
}
Expand Down Expand Up @@ -194,7 +205,8 @@ trait NonSensitiveApplicationServletContainer {
jwt.encode(HakemusJWT(metadata.hakemusOid, Set(), hakemus.hakemus.personOid)),
new NonSensitiveHakemusInfo(hakemus, Set()),
oiliJwt = jwt.createOiliJwt(personOid),
migriJwt = migriJwt.createMigriJWT(personOid)
migriJwt = migriJwt.createMigriJWT(personOid),
migriUrl = migriUrl
))
}).get
}
Expand Down

0 comments on commit 4adf629

Please sign in to comment.