Skip to content

Commit

Permalink
Merge pull request #2286 from constantine2nd/develop
Browse files Browse the repository at this point in the history
Echo Request Headers to Response Headers with ECHO_ prepended to each Request Header
  • Loading branch information
simonredfern authored Oct 9, 2023
2 parents 0bc462f + d671b0c commit 18b8340
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions obp-api/src/main/resources/props/sample.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,9 @@ outboundAdapterCallContext.generalContext
## Mirror request headers to response
# mirror_request_headers_to_response=x-fapi-interaction-id,x-jws-signature

## Echo all request headers to response
echo_request_headers=false

### enable or disable the feature of send "Force-Error" header, default value is false
enable.force_error=false

Expand Down
16 changes: 15 additions & 1 deletion obp-api/src/main/scala/code/api/util/APIUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{
getGatewayLoginHeader(cc).list :::
getRateLimitHeadersNewStyle(cc).list :::
getPaginationHeadersNewStyle(cc).list :::
getRequestHeadersToMirror(cc).list
getRequestHeadersToMirror(cc).list :::
getRequestHeadersToEcho(cc).list
)
}

Expand Down Expand Up @@ -678,6 +679,19 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{
CustomResponseHeaders(Nil)
}
}
/**
*
*/
def getRequestHeadersToEcho(callContext: Option[CallContextLight]): CustomResponseHeaders = {
val echoRequestHeaders: Boolean =
getPropsAsBoolValue("echo_request_headers", defaultValue = false)
(callContext, echoRequestHeaders) match {
case (Some(cc), true) =>
CustomResponseHeaders(cc.requestHeaders.map(item => (s"ECHO_${item.name}", item.values.head)))
case _ =>
CustomResponseHeaders(Nil)
}
}
/**
*
* @param jwt is a JWT value extracted from GatewayLogin Authorization Header.
Expand Down

0 comments on commit 18b8340

Please sign in to comment.