![]() |
General Programming »
Cryptography & Security »
Security
Beginner
Developing a Secure Solution using Commerce Server 2002 and .NETBy Khalid HaiDeveloping a secure solution using Commerce Server 2002 and .NET. |
C#, Windows, .NET 1.0, Visual Studio, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
This paper explains how to build a highly secured site using Authentication Tickets provided by Commerce Server 2002 and with Visual Studio .NET as well. It details challenges faced while creating a secure Commerce site, common configurations for employing Authentication methods and explains ways to implement these to maximize user experience and site security. Additionally, I will brief some of the bottlenecks incurred during the development.
Authentication is the process for determining a user�s identity on any computer. A user is allowed to access site, network, or computer resources depending on policies established by a system, network, or computer administrator. For the purposes of this paper, the computer that requires authentication is a Web server, and the user is a typical customer of a web site hosted on that server.
Commerce Server contains two objects for user authentication � AuthManager and AuthFilter. Each object offers multiple services that can be customized to serve your security and user-based needs. You can use more than one authentication service at a time. If different regions of your site have different security needs, you can employ separate authentication methods for each region.
Developers using Commerce Server have access to two authentication service objects:
AuthManager.
AuthFilter. I will be dealing with AuthFilter in this paper which is a very powerful authentication mechanism available today in Commerce Server. You can refer for more information under section �For More Information�.
Commerce Server uses authentication tickets to authenticate users visiting your site. An authentication ticket is a mechanism used to authenticate users. It is made up of a property/value pair such as a userID and the value of the userID, or even may be a URL based value pair which will be discussed in more detail. For example, userID/joeuser is a property/value pair that would be in an authentication ticket.
A Commerce Server ticket contains information about a user visiting your site, such as a logon ID, the time when the user last visited your site, and a time window that indicates how long the ticket is valid. Commerce Server uses tickets to identify and authenticate users, and to associate user IDs with the profile information it collects about them.
Commerce Server uses two kinds of authentication tickets: MSCSProfile tickets and MSCSAuth tickets. When a user first accesses your site, Commerce Server creates an MSCSProfile ticket for that user, and writes it to the HTTP header. When a registered user is authenticated, Commerce Server creates an MSCSAuth ticket, and writes it to the HTTP header. Both tickets can be stored in the cookie or encoded in the URL query string.
Commerce Server uses MSCSAuth tickets to identify and track registered and authenticated users.
MSCSAuth tickets can be stored in session cookies, or encoded in the URL. When a session ends, the browser automatically deletes session cookies, and the user must re-authenticate when revisiting the site. We will be using these tickets for authenticated users in our application.
Commerce Server uses MSCSProfile tickets to identify and track anonymous users who visit your site. MSCSProfile tickets are stored in persistent cookies for users who allow persistent cookies. If users do not allow persistent cookies, the MSCSProfile ticket is encoded in the URL.
This section explains about creating a Commerce C# ASP.NET Web Application. Once Commerce Server 2002 is installed on your server, commerce projects will be added to the Visual Studio .NET project library. Although, one could create choice of application using Visual Basic .NET as well. The following steps guide you through creating a Commerce project.





Briefly, Profile Schema Definition (*.xml) - when you pack a site, Site Packager extracts the profile schema from your Profiles database and stores it in an XML file. Specify that XML file here, so it is unpacked.
When you unpack a Solution Site, accept the default XML file, ProfileDefinition. This file contains the following profile definitions: Address, BlanketPOs, Organization, Targeting Context, and User Object.
Site Terms Definition (*.xml) - when you pack a site, Site Packager extracts the site terms definition from your database and stores it in an XML file. Specify that XML file here, so it is unpacked.
When you unpack a Solution Site, accept the default XML file, SiteTerms. This file contains the predefined site terms for your use.
Expression Definition (*xml) - When you pack a site, Site Packager extracts the definitions for expressions that you defined using Business Desk, and stores them in an XML file. Specify that XML file here, so it is unpacked.
When you unpack a Solution Site, a default XML file is provided, ExpressionDefinition. This file does not contain any predefined expressions for the Solution Sites.

Accept the default connection string to the Profiles database, or click Modify to configure a new connection string.
Schema definition scripts - To pack the profile definitions, use SQL Server Enterprise Manager to export the definitions (schema) from the SQL database to a .sql file, and then specify the name of that file here.
When you unpack your site, you will specify this file, so the definitions will be unpacked into the runtime data stores (the SQL tables that store the data for the user, address, organization, and so forth).
Data population scripts - If you have extracted the profile data from a Profiles database, you can specify data population scripts, so when you unpack, the profile data is imported into the runtime data stores (the SQL tables that store the data for the user, address, organization, and so forth).


