new configuration version

This commit is contained in:
haburger 2025-01-13 16:26:02 +00:00
parent 22b06a4e46
commit d276168aaa
2 changed files with 19 additions and 15 deletions

View File

@ -45,7 +45,7 @@ spec:
podDisruptionBudget: podDisruptionBudget:
maxUnavailable: "50%" maxUnavailable: "50%"
git: git:
tag: "r-500f09f8321aa28d34a7334829af22055902f81b" tag: "r-5190e6a7cf86a817b73807ecaff4b41c37839349"
dir: "DEFAULT-ADN-AGOV-PROJECT/DEFAULT-ADN-AGOV-INV/auth" dir: "DEFAULT-ADN-AGOV-PROJECT/DEFAULT-ADN-AGOV-INV/auth"
credentials: "git-credentials" credentials: "git-credentials"
keystores: keystores:

View File

@ -1,7 +1,5 @@
import ch.nevis.esauth.auth.engine.AuthResponse import ch.nevis.esauth.auth.engine.AuthResponse
import ch.nevis.idm.client.IdmRestClient import ch.nevis.esauth.util.httpclient.api.HttpClient
import ch.nevis.idm.client.IdmRestClientFactory
import ch.nevis.idm.client.HTTPRequestWrapper
import groovy.json.JsonSlurper import groovy.json.JsonSlurper
import groovy.xml.XmlSlurper import groovy.xml.XmlSlurper
@ -19,7 +17,7 @@ def userAgent = request.getLoginContext()['connection.HttpHeader.user-agent'] ?:
IdmRestClient idmRestClient = IdmRestClientFactory.get(parameters) HttpClient httpClient = HttpClients.create(parameters)
String clientExtId = session.get('ch.adnovum.nevisidm.user.clientExtId') String clientExtId = session.get('ch.adnovum.nevisidm.user.clientExtId')
String userExtId = session.get('ch.adnovum.nevisidm.user.extId') String userExtId = session.get('ch.adnovum.nevisidm.user.extId')
@ -65,21 +63,27 @@ if (outargs.containsKey('out.JWTToken')) {
if (!session['agov.new.recovery.code.generated']) { if (!session['agov.new.recovery.code.generated']) {
inargs.remove('submit') inargs.remove('submit')
try { try {
def postRequest = new HTTPRequestWrapper() def httpResponse = Http.post()
postRequest.addToHeaders('Content-Type', ['application/json']) .url(endPoint)
.header("Accept", "application/json")
.header("traceparent", traceparent)
.entity(Http.entity()
.content("{\"userExtId\":\"$userExtId\",\"userSessionId\": \"$sessionId\"}")
.contentType("application/json")
.charSet("utf-8")
.build())
.build()
.send(httpClient)
postRequest.setPayLoad("{\"userExtId\":\"$userExtId\",\"userSessionId\": \"$sessionId\"}".getBytes('UTF-8'))
def result = idmRestClient.postWithResponse(endPoint, postRequest) if (httpResponse.code() != 200) {
if (result.getStatusCode() != 200) { LOG.debug("Result: ${httpResponse}")
LOG.debug("Payload: ${new String(postRequest.getPayLoad())}") LOG.warn("Event='RCVRY-CODE', Requester='${requester}', RequestId='${requestId}', RequestedAq=${requestedAq}, User=${user}, CredentialType='${credentialType}', SourceIp=${sourceIp}, UserAgent='${userAgent}', reason='Failed to create code (http status code ${httpResponse.code()})")
LOG.debug("Result: ${result}")
LOG.warn("Event='RCVRY-CODE', Requester='${requester}', RequestId='${requestId}', RequestedAq=${requestedAq}, User=${user}, CredentialType='${credentialType}', SourceIp=${sourceIp}, UserAgent='${userAgent}', reason='Failed to create code (http status code ${result.getStatusCode()})")
response.setResult('failed') response.setResult('failed')
return return
} }
def json = new JsonSlurper().parseText(new String(result.getPayLoad(), 'UTF-8')) def json = new JsonSlurper().parseText(httpResponse.bodyAsString())
notes.setProperty('agov.new.recovery.code', json['recoveryCode']['code'].replaceAll('^(....)(....)(.*)$', '$1-$2-$3')) notes.setProperty('agov.new.recovery.code', json['recoveryCode']['code'].replaceAll('^(....)(....)(.*)$', '$1-$2-$3'))
LOG.debug("agov.new.recovery.code: ${notes['agov.new.recovery.code']}") LOG.debug("agov.new.recovery.code: ${notes['agov.new.recovery.code']}")