oauth 2.0 - APIM Policy to check that token has specific role - Stack Overflow

admin2025-04-16  3

I'm using the validate-jwt policy in APIM. As a part of the verification, I want to confirm that the token has a specific role set. If I decode the token, the role appears as an array:

...
"roles": [
  "Api.Call"
],
...

How do I write this check? I've seen that you can use this syntax:

<required-claims>
   <claim name="scope" match="all" separator=",">
        <value>api1.write</value>
   </claim>
</required-claims>

But this is not a string with a specific separator, so that doesn't seem right.

I'm using the validate-jwt policy in APIM. As a part of the verification, I want to confirm that the token has a specific role set. If I decode the token, the role appears as an array:

...
"roles": [
  "Api.Call"
],
...

How do I write this check? I've seen that you can use this syntax:

<required-claims>
   <claim name="scope" match="all" separator=",">
        <value>api1.write</value>
   </claim>
</required-claims>

But this is not a string with a specific separator, so that doesn't seem right.

Share Improve this question edited Feb 4 at 3:30 Ikhtesam Afrin 6,5722 gold badges3 silver badges10 bronze badges Recognized by Microsoft Azure Collective asked Feb 3 at 17:20 MaxMax 69510 silver badges23 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

You can use this:

<required-claims>
    <claim name="roles" match="any">
        <value>Api.Call</value>
    </claim>
</required-claims>
转载请注明原文地址:http://anycun.com/QandA/1744758594a87204.html