This section details you on the configuration mechanisms and steps involved in enabling a site (or in other words Commerce Web application) with AuthFilter.
By default, there will be an AuthFilter folder which enables web applications to have secure authentication mechanism, individual ones can go for its own AuthFilter folder with different names as well. One can navigate to Commerce Server Manager as shown below:

This sample code snippet shows you to write code in code-behind of a Login.aspx Web Form which will be used for authenticating users on different URLs with Logon name and password as usual. Briefly coding goes like this, one could place this code in two sections, first part in under Page_Load function and secondly under Button_Click event. This code ensures that the user will be authenticated based on his official (corporation) URL. Other than the current URL, he can navigate to a different corporation's URL in this scenario.
Part 1:

Part 2:

You can change the properties and the database connection strings used by the global resource at any time.
To configure a global resource:
When you change the properties or AuthFilter folder name for a global resource using Commerce Server Manager, changes may not be reflected immediately in Commerce Server Business Desk or in the web pages of the applications using the global resource. To refresh these changes, restart all services that use those values. For instructions, refer section below �Restarting IIS Services'.

You can change the properties used by the site resource at any time. All site resources used by a site expose an object at the site level. After you change a property in Commerce Server Manager, you must restart all services that use those values. For instructions, refer section below �Restarting IIS Services'.
When you use Custom Authentication, login access is required for every ASPX or ASP page and directory in the Commerce Server site. AuthFilter checks against the virtual directory for the Commerce Server site, and it checks the Commerce Server Administration database to determine whether Custom Authentication is enabled for that site.
If the MSCSAuth ticket the user submitted is not valid when requesting access to an ASPX page or directory, AuthFilter requires the user to enter login information. When a user submits credentials to the login page, the login page obtains verification of the credentials from a SQL Server database, or other types of databases.
After the user has been authenticated, the Login.aspx page issues an MSCSAuth ticket. The MSCSAuth ticket is what is checked when the AuthFilter authenticates the request to determine whether or not to allow the request to be fulfilled.
In this mode, AuthFilter allows the site designer to provide a custom authentication process to control access to the site while still using the basic services of AuthFilter.
For Custom Authentication implementation, use AuthFilter to integrate it into your site. If you select Custom Authentication, AuthFilter checks for a valid MSCSAuth ticket. If the valid MSCSAuth ticket is not found, the user is redirected to a login page, where you can do your own Custom Authentication by validating credentials and setting MSCSAuth ticket upon success.
To enable the Custom Authentication mode:
AuthFilter redirects the user request to the Login.aspx page, which validates the user login and password against a SQL Server database or other types of data stores.
After you change a property value in Commerce Server Manager, you must unload the application from memory on each Web server for the change to take effect. For instructions, refer section below: �Restarting IIS Services'.

When you make changes to the properties used by the CS Authentication resource, you must stop and then restart IIS. Restarting IIS unloads all Web applications from memory, restarts the IIS service and refreshes the cache. Therefore, when restarting IIS, it is not necessary to also unload an application from memory.
You must restart IIS when you perform any of the following tasks in the CS Authentication resource:
AuthFilter
AuthFilter Note: Do not use the IISReset command to restart IIS. Although IISReset will stop and then restart IIS, under certain conditions, it does not stop and then start Inetinfo.exe (W3SVC service). For example, if the W3SVC service has been configured for manual start instead of automatic, it will not be restarted.
To restart IIS :
This section details on live problems faced during development while working with Commerce Server 2002 and Visual Studio .NET.
AuthFilter is enabled. The following message will be displayed �

Remedies:-
AuthFilter to �No Filter� mode
System.Diagnostics.Debugger.Break() for debugging purpose. AuthFilter enabled, when Visual Studio .NET tries to connect to the site, AuthFilter does a redirect so Visual Studio .NET cannot open the project.

Remedies:-
AuthFilter to �No Filter� mode. Disabling AuthFilter does not unload it from IIS process space until IIS is restarted; it only removes the AuthFilter entry from the metabase.
Remedies:-
The paper briefed about the creating and configuring the Secured Commerce Server ASP.NET Web Application. And further, it shows enabling the Commerce Server site to use an AuthFilter and ensure secured access to users. The following points summarizes in brief:
AuthFilter
AuthFilter
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 21 Apr 2004 Editor: Smitha Vijayan |
Copyright 2004 by Khalid Hai Everything else Copyright © CodeProject, 1999-2009 Web16 | Advertise on the Code Project |