# Converting rule to action for wsfed auth

**URL:** <https://community.auth0.com/t/converting-rule-to-action-for-wsfed-auth/120065>\
**Category:** Get Help\
**Tags:** application, addons\
**Created:** [November 2, 2023, 12:02pm UTC](https://community.auth0.com/t/converting-rule-to-action-for-wsfed-auth/120065 "2023-11-02T12:02:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hales8181](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@hales8181](https://community.auth0.com/u/hales8181)\
**Post date:** [November 2, 2023, 12:02pm UTC](https://community.auth0.com/t/converting-rule-to-action-for-wsfed-auth/120065/1 "2023-11-02T12:02:50Z")

</div>

I am trying to convert a rule that we have in use for applications with the wsfed addon:

> function (user, context, callback) {  
> var roleProperty = ‘roles’;  
> if (user.hasOwnProperty(‘role’)) {  
> roleProperty = ‘role’;  
> }  
> context.samlConfiguration.mappings = {  
> ‘[http://schemas.microsoft.com/ws/2008/06/identity/claims/role](http://schemas.microsoft.com/ws/2008/06/identity/claims/role)’: roleProperty,  
> ‘[http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name](http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name)’: ‘name’,  
> ‘[http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier](http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier)’: ‘email’  
> };  
> callback(null, user, context);  
> }

Which works with no issue, I am trying to replace it with an action ahead of the deprecation with:

> exports.onExecutePostLogin = async (event, api) =\> {
> 
> var roleProperty = ‘roles’;  
> if (event.user.hasOwnProperty(‘role’)) {  
> roleProperty = ‘role’;  
> }
> 
> api.samlResponse.setAttribute(‘[http://schemas.microsoft.com/ws/2008/06/identity/claims/role](http://schemas.microsoft.com/ws/2008/06/identity/claims/role)’,roleProperty);  
> api.samlResponse.setAttribute(‘[http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name](http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name)’,event.user.name );  
> api.samlResponse.setAttribute(‘[http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier](http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier)’,event.user.email );
> 
> console.log(api.samlResponse)  
> };

but I get a http error 403, and the results of my console.log(api.samlResponse) in wetask logs is just:

> Kc {}  
> Blockquote

The actual log itself in Auth0 is type Sucess Login.

I’m not sure what I’m doing wrong

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 6, 2023, 10:43pm UTC](https://community.auth0.com/t/converting-rule-to-action-for-wsfed-auth/120065/3 "2023-11-06T22:43:00Z")

</div>

Hi @hales8181,

After reviewing your Post Login action script, everything looks good. However, I noticed that you are trying to call `console.log(api.samlResponse)`, which is not a property you can call to view the samlResponse. That’s why the returned response from the Realtime Webtask logs produced `Kc{}`.

Only the properties defined [here](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/event-object) can be called in the Post Login action script. In this case, you will have to check the actual samlResponse to see if the mappings are done correctly.

Thanks,  
Rueben

---

<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:** [December 1, 2023, 1:31am UTC](https://community.auth0.com/t/converting-rule-to-action-for-wsfed-auth/120065/4 "2023-12-01T01:31:25Z")

</div>

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