# Azure Active Directory SAML for authentication into ignition

**URL:** <https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [July 5, 2023, 7:49pm UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960 "2023-07-05T19:49:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mandeep\_gill](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mandeep\_gill](https://forum.inductiveautomation.com/u/mandeep_gill)\
**Post date:** [July 5, 2023, 7:49pm UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/1 "2023-07-05T19:49:38Z")

</div>

Hi Team,  
We are doing some work to integrate ignition for Active directory.

Following is what my college has done and results of it. Do we have other documentation which can help us to setup users within ignition.

The businesses are transitioning towards standardizing the use of Azure Active Directory SAML for authentication for all business applications. During my , I successfully implemented SAML integration in Ignition by following the instructions provided in the documentation: [https://docs.inductiveautomation.com/display/DOC80/SAML+Example](https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.inductiveautomation.com%2Fdisplay%2FDOC80%2FSAML%2BExample&data=05%7C01%7CMandeep.Gill%40silverfernfarms.co.nz%7C6ffa56206fec460f3f0108db7d8fa7fe%7Ca88935c3586c4558957867aabfe160a8%7C0%7C0%7C638241828172062645%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=P8LzvRX5AuMnvUsTMk%2F7BJgMwcKC%2F7NlDj6Mpa5oa7s%3D&reserved=0). However, I'm currently uncertain about the subsequent steps necessary to map users with their respective roles and permissions within the Ignition application. Additionally, I'm a bit confused about how to integrate the Active Directory security groups into the Ignition application.

---

<div class="post-metadata">

**Author:** ![nicholas.robinson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicholas.robinson/32/22188_2.png) [@nicholas.robinson](https://forum.inductiveautomation.com/u/nicholas.robinson)\
**Post date:** [July 6, 2023, 1:59am UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/2 "2023-07-06T01:59:20Z")

</div>

@mandeep_gill what you will get back from a SAML IDP is a list of AD group names that you have been granted access to. What you want to do is convert those to roles.

We accomplish this with a scripting module that plugs into ignition and is called from the roles user attribute field with an expression. We pass in the ad groups and the host name like this:

```auto
runScript("system.idp.processIdpResponse("+{idp-attributes://saml:Attribute[@Name='adgroups']}+", system.net.getHostName())") 

```

In the actual module it simply does this (some things retracted for privacy):

```auto
    @Override
    protected ArrayList<String> assignRoles(List<String> samlResponse, String hostName, String country) {
        ArrayList<String> adGroups = new ArrayList<>();
        ArrayList<String> assignedRoles = new ArrayList<>();
        HashMap<String, List> roleMap = new HashMap<>();

        for (String member: samlResponse){
            adGroups.add(member.split(",")[0].replace("CN=", ""));
        }

        String siteNum = getSiteNum(hostName);

        if(!siteNum.equals("other")) {
            String base = "hidden" + siteNum;

            roleMap.put("User", Collections.singletonList(base));
            roleMap.put("Operations", Arrays.asList(base + "_ops", "hidden"));
            roleMap.put("Maintenance", Collections.singletonList("hidden"));
        }
        else roleMap.put("Operations", Collections.singletonList("hidden"));

        roleMap.put("ReadOnlyUse", Collections.singletonList("hidden"));
        roleMap.put("siteEngineering", Collections.singletonList("hidden"));
        roleMap.put("remoteEngineering", Collections.singletonList("hidden"));
        roleMap.put("Developer", Arrays.asList("hidden"));

        for (String role : roleMap.keySet()) {
            for (String adGroup : adGroups) {
                if (roleMap.get(role).contains(adGroup.toLowerCase())) {
                    if (!assignedRoles.contains(role)) {
                        assignedRoles.add(role);
                    }
                }
            }
        }
        return assignedRoles;
    }
}

```

Rgds,

Nick

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [July 6, 2023, 8:32am UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/3 "2023-07-06T08:32:35Z")

</div>

Any particular reason for making a module?

I do a similar thing but utilise the gateway scripting project and just call a function there.

---

<div class="post-metadata">

**Author:** ![mandeep\_gill](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mandeep\_gill](https://forum.inductiveautomation.com/u/mandeep_gill)\
**Post date:** [July 17, 2023, 8:12pm UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/4 "2023-07-17T20:12:57Z")

</div>

> [@nicholas.robinson](#):
>
> `system.idp.processIdpResponse`

Thanks Nic,  
I can't compile the script in gateway script under timer. I believe there is syntax error.....

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/9/69c7216a79a8d30d2f479ffa7d0b264f784339f2.png)

or i am doing something wrong here?.... i haven't dealt with classes or modules in ignition...

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 17, 2023, 9:32pm UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/5 "2023-07-17T21:32:09Z")

</div>

> [@mandeep\_gill](#):
>
> I can't compile the script

NIck's example is java from a 3rd-party add-on module, not jython. You will need to reimplement in jython or develop a 3rd-party module.

---

<div class="post-metadata">

**Author:** ![mandeep\_gill](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mandeep\_gill](https://forum.inductiveautomation.com/u/mandeep_gill)\
**Post date:** [July 17, 2023, 10:09pm UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/6 "2023-07-17T22:09:14Z")

</div>

> [@pturmel](#):
>
> NIck's example is java from a 3rd-party add-on module, not jython. You will need to reimplement in jython or develop a 3rd-party module.

Thanks Pturmel,  
Is there any other way to use the built in functions of ignition to deal with SAML..... or best practice to go about it?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 17, 2023, 10:11pm UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/7 "2023-07-17T22:11:47Z")

</div>

Nick's sample looks pretty good. Treat it as pseudocode as you write your own jython. (As noted by deon, that is perfectly reasonable.) I don't do any of this with my clients, so I have no first-hand samples for you.

---

<div class="post-metadata">

**Author:** ![david.l](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@david.l](https://forum.inductiveautomation.com/u/david.l)\
**Post date:** [July 17, 2023, 11:12pm UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/8 "2023-07-17T23:12:10Z")

</div>

We use OpenID Connect for Azure AD instead of SAML but they should be close in implementation. It seems you have the roles coming across already.

You should be able to use those Roles everywhere where you used to use a native Ignition role. Ignition might not recognize it when you type it in but it should work. Have you tried to see if it works?

---

<div class="post-metadata">

**Author:** ![mandeep\_gill](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mandeep\_gill](https://forum.inductiveautomation.com/u/mandeep_gill)\
**Post date:** [July 18, 2023, 1:21am UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/9 "2023-07-18T01:21:13Z")

</div>

Thanks David,  
No i havn't tried it yet. what is the syntax to use in scripting?

---

<div class="post-metadata">

**Author:** ![david.l](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@david.l](https://forum.inductiveautomation.com/u/david.l)\
**Post date:** [July 18, 2023, 1:31am UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/10 "2023-07-18T01:31:55Z")

</div>

Our roles are mapped to security groups in Enterprise Applications (Azure AD terminology). Therefore we add users to those groups in Azure AD, then that information is brought over to Ignition via the mapping in the Users/Groups section of Enterprise Applications.

In Ignition, the user comes across with the roles. I believe you had this in one of your screenshots so that is showing that it is working. The difference is that the same role list would have all of our Ignition roles in it as well (created in Azure AD as security groups, then mapped to Roles in AzureAD)

Therefore, no more mapping of users to roles is needed in Ignition. I believe we did not create roles in Ignition either (just Azure AD)

We just add the roles wherever we used them before such as Client Roles for Login.

We don't do a hybrid method (creating Roles in Ignition while doing Azure AD authentication). My guess is it's possible, but we decided not to do that. We figured internet is required for authentication, might as well just do the groups in Azure AD as well.

---

<div class="post-metadata">

**Author:** ![mandeep\_gill](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mandeep\_gill](https://forum.inductiveautomation.com/u/mandeep_gill)\
**Post date:** [July 21, 2023, 2:27am UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/11 "2023-07-21T02:27:31Z")

</div>

Thanks Everyone, I am able to setup most of it.  
When i logon to gateway or designer it is going through IdP. but when i opened the project, it is not showing the configured security level for that IdP. I am not sure if anything else needs to be configured? or i am making mistake somewhere.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/a/daa0a236859db8962ff842d432b2b32bcd35e21f.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/e/7ec1bcde5ca21ce32c0b0b4096b200e103d3bb25.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/9/3959a94d877e925c3e727c69dc0fe5b798315e1a.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/0/9037254b04d8f116f4fdec7124cb430f308dd793.png)

---

<div class="post-metadata">

**Author:** ![nicholas.robinson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicholas.robinson/32/22188_2.png) [@nicholas.robinson](https://forum.inductiveautomation.com/u/nicholas.robinson)\
**Post date:** [July 25, 2023, 5:04pm UTC](https://forum.inductiveautomation.com/t/azure-active-directory-saml-for-authentication-into-ignition/75960/12 "2023-07-25T17:04:50Z")

</div>

The main reason to do it as a module and not python code is distributability and being more able to lock down the code. Modules are far more difficult to modify than python code in the designer and something that affects the ability to login is something you want to be as secure as possible.

Nick
