square-eye-96545
03/25/2022, 11:53 AMoauth2_client_credentials
authenticator along with id_token
mutator. While trying to use custom claims using the hydrator
example in the documentation - https://www.ory.sh/docs/oathkeeper/pipeline/mutator#hydrator, I am receiving a marshaling error for url
using this response object as described in the documentation. Has anyone used a hydrator before and can share a working example?
{
"subject": "anonymous",
"extra": {
"foo": "bar"
},
"header": {
"foo": [
"bar1",
"bar2"
]
},
"match_context": {
"regexp_capture_groups": [
"http",
"foo"
],
"url": "<http://domain.com/foo>"
}
}
happy-morning-85531
03/25/2022, 12:00 PMhappy-morning-85531
03/25/2022, 12:03 PMsquare-eye-96545
03/25/2022, 12:10 PMhappy-morning-85531
03/25/2022, 12:18 PM@Serializable
data class OryAuthenticationSession(
val subject: String,
val extra: JsonObject? = JsonObject(emptyMap()),
val header: JsonObject? = null,
@SerialName("match_context")
val matchContext: MatchContext,
) {
@Serializable
data class MatchContext(
@SerialName("regexp_capture_groups")
val regexpCaptureGroups: JsonArray,
val url: JsonElement,
val method: String? = null,
val header: JsonObject? = null,
)
}
JsonElement
is just any json type, and the input would just modify the extra field with
override suspend fun hydrateAuthSession(rq: OryAuthenticationSession): OryAuthenticationSession {
val mapping = repository.findBySubject(rq.subject) ?: throw UnauthorizedException("No such mapping for subject")
val modifiedExtra = (rq.extra ?: JsonObject(emptyMap())).toMutableMap().apply {
put(ORG_MAPPING_KEY, JsonPrimitive(mapping.organization))
}
return rq.copy(extra = JsonObject(modifiedExtra))
}
happy-morning-85531
03/25/2022, 12:19 PMv0.38.19-beta.1
square-eye-96545
03/25/2022, 12:33 PMFROM oryd/oathkeeper:v0.38.23-beta.1
square-eye-96545
03/25/2022, 12:33 PMsquare-eye-96545
03/27/2022, 4:56 PM