OpenID Connect Sample web app
OpenID Connect Sample Web App
In this document, I'm trying to demonstrate OpenID Connect with a sample web application. Before doing this we need to have a good idea about OpenID Connect. So if you need to learn about OpenID Connect you can read my previous post.
I'm using MiniOrange as my OpenID Connect provider. There are some steps to follow to setup the OIDC application with MiniOrange.
- First, create an account on miniorange and sign in to the account.
- Then go to the miniOrange Administrator Console.
- Create an application by selecting Apps > Configure Apps.
- In the Application name type “OIDC”.
- Enter your client information(First_name,Last_name) and Save.
- Once you have configured the application. Please note down the clientID and client secret by going to Apps > View Apps then Select your Open Id application and click on “Edit”.
- Then add this redirection endpoint to the application.
- Again go to the miniOrange Administrator Console.
- Go to Policy > App Authentication Policy. Then select the tab “Add Policy”.
- In the Application, name select the OpenID Application that you have created.
- Enter configuration settings and Save.
You can configure sample application using your details.
Configure the OpenId Connect application in miniOrange Admin Console with the redirect URI : https://www.miniorange.com//openid-Sample-webapp/OpenIdResponse.
- We need to edit client secret so, go to the Constraints.javavfile and edit it. Open the Constants.Java file and initialize the following variables
HOST NAME = miniOrange host provider(example : auth.miniorange.com) without the HTTP/PORT/SUBDOMAIN name
CLIENT SECRET = enter the client secret noted from our miniOrange Admin Console
- Edit the client id according to your client id in index.jsp
Building the project
- Add all the dependencies and run the following maven commands to add our third-party library MiniOrange-OpenID-api.jar
mvn install : install-file -Dfile="/lib/miniorange-openid-api.jar"
Dgroupld=com.miniorange.openidclient-
Dartifacld=miniorange-openid-api -Dversion=3.6-
Dpackaging=jar
2.Run "mvn clean package"at the pom directory level and deploy the ".war" file to apache tom cat.
Testing the project
Ucing our client credintial we can get the user concern page
- Username :bunny123@gmail.com
- abc123
Then click on the authorize button to give the permission to the client app.
After clicking it we can get the access token and id token.
Comments
Post a Comment