Skip to content

Commit

Permalink
PUB-2535 - Updated validate JWT part 2 (#457)
Browse files Browse the repository at this point in the history
* PUB-2535 - Updated validate JWT

* PUB-2535 - Updated to only use Authorization header

* PUB-2535 - Updated validate JWT (#459)

* PUB-2535 - Updated validate JWT (#471)
  • Loading branch information
ChrisS1512 authored Oct 22, 2024
1 parent 8e6da8e commit 7aac30f
Showing 1 changed file with 14 additions and 34 deletions.
48 changes: 14 additions & 34 deletions infrastructure/resources/operation-policies/sendOtpEmail.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
<policies>
<inbound>
<choose>
<when condition="@(context.Request.Headers.GetValueOrDefault("Authorization","") != "")">
<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
<openid-config url="https://login.microsoftonline.com/{TENANT_ID}/v2.0/.well-known/openid-configuration" />
<audiences>
<audience>{CLIENT_ID}</audience>
</audiences>
<issuers>
<issuer>https://login.microsoftonline.com/{TENANT_ID}/v2.0</issuer>
</issuers>
<required-claims>
<claim name="roles" match="all">
<value>api.request.b2c</value>
</claim>
</required-claims>
</validate-jwt>
</when>
<otherwise>
<validate-jwt token-value="@((String)context.Request.Body.As<JObject>(preserveContent: true)["bearer"])" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
<openid-config url="https://login.microsoftonline.com/{TENANT_ID}/v2.0/.well-known/openid-configuration" />
<audiences>
<audience>{CLIENT_ID}</audience>
</audiences>
<issuers>
<issuer>https://login.microsoftonline.com/{TENANT_ID}/v2.0</issuer>
</issuers>
<required-claims>
<claim name="roles" match="all">
<value>api.request.b2c</value>
</claim>
</required-claims>
</validate-jwt>
</otherwise>
</choose>
<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
<openid-config url="https://login.microsoftonline.com/{TENANT_ID}/v2.0/.well-known/openid-configuration" />
<audiences>
<audience>{CLIENT_ID}</audience>
</audiences>
<issuers>
<issuer>https://login.microsoftonline.com/{TENANT_ID}/v2.0</issuer>
</issuers>
<required-claims>
<claim name="roles" match="all">
<value>api.request.b2c</value>
</claim>
</required-claims>
</validate-jwt>
<cors>
<allowed-origins>
<origin>*</origin>
Expand Down

0 comments on commit 7aac30f

Please sign in to comment.