December 19, 2016

Social connect Module for Dxa - Internals - Part 2

Social connect Module was developed using Microsoft's OWIN implementation, which actually make it easy to write code.

Nuget packages

 <package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />  
  <package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Facebook" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Google" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.OAuth" version="2.1.0" targetFramework="net45" />

This is most important file of the module. it plugs the module in mvc lifecycle to ensure user is logged in and prompt whenever required for login.

 [assembly: OwinStartup(typeof(Sdl.Web.Modules.Social.Startup))]  

startup.cs has method ConfigureAuth which has responsibility to Register Social networks and add required claims to be returned by the respective social network.

upto now, no Dxa involvement was required but now will start integrating Dxa step by step.

SocialController :
This controller acts as main interaction of the system. it triggers following as per the Component template of the module

  • Show the Social network options to user
  • Trigger required social network to prompt for credentials
  • Receive token from Social network to validate it & Read the claims and show log out options.
  • Log outs from system

for above 4 set of activities we need different Component templates.

For last three activities three different pages have been created so that only specified activity is triggered as per the need of user. First activity is part of Header page.

If you need to retrieve authentication status or User information following can be used.

  • Request.IsAuthenticated
  • User.Identity.GetUserName()

December 15, 2016

Packaging an SDL DXA Custom Module

SDL has provided good API's to develop an DXA module. I have recently published two modules

  • JwPlayer Module
  • Social Connect/Login Module (updated)
Though creation of module is of medium complexity but packaging of module is also not easy. so i had hard time initially packaging a module. 

Packaging essentially means providing CMS and CD part in one zip file with respective power-shell scripts to automate the installation on CMS(via calling core Service) and deploying the necessary files on the website. 

CM Part- CM part is where building blocks along with required components, content porter package is created. it has three parts

  •  Import Export folder - Where SDL provided Dlls and powershell scripts are kept which helps in importing the module.
  • Content Porter Package -  To Export content porter package
    • Do not select dependencies
    • Select all required component and pages at website publication only, with setting select folder and all children. in this way only small package with required items will be created.
  • Custom Export Power shell script
    • Download some existing DXA module
    • Take script of that
    • and do required modifications
CD Part - 
  • Copy your Area and respective views
  • Copy required dll into Bin folder
  • Use existing power-shell script from some module
  • if you have custom setting like. web.config to update etc. then write the required power-shell script. refer my social login module for that. 
now try above and zip it for delivery.

Social connect module for DXA - Part 1

 recently published Social Connect module for Digital Experience Accelerator. which extends Dxa to login using social network.

Currently this module supports two social networks
  • Facebook
  • Google Plus
but i will try to add Twitter and linked-in later.

After installing this module you will find login link on your Dxa menu.
After click on the Login link you should find below option to select.
After clicking on above e.g Facebook. Facebook will ask for Credentials to enter. after successfully validating. Facebook will return back to Dxa application with token and other details in form of claims. 

Custom modules will receive inputs from the Facebook and accordingly update the UI with logged in name and logout link.

Similarly when after clicking on Google, it will take you to Google login and ask for credentials and OTP. and take back to application with claims. claims are processed and use is logged in.

To achieve above there are few settings to be done at Facebook and Google console where return URL etc are returned

Google requires to create credentials at
  • Create Auth 2.0 Client-id
  • Give it a name, 
  • Mention Return URL of your application, which will receive the token after successfully authenticated by Google.
  • for Google default URL will always be http://your-domain/signin-google.

I tried to have other endpoint as well but did not work for me so i kept default Url for my testing.

Similarly for Facebook you have to create new App and provide your site's Domain and URL. it will also redirect on your siteurl on a default page with name: /signin-facebook again Owin automatically intercept this and accordingly validate the token and proceed to next steps.

November 29, 2016

Topology manager Tips and Tricks

While working on Web 8 from last 7 months i have few tricks to share

Register multiple Url for single websites : While in development here are various scenarios where we need multiple domain url for the website.

