Showing posts with label SSO. Show all posts
Showing posts with label SSO. Show all posts

Monday, 3 May 2021

SSO with Office 365 (Azure AD) using Java (Picketlink) in Tomcat

How to configure Azure Active Directory Federated Single Sign On (SSO) for BuyOnline portal

 

Background

To simplified user authentication process and improve user experiences on BuyOnline, we are enabling  Single Sign On (SSO) features by leveraging Azure Active Directory (AAD).

There are 2 main components involved to enable SSO features on BuyOnline, first is on the application itself which is written on JAVA and secondly on Azure Active Directory (AAD) as Identity Provider (IdP)

This document will only cover the second part which is how to configure SSO for BuyOnline website in Azure Active Directory.

 

Please follow the below steps:

1. Create a Group

Group is used for a logical grouping of BuyOnline users for example a staff, volunteer, etc.

How to create a group in AAD:

Step 1:

After sign-in to Azure portal, navigate to Azure Active Directory -> Users and Groups -> All Groups -> + New Group



 

Step 2:

Add group for example, volunteer and set membership to “Assigned” and give a description.




Step 3:

Assigned user to a group, click “Members” on the group screen and follow the instruction.

2. Registering BuyOnline on Azure Active Directory (AAD)

To establish authentication from BuyOnline to AAD, we have to register the website in AAD.

Step 1: Create New Application

After sign-in to Azure portal, navigate to Azure Active Directory -> Enterprise Application -> All Applications -> + New Application

 



Step 2: Add Non-Gallery Application

Choose “Non-Gallery Application” -> Key In the Name for example buyonline_test for test system and buyonline for production. 



Step 3: Configuring SSO

On the application settings screen, navigate to “Single Sign-On”



 

Set SAML-based Sign-On on the Single Sign-on Mode.

 

Identifier:

TEST: Ananda Please supply the URI

PRODUCTION: Ananda Please supply the URI

 

Reply URL:

TEST: Ananda Please supply the URI

PRODUCTION: Ananda Please supply the URI

 

User Identifier: user.userprinciplename

 

 

“tick” on View and edit all other user attributes and “add attribute”

Name: userid

Value: user.userprincipalname

Namespace: http://schemas.microsoft.com/ws/2008/06/identity/claims



 

3. Create Role for BuyOnline

For authentication purpose, a “manager” role has to be created in the system.

 

Step 1: Adding Manager Role on Application Manifest

Navigate to Azure Active Directory -> App Registrations –> Click on the application name e.g BuyOnline -> Click Manifest




 


Append AppRoles section by addition the below code snippet and click save.

{

      "allowedMemberTypes": [

        "User"

      ],

      "displayName": "manager",

      "id": "d1c2ade8-98f8-45fd-aa4a-6d06b947c66f",

      "isEnabled": true,

      "description": "Its a Manager",

      "value": "manager"

    }

 

Step 2: Assign Role to the User Group

Navigate to Azure Active Directory -> Enterprise Applications -> All Application -> Select your application -> Users & Groups



Assign user group to the role by clicking “+ Add user”



Select the group and assigned “manager” role.

 

 

 

                                                ------------------------------------ END -------------------------------------------

 

 

 

 

 

 

Sunday, 21 June 2015

How to implement SAML SSO in jBoss AS 7.1

SSO is nothing but Single-Sign-On, which is mostly required in the intranet applications where users are not required to enter their credentials, which will be used from the desktop login or AD. There are different way of implementing the SSO in the J2EE Web applications. You can use RSA and install the implemented product in the Web server and you can get all the details in the Payload of the URL. You can also use SAML to implement SSO. SAML is Security Assertion Markup Language. We are going to see how to implement SSO using SAML into jBoss AS 7.1

RedHat has released a separate plugin called PicketLink, through which you can implement the SSO. It has many features like authentication, authorization, social logins and the list is going on. PicketLink has released different version. Since jBoss has moved to EAP and Wildfly, latest version of PicketLink cannot be used for AS 7.1. We need to use the PicketLink-V2.0.2 for configuring the SAML in jBoss AS 7.1

