<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Lambda reconcile does not remove role from registration]]></title><description><![CDATA[<p dir="auto">Lambda reconcile with Azure AD OIDC</p>
<p dir="auto">I have set up an azure application like described <a href="https://fusionauth.io/docs/v1/tech/identity-providers/openid-connect/azure-ad/" rel="nofollow ugc">here</a>. To match the group-ids on azure to our application-specific roles, I set up a reconcile lamba (as the jwt-populate lambda is not available while on oidc), which is as follows:</p>
<pre><code>function reconcile(user, registration, jwt) {
  //groupId matching
  var admin = 'd166c6a0-...';
  var superuser = '738d97af-...';
  var viewer = '8932d06f-...';

  //azure groups are like this
  // "groups": &lsqb;&lsqb;"d166c6a0-..."&rsqb;&rsqb;;
  var groupsAzure = JSON.parse(jwt.groups);

  registration.roles = [];

  user.email = jwt.upn;
  if(Array.isArray(groupsAzure)){
    groupsAzure.forEach(function(groups){      						
      if(groups === admin){
        registration.roles.push('admin', 'superuser', 'viewer');
      }
      if(groups === superuser){
        console.info('superuser!!!!');
        registration.roles.push('superuser', 'viewer');
      }
      if(groups === viewer){
        console.info('viewer!!!!');
        registration.roles.push('viewer');
      }

    });
  }
}
</code></pre>
<p dir="auto">This works perfectly fine (only for testing!) If I login with a "viewer" user, the registration gets the right rule. If I "upgrade" the "viewer" with "admin" permissions, this is also updated in the registration.<br />
But if I "downgrade" a user while removing him from the admin group, the lambda does not update the registration roles.<br />
Do I miss something? Currently using 1.15.2. Thanks a lot!</p>
]]></description><link>https://fusionauth.io/community/forum/topic/939/lambda-reconcile-does-not-remove-role-from-registration</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 08:19:51 GMT</lastBuildDate><atom:link href="https://fusionauth.io/community/forum/topic/939.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 12 Apr 2021 08:34:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Lambda reconcile does not remove role from registration on Wed, 12 May 2021 20:20:29 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/717">@tl-fa</a>,</p>
<p dir="auto">You can view our <a href="https://fusionauth.io/docs/v1/tech/core-concepts/roadmap/#overview" rel="nofollow ugc">Roadmap Guidance</a> regarding how features are implemented into FusionAuth.  A good snapshot of current development can be found <a href="https://github.com/FusionAuth/fusionauth-issues/projects/2" rel="nofollow ugc">here</a> as well.</p>
<p dir="auto">We will certainly update any related issue cards as development moves forward!</p>
<p dir="auto">Thanks!<br />
Josh</p>
]]></description><link>https://fusionauth.io/community/forum/post/2999</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2999</guid><dc:creator><![CDATA[joshua]]></dc:creator><pubDate>Wed, 12 May 2021 20:20:29 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda reconcile does not remove role from registration on Wed, 05 May 2021 07:16:57 GMT]]></title><description><![CDATA[<p dir="auto">Happy to hear that! Any solution is welcome for me, when implemented, I will retest the case. Can you already shout out a date?</p>
<p dir="auto">Cheers,<br />
Thomas</p>
]]></description><link>https://fusionauth.io/community/forum/post/2945</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2945</guid><dc:creator><![CDATA[tl+fa]]></dc:creator><pubDate>Wed, 05 May 2021 07:16:57 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda reconcile does not remove role from registration on Wed, 05 May 2021 06:43:40 GMT]]></title><description><![CDATA[<p dir="auto">Hmm... this is likely a JSON merge issue. See linked issues below.</p>
<p dir="auto">We Marshall objects back and forth from the JS engine via JSON and I the root issue here is likely that JSON merge does not handle arrays.</p>
<p dir="auto">We could fix this by turning off merge for this field, or we will be updating &gt; Java 14 shortly which means we have to ditch Nashorn, so it is possible this new JS engine will allow us to directly manipulate the registration object and ditch the JSON conversation.</p>
<p dir="auto">Related issues:<br />
<a href="https://github.com/FusionAuth/fusionauth-issues/issues/441" rel="nofollow ugc">https://github.com/FusionAuth/fusionauth-issues/issues/441</a><br />
<a href="https://github.com/FusionAuth/fusionauth-issues/issues/571" rel="nofollow ugc">https://github.com/FusionAuth/fusionauth-issues/issues/571</a><br />
<a href="https://github.com/FusionAuth/fusionauth-issues/issues/667" rel="nofollow ugc">https://github.com/FusionAuth/fusionauth-issues/issues/667</a></p>
]]></description><link>https://fusionauth.io/community/forum/post/2944</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2944</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 05 May 2021 06:43:40 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda reconcile does not remove role from registration on Tue, 04 May 2021 06:32:45 GMT]]></title><description><![CDATA[<p dir="auto">No, only the previous roles (as they already include the viewer role). Yes, I am expecting a single role of <code>viewer</code>.</p>
<p dir="auto">If I change the previous roles of the user to <code>superuser</code> and <code>developer</code> (on FA) the resulting set of roles after the lambda is <code>superuser</code>, <code>developer</code> and <code>viewer</code>. So there is an additional role of <code>viewer</code>, but the previous two roles remain.</p>
]]></description><link>https://fusionauth.io/community/forum/post/2940</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2940</guid><dc:creator><![CDATA[tl+fa]]></dc:creator><pubDate>Tue, 04 May 2021 06:32:45 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda reconcile does not remove role from registration on Mon, 03 May 2021 15:04:41 GMT]]></title><description><![CDATA[<p dir="auto">To confirm, you are doing something like this:</p>
<pre><code>registration.roles = [];
registration.roles.push('viewer');
</code></pre>
<p dir="auto">And then the resulting registration contains the previous roles + <code>viewer</code>? And you are expecting a single role of <code>viewer</code>?</p>
]]></description><link>https://fusionauth.io/community/forum/post/2938</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2938</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 03 May 2021 15:04:41 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda reconcile does not remove role from registration on Mon, 03 May 2021 14:42:04 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/3">@robotdan</a><br />
Actually these are roles belonging to my application. I have some more debug informations:<br />
Downgrade Flow:<br />
User on FusionAuth with roles [admin,superuser,viewer]:<br />
<img src="/community/forum/assets/uploads/files/1620050757032-f410c3a2-65e3-42b9-b69f-04bd56e3cf25-image-resized.png" alt="f410c3a2-65e3-42b9-b69f-04bd56e3cf25-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">User on Azure:<br />
<img src="/community/forum/assets/uploads/files/1620051593664-362ed938-503c-46c8-856b-d6d991287ba2-image.png" alt="362ed938-503c-46c8-856b-d6d991287ba2-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Lambda invocation result.</p>
<pre><code>
--- jwt ---
{
  "sub": "5SS_....",
  "amr": "[\"pwd\"]",
  "ipaddr": "......",
  "name": "reader",
  "oid": "2c5cccd....,
  "rh": "0.ATsA112D...",
  "tid": "b9835dd7....."
  "unique_name": "reader@...onmicrosoft.com",
  "upn": "reader@......onmicrosoft.com",
  "uti": "LR1UTJ...",
  "ver": "1.0",
  "groups": [
    "[\"8932d06f-eeb0-444f-a8d8-0c7c9972e311\"]"
  ]
}
--- registration ---
{
  "applicationId": "9d63587b-e17c-4af0-989f-9b965ba94a60",
  "tokens": {
    "7c8a26f1....": "0.ATsA11..."
  },
  "verified": false
}
--- user ---
{
  "active": false,
  "fullName": "reader",
  "passwordChangeRequired": false,
  "twoFactorEnabled": false,
  "verified": false
}
--- azure groups  ---
8932d06f-eeb0-444f-a8d8-0c7c9972e311
mapped group is -&gt; viewer
--- registration after assignement ---
{
  "applicationId": "9d63587b-e17c-4af0-989f-9b965ba94a60",
  "tokens": {
    "7c8a2..": "0.ATsA.."
  },
  "verified": false,
  "roles": [
    "viewer"
  ]
}
--- user after assignement ---
{
  "active": false,
  "fullName": "reader",
  "passwordChangeRequired": false,
  "twoFactorEnabled": false,
  "verified": false,
  "email": "reader@....onmicrosoft.com"
}