e.g Mobile testing, as we mock the url using IIS host entry, but it does not work on Android and IOS very well, so we have to test on IP on those devices.

Another case when multiple CMS developer working on their on their own DXA copy and they need separate URL for developer's local websites.

With following command you can register multiple Urls for same website.

 PS C:\Windows\system32> Set-TtmWebsite -id Website1 -BaseUrls 
"", ""  

Change Topology Manager database: I changed my VM machine's Server name and suddenly Tridion stopped working. now i have to update server name everywhere in the system from CM to CD. it took me 2-3 days to find out all the instances where Server name was referred.  but still i could not figured out topology manger database reference, then after wasting lots of time i figured out TM's connection string with server-name is embedded in the web.config in encrypted form.

Use following commands to change server name/database of Topology manager. take backup of the web.config file of your Topology manager website, and decrypt it using following command then change the connection string and encrypt it again.

Take backup of your config first

Decryption command
 C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -pdf "database" "C  
 :\Program Files (x86)\SDL Web\TopologyManager\web"  

Encryption command
 C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -pef "database" "C  
 :\Program Files (x86)\SDL Web\TopologyManager\web"  

November 18, 2016

Sdl Web 8 Dxa Installation - Content Delivery

Content Delivery installation requires few services to be installed and configured. SDL also introduced all new Discovery Service in the web 8 which acts as gateway for all the CD services.
Please find below Different services to be installed.
  • Content/Session-enabled Content Service
  • Content Deployer Service
  • Preview Service
  • Context Service
  • Discovery Service

Content/Session-enabled Content Service
if staging environment,  where XPM etc is enabled, is being configured only Session-Enabled content service is required to be installed and configured. other Content Service is not required to be installed.

Content Deployer Service: Pre web-8 separate http-upload website was hosted on IIS, but with web 8 deployer windows service itself host the required service to deploy the content. Installation is pretty state-forward, just follow the steps mentioned in installation document

Discovery Service 

Once all the above services are installed now you can registered these capabilities into the Discovery Service Registered these capabilities into Discovery Service using Discovery Service registration command.

The discovery service cd_storage_conf config file should have the service entries as shown below.

When you install discovery service, Separate database is recommended for it. This database share same structure as content database but purpose is to keep discovery information separately. 

Run power shell and execute following command

 java -jar discovery-registration.jar update  

This command will update the Discovery database with latest values from cd_storage_conf file. basically it will register the services with different capabilities defined in storage config file.

Discovery Service become gateway service for all the installed capabilitiy. e.g earlier we used to configure http-upload endpoint in the CMS, which actually was source of lots of error when CMS db was backed up from live to UAT etc.

but now Discovery service is registered in CMS, so when something is published request goes to discovery service, its checks whether it has that deploying capability or not. if yes it pass the torch to Content-Deployer and subsequent request goes to Content deployer directly.

Same case with content service etc.

so your ports etc for all the services should be open for your website. e.g you have local sanddbox for DXA and content service is installed at 8089 port. 8089 port should also be accessible at your website box because after discovery resolve the dependency then direct communication between service happens.

October 28, 2016

Custom Dxa Modules Creation - Presentation

SDL Web 8 Developer Summit  2016 was second event in India and was really enjoyed by 50+ Audience including few Mvps including Nuno and Bart. Two days event was a great success.

All the goodies were great especially Pen drive.

I presented step by step way to create Dxa modules. which was really appreciated by all especially Nuno. I am sharing here my slides below for benefits of others. We will come with next season of summit next year as well.

October 18, 2016

Content Type Basics - Web 8 XPM

Content Type - It is predefined Component presentation that can be added to a Page using Experience Manager if that Component type is allowed on particular Page Template.

How to create  - Go to publication Property on the tab "Content type", at bottom click on Insert. you will see following form on the screen.

Already defined component presentation on a page automatically become content type for that page.

All the fields are very descriptive itself.  Define you content type at some common publication 
e.g Website Site Master. so that it gets available to all the site publication in XPM.

There are two types of settings in Content Type:
  • Blueprint Context Setting
  • Content type mapping Setting
