Question
Wüstenrot & Württembergische Informatik
DE
Last activity: 15 May 2024 9:27 EDT
Authentication Service Error Handling
Hi Community,
we developed a custom authentication service, which we use to secure our application specific REST service endpoints. The activity uses the pxProcessJWT Activity to validate and parse the received JWT.
If a wrong token is supplied (e.g. issued by a wrong IDP) the authentication fails (which is expected), the following error is logged by com.pega.pegarules.integration.engine.internal.services.ServiceAPI and the http status 500 is returned (which ideally should be 401):
Hi Community,
we developed a custom authentication service, which we use to secure our application specific REST service endpoints. The activity uses the pxProcessJWT Activity to validate and parse the received JWT.
If a wrong token is supplied (e.g. issued by a wrong IDP) the authentication fails (which is expected), the following error is logged by com.pega.pegarules.integration.engine.internal.services.ServiceAPI and the http status 500 is returned (which ideally should be 401):
com.pega.pegarules.pub.services.ServiceException: Service requestor could not be authenticated
at com.pega.pegarules.integration.engine.internal.services.ServiceAPI.handleAuthentication(ServiceAPI.java:1770)
at com.pega.pegarules.integration.engine.internal.services.RESTServiceAPI.handleAuthentication(RESTServiceAPI.java:227)
at com.pega.pegarules.session.external.engineinterface.service.EngineAPI.activityExecutionProlog(EngineAPI.java:628)
at com.pega.pegarules.session.external.engineinterface.service.EngineAPI.processRequestInner(EngineAPI.java:454)
at jdk.internal.reflect.GeneratedMethodAccessor175.invoke(Unknown Source)
[...]
Caused by: com.pega.pegarules.pub.PRRuntimeException: No failure response set by custom authentication activity
at com.pega.pegarules.session.internal.mgmt.authentication.SchemePRCustom.onAuthenticationFailure(SchemePRCustom.java:1091)
at com.pega.pegarules.session.internal.mgmt.authentication.Authentication.doAuthentication(Authentication.java:740)
at com.pega.pegarules.integration.engine.internal.services.ServiceAPI.handleAuthentication(ServiceAPI.java:1735)
... 56 more
Especially the "No failure response set by custom authentication activity" makes us wonder, what the correct way to handle an authentication failure would be.
We tried setting param.pyFailMessage as suggested in PRRuntimeException: No failure response set by custom authentication activity but with no effect.