Download the PicketLink sample files from here
jBoss AS 7.1.1 already comes with PicketLink and is available in the location - jboss\modules\org\picketlink.
Go to the folder named main in the above location and open module.xml file
Add a new line and comment the last but one line. Refer the below code
<module xmlns="urn:jboss:module:1.1" name="org.picketlink">
                             <resources>
                                      <resource-root path="picketlink-fed-2.0.2.Final.jar"/>
                                      <resource-root path="picketlink-bindings-2.0.2.Final.jar"/>
                                      <resource-root path="picketlink-bindings-jboss-2.0.2.Final.jar"/>
                                      <resource-root path="picketlink-trust-jbossws-2.0.2.Final.jar"/>
                             </resources>
                             <dependencies>
                                      <module name="javax.api"/>
                                      <module name="javax.security.auth.message.api"/>
                                      <module name="javax.security.jacc.api"/>
                                      <module name="javax.transaction.api"/>
                                      <module name="javax.xml.bind.api"/>
                                      <module name="javax.xml.stream.api"/>
                                      <module name="javax.servlet.api"/>
                                      <module name="org.jboss.common-core"/>
                                      <module name="org.jboss.logging"/>
                                      <module name="org.jboss.as.web"/>
                                      <module name="org.jboss.security.xacml"/>
                                      <module name="org.picketbox"/>
                                      <module name="javax.xml.ws.api"/>
                                      <module name="org.apache.log4j"/>
                                      <!-- <module name="org.apache.santuario.xmlsec"/> --> <!-- Comment this line out -->
                                      <module name="sun.jdk"/> <!-- Add this new module dependency -->
                             </dependencies>
                    </module>
- See more at: https://developer.jboss.org/wiki/HowToConfigurePicketLink202WithJBossAS711#sthash.yYySpqIH.dpuf

You need to update the sun.jdk module definition. Go to the location jboss\module\sun\jdk\main and open module.xml and add the following lines in the respective place
<module xmlns="urn:jboss:module:1.1" name="sun.jdk">
                         <resources>
                              ...
                         </resources>
                         <dependencies>
                              <system export="true">
                                   <paths>
                                        ...
                                        <!-- Add this lines -->
                                        <path name="javax/xml/crypto/dsig"/>
                                        <path name="javax/xml/crypto"/>
                                        <path name="javax/xml/crypto/dsig/dom"/>
                                        <path name="javax/xml/crypto/dsig/keyinfo"/>
                                        <path name="com/sun/org/apache/xml/internal/security/transforms/implementations"/>
                                        <path name="org/jcp/xml/dsig/internal/dom"/>                                       
                                   </paths>
                              </system>
                         </dependencies>
                    </module>         
- See more at: https://developer.jboss.org/wiki/HowToConfigurePicketLink202WithJBossAS711#sthash.yYySpqIH.dpuf

Add the following lines in the standalone.xml of the jBoss AS

<subsystem>
<security-domains>
<security-domain name="idp" cache-type="default">
                    <authentication>
                        <login-module code="UsersRoles" flag="required">
                            <module-option name="usersProperties" value="users.properties"/>
                            <module-option name="rolesProperties" value="roles.properties"/>
                        </login-module>
                    </authentication>
                </security-domain>
                <security-domain name="picketlink-sts" cache-type="default">
                    <authentication>
                        <login-module code="UsersRoles" flag="required">
                            <module-option name="usersProperties" value="sts-users.properties"/>
                            <module-option name="rolesProperties" value="sts-roles.properties"/>
                        </login-module>
                    </authentication>
                </security-domain>
                <security-domain name="sp" cache-type="default">
                    <authentication>
                        <login-module code="org.picketlink.identity.federation.bindings.jboss.auth.SAML2LoginModule" flag="required"/>
                    </authentication>
                </security-domain>
                <security-domain name="cache-test" cache-type="default">
                     <authentication>
                        <login-module code="org.picketlink.identity.federation.bindings.jboss.auth.SAML2STSLoginModule" flag="required">
                            <module-option name="password-stacking" value="useFirstPass"/>
                            <module-option name="configFile" value="sts-config.properties"/>
                            <module-option name="cache.invalidation" value="true"/>
                        </login-module>
                    </authentication>
                </security-domain>
            </security-domains>
</subsystem>

Unzip the files downloaded in the first step and place the WAR files in the deployment folder of the jBoss AS.

After restarting the server, hit the URL localhost:8080/employee. Enter the username and password as tomcat. The values are available in user.properties, part of idp.war file. IDP will perform the authentication and then allow it to Employee application.