Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Policy inside aad-cc.bicep seems not correct #4

Open
SLdragon opened this issue Jun 20, 2022 · 0 comments
Open

Policy inside aad-cc.bicep seems not correct #4

SLdragon opened this issue Jun 20, 2022 · 0 comments

Comments

@SLdragon
Copy link
Member

SLdragon commented Jun 20, 2022

Thanks for this amazing project to help me understand how authentication works inside APIM!

Here is policy inside aad-cc.bicep file:

<inbound>
    <base />
     ...
    <set-variable name="uri" value="@{
      string oid = &quot;&quot;;
      string token = ((Authorization)context.Variables.GetValueOrDefault(&quot;auth-context&quot;))?.AccessToken;
      Jwt jwt;
      if (token.TryParseJwt(out jwt))
      {
          oid = jwt.Claims.GetValueOrDefault(&quot;oid&quot;, &quot;empty&quot;);
      }
      return &quot;/v1.0/users/&quot; + oid;
  }" />
  <rewrite-uri template="@((string)context.Variables[&quot;uri&quot;])" copy-unmatched-params="false" />
</inbound>

This policy is extract object id from access token, I am not sure what the oid inside access token stand for, and I got 404 error when use this policy. (tip: my tenant of the AAD is different from where APIM hosted)

I think the policy show be as below to obtain oid from query parameter objectid, if objectid is empty, it will list all the users inside the tenant:

<rewrite-uri template="@("v1.0/users/" + context.Request.Url.Query.GetValueOrDefault("objectid",""))" copy-unmatched-params="false" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant