Closed wallacekelly-da closed 5 months ago
@wallacekelly-da are the parameters participantId
, actAs
, readAs
part of the token request? The only way we can use dynamic values in the returned token for a specific request mapping is if we receive them as a part of the token request. Can you provide a sample of the token request?
Hi, @tommytroen! Thanks for asking:
curl http://localhost:8080/mockauth/token \
-d grant_type=client_credentials \
-d client_id="ignored" \
-d client_secret="ignored" \
-d mock_token_type="custom" \
-d participantId="participant1::1220f7994746f8f05198bbaf817714503d54fa17f4b23f17fafae8387f86bf5eaead" \
-d actAs="admin::1220f7994746f8f05198bbaf817714503d54fa17f4b23f17fafae8387f86bf5eaead" \
-d readAs="admin::1220f7994746f8f05198bbaf817714503d54fa17f4b23f17fafae8387f86bf5eaead"
@wallacekelly-da: Great thanks, this looks feasible. Will have a look soon.
seems like this to are related? https://github.com/navikt/mock-oauth2-server/issues/683
@wallacekelly-da sorry for taking so long, we have create a PR here, #699 , which should support your use case.
I have been using this today and it works great! Thanks, @tommytroen !
Repro steps
Motivated by this, define a request mapping in the JSON config file:
Desired Behavior
The mock-oauth2-server responds to token requests with a signed token with
${participantId}
,${actAs}
, and${readAs}
replaced with values from the token request. Here is a sample of what I'm looking for:Current Behavior
The fields
${participantId}
,${actAs}
, and${readAs}
are not replaced. Here is an example of what is returned:Related code
It looks like the
replaceVariables
function is only being applied to the first-level strings and lists of strings.From OAuth2TokenCallback.kt:
This code would need to be updated to recurse the fields of child objects. Or, perhaps more simply, perform the substitution on the full claims JSON string, instead of the individual claims.