Custom Policies - How can I check if a query parameter is present or not in the request?

Maluenda Miranda, Cristian G 121 Reputation points
2022-04-26T00:22:58.117+00:00

Hi,

I am using the Claims Resolver "{OAUTH-KV:any custom query string}" to read a query parameter. That works fine but my problem is, that I need to set a default value when the query parameter is not part of the request.

The problem that I am having is Azure creates a Claim Type null, so there is no way to use a "precondition" in the UserJourney to do some logic. ClaimsExist is always true, and ClaimEquals doesn't work if I compare it against the value "Null" or an empty string.

I know that I could pass always a default value (Something like "skip"). So, I can use the ClaimEquals and check if the value is "skip." The problem with this solution is not backward compatible and it will break old clients.

Any suggestion on what can I do?

Thanks.

Microsoft Security Microsoft Entra Microsoft Entra External ID
{count} votes

1 answer

Sort by: Most helpful
  1. Maluenda Miranda, Cristian G 121 Reputation points
    2022-04-26T21:26:17.977+00:00

    In the end, I used two query parameters. One is for the input that I need, and the other is a true/false flag. So, I can do this:

                    <OrchestrationStep Order="2" Type="ClaimsExchange">
                        <Preconditions>
                            <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
                                <Value>useCustomCorrelationId</Value>
                                <Value>true</Value>
                                <Action>SkipThisOrchestrationStep</Action>
                            </Precondition>
                        </Preconditions>
                        <ClaimsExchanges>
                            <ClaimsExchange Id="set-azure-correlation-id" TechnicalProfileReferenceId="set-azure-correlation-id" />
                        </ClaimsExchanges>
                    </OrchestrationStep>
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.