</code></pre>
<p dir="auto">The lambda as follows</p>
<pre><code>// Using the JWT returned from UserInfo, reconcile the User and User Registration.
function reconcile(user, registration, jwt) {
 console.info('--- jwt ---');
   console.info(JSON.stringify(jwt, null, 2));
 console.info('--- registration ---');
 console.info(JSON.stringify(registration, null, 2));
 console.info('--- user ---');
   console.info(JSON.stringify(user, null, 2));

 //groupId matching
   var admin = 'd166c6a0-bdd0-4649-b596-0b5ce2c58b49';
 var superuser = '738d97af-f058-4eb3-b3d5-ddbf84df20f9';
 var viewer = '8932d06f-eeb0-444f-a8d8-0c7c9972e311';
 
   var groupsAzure = JSON.parse(jwt.groups);
 console.info('--- azure groups  ---');
 console.info(groupsAzure);
 
 
 registration.roles = [];
 
 user.email = jwt.upn;
   if(Array.isArray(groupsAzure)){
   	groupsAzure.every(function(groups){
     if(groups === admin){
       console.info('mapped group is -&gt; admin');
       registration.roles.push('admin', 'superuser', 'viewer');
       return false;
     }
     if(groups === superuser){
       console.info('mapped group is -&gt; superuser');
       registration.roles.push('superuser', 'viewer');
       return false;
     }
     if(groups === viewer){
       console.info('mapped group is -&gt; viewer');
       registration.roles.push('viewer');
       return false;
     }

   });
   }
 console.info('--- registration after assignement ---');
 console.info(JSON.stringify(registration, null, 2));
 console.info('--- user after assignement ---');
   console.info(JSON.stringify(user, null, 2));
}
</code></pre>
<p dir="auto">the payload of the jwt issued by FushionAuth to the application:</p>
<pre><code>{
  "aud": "9d63587b-e17c-4af0-989f-9b965ba94a60",
  "exp": 1620055251,
  "iat": 1620051651,
  "iss": "https://fusionauth....",
  "sub": "0b867bd9-ffbd-4dd8-a275-f663143c7a70",
  "authenticationType": "OPENID_CONNECT",
  "email": "reader@...onmicrosoft.com",
  "email_verified": true,
  "at_hash": "0MKgnKThS_tyAK460tE_Ng",
  "c_hash": "uSQ7YGhENpZyfTg-iiipWg",
  "applicationId": "9d63587b-...",
  "roles": [
    "admin",
    "superuser",
    "viewer"
  ]
}
</code></pre>
<p dir="auto">The issued jwt from fusionauth still contains the all three roles as before the "downgrade". So it seems that the lambda assignment</p>
<pre><code>registration.roles.push('viewer');
</code></pre>
<p dir="auto">does not work as expected..</p>
]]></description><link>https://fusionauth.io/community/forum/post/2937</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2937</guid><dc:creator><![CDATA[tl+fa]]></dc:creator><pubDate>Mon, 03 May 2021 14:42:04 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda reconcile does not remove role from registration on Sun, 02 May 2021 02:28:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/717">@tl-fa</a> said in <a href="/community/forum/post/2789">Lambda reconcile does not remove role from registration</a>:</p>
<blockquote>
<p dir="auto">registration.roles</p>
</blockquote>
<p dir="auto">In your example, are you trying to modify roles for a FusionAuth admin user (roles that apply when logging into the FusionAuth admin UI) or is this for your application?</p>
<p dir="auto">For reference, if you are trying to modify roles for the FusionAuth admin UI (FusionAuth registration), the roles are documented here. <a href="https://fusionauth.io/docs/v1/tech/core-concepts/roles/#fusionauth-application-roles" rel="nofollow ugc">https://fusionauth.io/docs/v1/tech/core-concepts/roles/#fusionauth-application-roles</a></p>
]]></description><link>https://fusionauth.io/community/forum/post/2928</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2928</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sun, 02 May 2021 02:28:26 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda reconcile does not remove role from registration on Thu, 29 Apr 2021 08:22:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/645">@joshua</a> Thank you very much for your effort. I will try to put some more light on this!</p>
<p dir="auto">Thanks again,<br />
Thomas</p>
]]></description><link>https://fusionauth.io/community/forum/post/2914</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2914</guid><dc:creator><![CDATA[tl+fa]]></dc:creator><pubDate>Thu, 29 Apr 2021 08:22:09 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda reconcile does not remove role from registration on Thu, 29 Apr 2021 01:09:28 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/717">@tl-fa</a>,</p>
<p dir="auto">After discussing this issue, there are three troubleshooting strategies for you to consider:</p>
<ol>
<li>Add debugging statements<br />
-- Add console log statements just preceding and immediately following any time <code>registration.roles</code> array changes.<br />
-- Any other location you can think of to confirm assumptions vs actual behavior</li>
<li>Decouple the Azure OIDC protocol<br />
-- Reproducing the same lambda/js code but using a different OIDC partner/choice would confirm it is not Azure AD creating the issue.<br />
-- Obviously, this is extra lifting codewise, but could prove illuminating and would be confirming.</li>
<li>Change the order of your roles<br />
-- Confirm that if you were to reverse the roles on different groups, you have the opposite behavior<br />
-- For instance, if you were to push <code>admin</code>, <code>superuser</code>, and <code>viewer</code> on to <code>groups.user</code> (and so forth) would things act <em>incorrectly</em> on the 'upgrade' but work <em>correctly</em> on the downgrade (as seen in the current example provided).<br />
-- All this would be in an attempt to confirm the actual behavior of the Array.  Is it resetting correctly upon initialization? Is it getting roles added as we would expect in the array and removed as expected?</li>
</ol>
<p dir="auto">We could certainly troubleshoot more in-depth if you had a <a href="https://fusionauth.io/pricing/editions/" rel="nofollow ugc">support contract</a> so please do let us know if this is something you would need (i.e. - if you are running in production at scale).  I hope this gives you something more to go on.</p>
<p dir="auto">Thanks,<br />
Josh</p>
]]></description><link>https://fusionauth.io/community/forum/post/2913</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2913</guid><dc:creator><![CDATA[joshua]]></dc:creator><pubDate>Thu, 29 Apr 2021 01:09:28 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda reconcile does not remove role from registration on Wed, 21 Apr 2021 05:56:04 GMT]]></title><description><![CDATA[<p dir="auto">Hi Josh,<br />
I was not yet able to get this done. The problem still is, that the assignment of registration rules inside the reconcile lambda. Your help is greatly appreciated.</p>
<p dir="auto">Thanks a lot,<br />
Thomas</p>
]]></description><link>https://fusionauth.io/community/forum/post/2860</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2860</guid><dc:creator><![CDATA[tl+fa]]></dc:creator><pubDate>Wed, 21 Apr 2021 05:56:04 GMT</pubDate></item><item><title><![CDATA[Reply to Lambda reconcile does not remove role from registration on Tue, 20 Apr 2021 22:44:25 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/717">@tl-fa</a>,</p>
<p dir="auto">Were you able to figure this out?  If not, I can review the tutorial that you are working through to see if I have any thoughts.</p>
<p dir="auto">Thanks,<br />
Josh</p>
]]></description><link>https://fusionauth.io/community/forum/post/2857</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2857</guid><dc:creator><![CDATA[joshua]]></dc:creator><pubDate>Tue, 20 Apr 2021 22:44:25 GMT</pubDate></item></channel></rss>