Skip to main content

Posts

Showing posts from December, 2015

Rest API using Spring and Hibernate connecting to a PostgreSQL database

In my last post Setting up a Postgresql database , I showed how to install and setup a simple postgres local database. Now I am going to proceed and create a simple java Spring project that exposes a rest api endpoint allowing to query and fetch data from the database. The IDE i am using is Eclipse and I will be using Maven for building the project. To start create a Maven project using the archetype - maven-archetype-webapp. In Eclipse, I enable Dynamic Web Module Facet in the project's properties and set the compiler level to 1.7 at least. Update the pom.xml file to add required dependencies. For our project, we will use spring-webmvc , javax.servlet-api, jackson-core and jackson-databind. These are required to build a rest api endpoing with automatic conversion of java objects to json and vice versa. Also add following dependencies to enable persistence with the postgreSQL database - spring-data-jpa, hibernate-entitymanager, postgresql and jta.  Now

Workaround to bypass Salesforce SSO

One of the best practices for implementing Single Sign On for your Salesforce org is always ensure there is a way your System administrator can login via the standard login page side-stepping the SSO configuration.  Reason for this is if ever something goes wrong with your Idp provider's service and the SSO authentication responses are not coming as expected, all your users are unable to login. That is, if you have setup your My domain to prevent logins via standard Salesforce login urls (login.salesforce.com). This includes the System administrator as well. Only if your system administrator can somehow login, then he or she can disable the SSO settings for your domain and allow login via the normal login page as a temporary measure. What do you do in such a situation? Well Salesforce has built a workaround for this which is not well documented anywhere (probably for a good reason :) ). I found out about it from a colleague at work. If your my domain url is - https://Com

Setting up a Postgresql database

I am working on a new learning project to setup a simple Spring java rest api application. As part of this project, the first step was to setup a database backend for my service. For this I am going to use a PostgreSQL database on my laptop. As I do this, I am going to capture all the steps for anyone who may want to do similar things. My laptop's OS is Xubuntu. So you can use these steps to install the database in Ubuntu or such Linux distributions. Installing in Windows is very similar and differs only in places such as the downloadable to use, the paths used during the installation etc. in linux, you can install most softwares using the OS's package manager. For example, in Ubuntu, you could do: sudo apt-get install postgresql postgresql-contrib . Unfortunately my experience has been that these package managers have old versions of software. So I prefer installing from the distribution website sometimes.  First download the postresql installable (appropriate one fo

Setting up your SSO enabled application as a connected app in your Idp Salesforce Org

This is my final post for my experiment around setting up SSO in a Salesforce org while using another Salesforce org as my Identity Provider. All the other posts related to this experiment are below - Setup my domain in Salesforce Setting up Salesforce as an Identity Provider Enabling SAML based SSO on Salesforce Now I am in the final step of my experiment and am going to login back to my Salesforce org which is acting as my Idp. Here I am going to add a connected app for the SSO enabled Salesforce org by doing the following -  Navigate to the Setup -> Create -> Apps and create a new app under the Connected Apps section In the new connected app, set the field values as -  Name - unique name of the connected app Set the Enable SAML to true in the Web App Settings section Now you will have to fill the data in SAML details that will show up.  The entity id should match the entity id from the SSO app (sso enabled salesforce org my domain url) ACS url - the log

Enabling SAML based Single Sign On (SSO) in Salesforce

Today I continue my little experiment to enable Single Sign On (SSO) on one of my Salesforce Orgs using SAML. For this research, I previously setup another one of my Salesforce developer orgs as my Identity Provider. The steps to follow while setting up an Idp in Salesforce are captured in my previous post - Setting up Salesforce as an Identity Provider . As a first step, you may need information from your Idp to help setup SSO. Things you will need to know are - SAML version (1.1 or 2.0) Entity Id (or Issuer) of the Idp A certificate that will be used to authenticate the requests SAML assertion parameters such as SAML User id type It may be easier to do this setup by obtaining the SAML metadata xml from the Identity Provider. In my case as the Idp is another Salesforce org, I can use the Download Metadata button to download the xml required from the Setup -> Security Controls -> Identity Providers screen. There will be steps the Identity Provider will have to

Setting up Salesforce as an Identity Provider

As I mentioned in my previous post, I am currently working on enabling Single Sign On (SSO) for my Salesforce Org. To do this research, I needed an identify provider that would act as my SAML end point to validate identity requests and respond with valid SAML responses. Well I figured why dont i setup another one of my Salesforce orgs as an Idp provider. Below are the steps i followed to enable one of my Salesforce Orgs as an Idp that is capable of sending SAML responses to valid requests - As a prerequisite to enabling an org as an Idp, you will need to setup a My Domain for that environment. Please see my previous blog for instructions - Setup my Domain on Salesforce .  For the org that will act as your Identity Provider, navigate to the Setup -> Security Controls -> Identity Providers screen Now click the Enable Identity Provider button In the next step, you will be asked to select a certificate to enable secure communication of the SAML requests and respon

Setup my domain on Salesforce

Currently I am setting up SSO (single sign on) for my Salesforce environment. As part of this setup, i needed to setup a domain for the environment first. It is a very simple setup in Salesforce. You may want to setup a domain for your environment for different reasons - 1. Add some branding to your environment (your own environment specific url, a branded login page with your company logo, etc) 2. Security reasons - setup your own login url and force your users to use this. It will prevent access from the standard salesforce login url. 3. Add single sign on for your org with required authentication capabilities Below are the steps I followed for setting up a My Domain url in Salesforce - Navigate to Setup -> Domain Management -> My Domain Populate a unique value in the textbox for the domain name. Choose a value that will make sense to your company and environment. An example screenshot below - Click the register Domain button. The registration takes some ti