Home
english
Home
.NET Server
Java Server
.NET Client
AJAX Client
AJAX Browser
Map Drive
Pricing
Contacts
info@ithit.com



AJAX File Browser Authentication and SSL

The Ajax File Browser supports SSL as well as any authentication supported by a user agent. In many cases you will rely on a user agent authentication mechanisms and do not need to care about authentication. By default the user agent will present the login dialog when required, requesting for credentials. The user agent will keep the credentials and use it when necessary automatically.

If you would like to create your own custom login dialog you can set the credentials using SetCredentials method of WebDavSession object provided by each IT Hit AJAX File Browser instance:

var ajaxFileBrowser = new ITHit.WebDAV.Client.AjaxFileBrowser.Controller('AjaxFileBrowserContainer', 'http://webdavserver.com/', 'height: 500px; width: 500px');
ajaxFileBrowser.GetSession().SetCredentials('User1', 'pwd');
ajaxFileBrowser.SetSelectedFolder('/');

If you set the credentials via SetCredentials method the default browser login dialog will not popup.

Important! Internet Explorer and Microsoft Office on Windows 7 and Windows Vista by default require SSL connection for Basic authentication. Details about how to overcome this limitation could be found here.

Authentication in Safari

If your page containing Ajax File Browser is NOT under authentication, but your server requires authentication the Safari login dialog will not show and Ajax File Browser will display an error. This is because unlike other browsers, the login dialog in Safari is never displayed for XmlHttpRequest requests.

To display the login dialog, Safari must first sent the GET request. This request cannot be sent via XmlHttpRequest but only via directly accessing server, for example via iframe. The iframe onload event always fired after user enters credentials to login dialog. Only when iframe onload event fires, the Ajax File Browser can sent requests. If authentication fails, onload event never fires. Below you can see a sample code that you can use to create Ajax File Browser in Safari:

var webDavServerUrl = 'http://webdavserver.com/dav/';

 

function onLoad() {
    // If this page is NOT under authentication, but your server requires authentication the Safari does not show login dialog. 
    // We have to create hidden iframe to get the login dialog and to authenticate.
    if ((navigator.userAgent.indexOf('Safari') != -1) && navigator.userAgent.indexOf('Chrome') == -1) {
        var iframe = document.createElement("IFRAME");
        iframe.style.display = "none";
        document.body.appendChild(iframe);
        iframe.onload = initAjaxFileBrowser; // iframe onload event fires only when user succesefully authenticated              
        iframe.src = webDavServerUrl; // you can specify any page that requires authentication here
    }
    else {
        initAjaxFileBrowser();
    }
}

 

function initAjaxFileBrowser() {       
    var settings = {
        Id: 'AjaxFileBrowserContainer',   // ID of the HTML control in which Ajax File Browser will be created
        Url: webDavServerUrl,    // the root folder to be displayed in Ajax File browser
        Style: 'height: 100%; width: 100%',
        FileIconsPath: 'http://ajaxbrowser.com/ITHitService/AjaxFileBrowser/icons/', // path to the folder where file icons are located
        MsOfficeTemplatesPath: 'http://officeserv.com/templ/', // the server on which templates are located must support locks (class 2)
        SelectedFolder: webDavServerUrl  // folder to be selected, same as SetSelectedFolder call
    }
               
    var ajaxFileBrowser = new ITHit.WebDAV.Client.AjaxFileBrowser.Controller(settings);

}

 

Note that you do not need the above workaround if both your WebDAV server and page containing Ajax File Browser require authentication. Opening the page with Ajax File Browser will trigger the login dialog and the credentials that you provide will be used in WebDAV server requests.

 

Preauthentication in Google Chrome and Safari

In Google Chrome and Safari, you may experience a long delay before you will see the AJAX File Browser progress bar starts refreshing when your WebDAV server requires authentication. This delay is caused by preauthentication mechanisms used by user agent. If preauthentication occurs the user agent will first submit entire file to server without authentication information and will get the 401 Unauthorized response. Only after that the user agent will submit the file content with authentication information and the AJAX File Browser will start refreshing progress bar.

comments powered by Disqus

Selected Customers:
USA
Symantec
Country: Sweden
Toyota
Country: USA
Microsoft
Country: Ukraine
Raiffeisen Bank
Country: USA
Siemens
Country: USA
Lockheed Martin
Country: USA
Intel Corporation
Country: Germany
SAP AG
Country: Israel
Autodesk, Inc.
Country: USA
U.S. Customs and Border Protection Agency
Home .NET Server Java Server .NET Client AJAX Client AJAX Browser Map Drive Pricing Contacts

Updated: Tuesday, February 22, 2011