Skip to content

Commit

Permalink
some tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tlangs committed May 3, 2024
1 parent aba9d91 commit 450df56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ trait StandardSamUserDirectives extends SamUserDirectives with LazyLogging with
res match {
case Complete(resp) =>
logger.info(
s"Request from Service Admin user ${oidcHeaders.email}",
s"${req.method.value} ${req.uri.path} - ${resp.status.value} - Service Admin User: ${oidcHeaders.email} ",
UnregisteredUserApiEvent(
"apiRequest:serviceAdmin:complete",
RequestEventDetails(req, Some(oidcHeaders)),
Expand All @@ -120,7 +120,7 @@ trait StandardSamUserDirectives extends SamUserDirectives with LazyLogging with
)
case Rejected(rejections) =>
logger.warn(
s"Request from Service Admin user ${oidcHeaders.email}",
s"${req.method.value} ${req.uri.path} - incomplete - Service Admin User: ${oidcHeaders.email} ",
UnregisteredUserApiEvent(
"apiRequest:serviceAdmin:incomplete",
RequestEventDetails(req, Some(oidcHeaders)),
Expand All @@ -139,7 +139,7 @@ trait StandardSamUserDirectives extends SamUserDirectives with LazyLogging with
res match {
case Complete(resp) =>
logger.info(
s"Request from user ${samUser.id} (${samUser.email})",
s"${req.method.value} ${req.uri.path} - ${resp.status.value} - User: ${oidcHeaders.email} (${samUser.id}) ",
RegisteredUserApiEvent(
samUser.id,
"apiRequest:user:complete",
Expand All @@ -149,7 +149,7 @@ trait StandardSamUserDirectives extends SamUserDirectives with LazyLogging with
)
case Rejected(rejections) =>
logger.warn(
s"Request from user ${samUser.id} (${samUser.email})",
s"${req.method.value} ${req.uri.path} - incomplete - User: ${oidcHeaders.email} (${samUser.id}) ",
RegisteredUserApiEvent(
samUser.id,
"apiRequest:user:incomplete",
Expand Down Expand Up @@ -260,10 +260,9 @@ final case class OIDCHeaders(
) extends MetricsLoggable {

override def toLoggableMap: java.util.Map[String, Any] = Map[String, Any](
"googleSubjectId" -> externalId.left.toOption.map(_.value).orNull,
"azureB2CId" -> externalId.map(_.value).toOption.orNull,
"email" -> email.value,
"googleSubjectIdFromAzure" -> googleSubjectIdFromAzure.map(_.value).orNull,
"googleSubjectId" -> googleSubjectIdFromAzure.map(_.value).orNull,
"managedIdentityObjectId" -> managedIdentityObjectId.map(_.value).orNull
).asJava

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import scala.jdk.CollectionConverters._
case class RequestEventDetails(httpRequest: HttpRequest, oidcHeaders: Option[OIDCHeaders]) extends MetricsLoggable {
override def toLoggableMap: util.Map[String, Any] = {
val baseMap = Map[String, Any](
"uri" -> httpRequest.uri.toString,
"path" -> httpRequest.uri.path.toString(),
"method" -> httpRequest.method.value
)
oidcHeaders.map(headers => (baseMap + ("oidcHeaders" -> headers.toLoggableMap)).asJava).getOrElse(baseMap.asJava)
Expand Down

0 comments on commit 450df56

Please sign in to comment.