Introduction

Community Server Extensions is as collection of unrelated bug fixes and behaviors that can be individually applied to a CS instance.
All features will be described individually.
Before adding any feature you must unzip package release and copy assembly NunoGomes.CommunityServer.dll to CS bin folder.

Adding CAPTCHA

The implementation details aren't yet available but will be soon.
The Captcha is added to the page by configuring 4 ControlAdapters:
  • One for the ContactFormcontrol
  • Another for the WeblogPostCommentForm
  • Another for the CreateUserForm
  • And the last one for the OpenIdCreateUserSubForm
They can be applied individually but I recommend them to be used together.
Here is the configuration snipet that should be added to App_Browsers\default.browser file:

      <!-- Adapter for the ContactForm control in order to add the Captcha and prevent SPAM comments -->
      <adapter controlType="CommunityServer.Blogs.Controls.ContactForm" adapterType="NunoGomes.CommunityServer.Blogs.Controls.ContactFormCaptchaAdapter, NunoGomes.CommunityServer" />
      <!-- Adapter for the WeblogPostCommentForm control in order to add the Captcha and prevent SPAM comments -->
      <adapter controlType="CommunityServer.Blogs.Controls.WeblogPostCommentForm" adapterType="NunoGomes.CommunityServer.Blogs.Controls.WeblogPostCommentFormCaptchaAdapter, NunoGomes.CommunityServer" />
      <!-- Adapter for the CreateUserForm control in order to add the Captcha and prevent new SPAM user accounts -->
      <adapter controlType="CommunityServer.Controls.CreateUserForm" adapterType="NunoGomes.CommunityServer.Controls.CreateUserFormCaptchaAdapter, NunoGomes.CommunityServer" />
      <!-- Adapter for the OpenIdCreateUserSubForm control in order to add the Captcha and prevent new SPAM user accounts -->
      <adapter controlType="CommunityServer.Controls.OpenIdCreateUserSubForm" adapterType="NunoGomes.CommunityServer.Controls.OpenIdCreateUserSubFormCaptchaAdapter, NunoGomes.CommunityServer" />

To make the Captcha fully functional you must choose a CaptchaProvider. Currently there only 2 providers available:
  • The SimpleCaptchaProvider - This is a Captcha provider that uses a simple captcha algorithm.
  • The RecaptchaProvider - a Captcha provider that the free ReCaptcha service

Configuring the Captcha Provider

A specific configuration section exists to configure the Captcha provider and must be added to the web.config. Here are the configSections snippet:
<configuration>
  <configSections>
    [...]
    <!-- New section for Captcha providers configuration -->
    <section name="communityServer.Captcha" type="NunoGomes.CommunityServer.Captcha.Configuration.CaptchaSection" />
  </configSections>
  [...]

The SimpleCaptchaProvider

This provider adds an extra Control to the ControlAdapter original control and stores the ciphered Captcha numeric challenge in is ControlState.
The Captcha challenge image is generated and provided in a specific HttpHandler.
Here are the configuration snippets that should be added to the web.config file:
<configuration>
  [...]
  <!-- Configuring a simple Captcha provider -->
  <communityServer.Captcha defaultProvider="simpleCaptcha">
    <providers>
      <add name="simpleCaptcha" type="NunoGomes.CommunityServer.Captcha.Providers.SimpleCaptchaProvider, NunoGomes.CommunityServer"
			imageUrl="~/captcha.ashx"
			enabled="true"
			passPhrase="_PutYourPassPhraseHere_"
			saltValue="_PutYourSaltValueHere_"
			hashAlgorithm="SHA1"
			passwordIterations="3"
			keySize="256"
			initVector="_YourInitVectorMustHaveExactly_16_Bytes_"
			/>
    </providers>
  </communityServer.Captcha>
  [...]

and
  <system.web>
    <httpHandlers>
      <!-- The Captcha Image handler used by the simple Captcha provider -->
      <add verb="GET" path="captcha.ashx" type="NunoGomes.CommunityServer.Captcha.Providers.SimpleCaptchaProviderImageHandler, NunoGomes.CommunityServer" />
    </httpHandlers>
  </system.web>

  <system.webServer>
    <handlers accessPolicy="Read, Write, Script, Execute">
      <!-- The Captcha Image handler used by the simple Captcha provider -->
      <add verb="GET" name="captcha" path="captcha.ashx" type="NunoGomes.CommunityServer.Captcha.Providers.SimpleCaptchaProviderImageHandler, NunoGomes.CommunityServer" />
    </handlers>
  </system.webServer>
Sample
CSCaptcha.jpg

The RecaptchaProvider

In order to use this provider you must:
  • Unzip package release and copy assembly NunoGomes.CommunityServer.Recaptcha.dll to CS bin folder.
  • Create an account at ReCaptcha, then you must register your domain to get the public and private keys.
Once you got the keys pair use the following snippet in the web.config file:
  <communityServer.Captcha defaultProvider="recaptcha">
    <providers>
      <add name="recaptcha" type="NunoGomes.CommunityServer.Recaptcha.RecaptchaProvider, NunoGomes.CommunityServer.Recaptcha"
           publicKey="_PutYourPublicKeyHere_" 
           privateKey="_PutYourPrivateKeyHere_"
           errorMessage="*"
           skipRecaptcha="false"
           allowMultipleInstances="false"
           />
    </providers>
  </communityServer.Captcha>

Remarks:
  • The Recaptcha ASP.NET plugin appears not to support multiple instances within the same page.
  • You must download the ReCaptcha ASP.NET plugin and copy assembly Recaptcha.dll to CS bin folder.
  • This provider was tested against Recaptcha API version 1.0.3.0 and 1.0.4.0.
Sample
CSReCaptcha.jpg

Last edited Oct 18, 2010 at 1:13 PM by nmgomes, version 14

Comments

No comments yet.