# Conditional multi-factor rule removes permissions from JWT

**URL:** <https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403>\
**Category:** Get Help\
**Tags:** multi-factor, rules, permissions\
**Created:** [December 20, 2019, 5:10am UTC](https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403 "2019-12-20T05:10:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex16](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alex16/32/12732_2.png) [@alex16](https://community.auth0.com/u/alex16)\
**Post date:** [December 20, 2019, 5:10am UTC](https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403/1 "2019-12-20T05:10:14Z")

</div>

Hello,  
In my setup the API has RBAC enabled as well as Add Permissions in the Access Token.  
At the same time there is a conditional MFA rule as following:

> function (user, context, callback) {  
> if (context.clientID === ‘’ && user.user\_metadata.use\_mfa !== “false”) {  
> context.multifactor = {  
> provider: ‘any’,  
> allowRememberBrowser: false  
> };  
> }  
> return callback(null, user, context);  
> }

Whenever use\_mfa is false (no multi-factor) the permissions are properly added to the JWT. However, when use\_mfa is true, permissions are missing.

Please help! This had me running in circles for awhile ☹

Alex

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [December 26, 2019, 11:04am UTC](https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403/2 "2019-12-26T11:04:27Z")

</div>

I was unable to reproduce this in a lab environment with only that rule enabled; for reference here’s the steps I did:

1. create a user, API and client application.
2. enable RBAC in API, set a permission directly to the user and configure user metadata to not request MFA.
3. login with the user and confirm the permissions are there in the token.
4. enable MFA in user metadata.
5. login again with the user.

In the last step I still saw permissions in the access token.

Can you confirm that is the only rule you have enabled in the tenant? If it is not it would be worthwhile to test with all other rules disabled and also provide more information about how you’re performing the login. For example, I used the new universal login experience to complete my test logins.

---

<div class="post-metadata">

**Author:** ![alex16](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alex16/32/12732_2.png) [@alex16](https://community.auth0.com/u/alex16)\
**Post date:** [December 26, 2019, 2:25pm UTC](https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403/3 "2019-12-26T14:25:23Z")

</div>

Thank you for your response!

This rule is the only rule in the tenant. Removing it, brings permissions back into the JWT.

The users in the app are required MFA on a certain condition. The use\_mfa flag is set to true when it is required. Type of the flow that is used here is username/password and a DB connection.

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [December 27, 2019, 9:52am UTC](https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403/4 "2019-12-27T09:52:08Z")

</div>

Can you share a sample access token for the two scenarios (with rule and without rule)? You can remove the signature part to make the token useless and if you want to go beyond you can just include the JSON payload with redacted personal information.

If you redact information please replace it in a consistent way in both tokens and use equivalent data. For example, if both tokens contains a user email address `john.doe@example.com` replace it by `user@example.com` in both.

---

<div class="post-metadata">

**Author:** ![alex16](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alex16/32/12732_2.png) [@alex16](https://community.auth0.com/u/alex16)\
**Post date:** [January 2, 2020, 3:33pm UTC](https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403/5 "2020-01-02T15:33:23Z")

</div>

Here is the token with MFA (signature removed):

eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik5rVXpRVE0xTnpReE16azJPRFl6UlRSRE1USTFRall6TmtKRk16TkZNMEUzUTBNM1FUUTRRUSJ9.eyJpc3MiOiJodHRwczovL2Ryb3BmaXRuZXNzLmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw1ZTBlMGE0NWMzMzQzYjBmMzEzNDc4ZTgiLCJhdWQiOiJodHRwczovL2Ryb3BmaXRuZXNzLmNvbS9hcGkiLCJpYXQiOjE1Nzc5Nzg1MDAsImV4cCI6MTU4MDU3MDUwMCwiYXpwIjoiSWRtTzNjUTZFUVJadTJNNm9NcGhpMDI3VHZzc2pJVGEiLCJndHkiOiJwYXNzd29yZCJ9

This one is without MFA:

eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik5rVXpRVE0xTnpReE16azJPRFl6UlRSRE1USTFRall6TmtKRk16TkZNMEUzUTBNM1FUUTRRUSJ9.eyJpc3MiOiJodHRwczovL2Ryb3BmaXRuZXNzLmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw1ZTBlMGJhNjUyZWU0ZTBmNGU0ZGI4ZTkiLCJhdWQiOiJodHRwczovL2Ryb3BmaXRuZXNzLmNvbS9hcGkiLCJpYXQiOjE1Nzc5Nzg3OTEsImV4cCI6MTU4MDU3MDc5MSwiYXpwIjoiSWRtTzNjUTZFUVJadTJNNm9NcGhpMDI3VHZzc2pJVGEiLCJndHkiOiJwYXNzd29yZCIsInBlcm1pc3Npb25zIjpbIm1hbmFnZTpzZWxmIiwicmVnaXN0ZXI6bWVtYmVyIiwic2VuZDplbWFpbCJdfQ

The last one has permissions in the payload as expected.

TIA!

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [January 8, 2020, 1:15pm UTC](https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403/6 "2020-01-08T13:15:23Z")

</div>

Thanks for sharing; I confess that I initially assumed only one user was being used for testing this and that the user profile was just updated to toggle MFA on and off, but for the provided tokens the `sub` claim is different which indicates different users. With different users there’s much more scenarios that could explain the difference in issued token.

Is it possible for you to perform the tests with the same exact user?

---

<div class="post-metadata">

**Author:** ![vitaliy.obideyko](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vitaliy.obideyko/32/27984_2.png) [@vitaliy.obideyko](https://community.auth0.com/u/vitaliy.obideyko)\
**Post date:** [March 4, 2021, 9:03am UTC](https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403/7 "2021-03-04T09:03:59Z")

</div>

@jmangelo I have the same problem. I did it with the same user, and if user logged in without mfa then permissions is presented, but if use mfa - they omitted  
@alex16 is there a solution to this problem?

---

<div class="post-metadata">

**Author:** ![vitaliy.obideyko](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vitaliy.obideyko/32/27984_2.png) [@vitaliy.obideyko](https://community.auth0.com/u/vitaliy.obideyko)\
**Post date:** [March 9, 2021, 11:09am UTC](https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403/8 "2021-03-09T11:09:17Z")

</div>

Now it have been **fixed** on Auth0 side

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 9, 2021, 2:45pm UTC](https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403/9 "2021-03-09T14:45:18Z")

</div>

Glad it’s working now!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 8, 2024, 8:28am UTC](https://community.auth0.com/t/conditional-multi-factor-rule-removes-permissions-from-jwt/35403/10 "2024-01-08T08:28:59Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
