Hello,
I wish to have multiple individual stages (actions) in the login action pipeline. Each individual action will need to add stuff to the same claim object.
As a more properly explained example. I want my auth login flow to have multiple stages like so
[Action1]
|
[Action 2]
|
[Action 3]
The made up code for Action 1
exports.onExecutePostLogin = async (event, api) => {
if (event.authorization) {
api.idToken.setCustomClaim("http://foo-bar/my-claim", {
"x-user-role": generateUserRole(),
})
}
};
Then the next Action in the pipeline, Action 2
exports.onExecutePostLogin = async (event, api) => {
if (event.authorization) {
api.idToken.setCustomClaim("http://foo-bar/my-claim", {
"x-foo-bar": "baz",
})
}
};
Then the next Action in the pipeline, Action 3
exports.onExecutePostLogin = async (event, api) => {
if (event.authorization) {
api.idToken.setCustomClaim("http://foo-bar/my-claim", {
"something-else": "goes here",
})
}
};
The problem seems to be that each action uses the setCustomClaim
method which seems to overwrite the object at the claim location “http://foo-bar/my-claim”, whereas I wish to add new object keys each time instead. I wish the final claim on the id token after all 3 stages to look like the following:
{
"http://foo-bar/my-claim": {
"x-user-role": "some-role",
"x-foo-bar": "baz",
"something-else": "goes here",
},
....
}