Blueprint context Settings: Here we define if  a component for is created for a page in any publication what should be physical location of that component. as pages and components are created in different publications.
Just choose the publication here.
Content Type Mapping: In this mapping we basically specify mapping between Page template and Content type. e.g Carousel content type should only be available on Article and home page template

So you can do this setting on parent publication and post that. its get available to all child publication. 

Because "Inherit setting from Parent" is selected by default on all publications. so this setting get automatically available to all child publications. if you wan to override these settings, you can un-check the check-box and define new setting for that required publication.

Here you see all content type available in choose publication. here you can define what all Content type are available to which page template

Content type usage in XPM

After defining the content type, time to use it on desired pages. So load the XPM with the target page where you need to insert the content. when page loads. make sure lock sign in not there on top of the page. else you will not see options under Insert Content, as shown below

when you load a page in Xpm, and select Create and insert New Content option, on left side slider all content type enabled(which we did in last steps) on that PT is shown here. You choose it and it show you form to give a name to the component and choose the folder of that component, if you want to go ahead with earlier selected location that is also OK.

Publication for the component is chosen as per the blueprint context you set in settings.

Some issue exists in Content type
  1. Only first level of components are cloned in content types any linked component is not cloned but same component is used.
  2. When we create Content-type and choose folder location, it does not pick the blueprint context but show the folder from that publication only.
    but when you create component in XPM publication and folders are selected as per blueprint context. if folder choose at creation of content type not exists in the publication as per blueprint context, XPM throws Error.

October 14, 2016

SDL Web 8 & DXA Installation - CM

To install typical DXA and Web 8 copy , following are the essential steps.
  • CM Installation
    1. Database setup (run database Power-Shell scripts)
    2. CMS installation (run the execute table file)
    3. Configure Topology Manager (First we need to install the CD services)
  • CD Installation
    1. Install all the content delivery services (windows service).
    2. Registered these capabilities into Discovery Service using Discovery Service registration command.
  • DXA Installation on CM server 
    1. Import DXA into the Content Manager
    2. Publish the Example Site (or at least a minimal set of Content Manager items) to get the Web site content into the Content Data Store from where it can be retrieved by the Web application on page request
  • DXA Installation on CD server
    1. Install/Host DXA web application by running the PS script and once done run the site to see the page renderings.
    2. Check Pre-requisites here for CMS
  • Setup Machine
    1. Get ready with a Microsoft Windows Server 2012 R2 (x64) and logged into it with your Content Manager Administrator User.
    2. .Ensure that you have installed MS SQL Server 2014 or MS SQL Server 2012 R2 SP2.
    3. Create an MTS User – Preferably with Admin rights else we can choose it to be under normal User group under your domain system. 
  • DB Installation 
    1. Open Windows Powershell by right clicking as choosing “Run As Administrator” 
    2. Navigate to SDL Web8 Installation media path in Powershell – .\SDL_Web_8\Database\mssql
    3. Databases to be Created
      • Content Manager Database 
      • Topology Manager Database 
      • Content Data store/broker Database 
      • Discovery Service Database 
      • Preview Session (XPM) Database 
Note: Last three databases share same schema ie. Content Data Store.
  • Content Manager Installation 
  1. Navigate to the SDL Web Installation Media and run SDLWeb8 executable by right clicking and choosing “Run as administrator” 
  2. Wizard will prompt for selecting the required components. 
  3. Next the setup will shows you all the missing prerequisite which SDL Web must have to work properly – o accept to install these missing prerequisite: 
  4. Once the prerequisites are all installed, you need to provide details of your MTS User: 
  5. Enter the details of Content Manager DB as created in earlier step 
  6. Enter the details of Topology Manager DB as created in earlier step 
  7. Next enter the Environment ID – It is typically to identify your CM instance in case of a scaled out and/or load balanced environment. For a standalone environment, you can leave it default: 
  8. for next step of wizard enter requested information and done with the installation.
Restart your CM Server after installation and enjoy the updated User-Interface.