Not a developer? Go to MovableType.com

Documentation

Registering Your OpenID Endpoint

The following example will show you how to provide your users with a customized login experience for an OpenID provider of your choice. What follows is a slightly modified version of the LiveJournal comment authenticator found natively in Movable Type.

Warning: Brace yourself, this is the most complex config.yaml we have seen up until this point. But don’t worry, most of it is HTML. Immediately after the example we will explain what all this means.

name: Example Plugin for Movable Type
id: Example
description: This plugin is an example plugin for Movable Type.
version: 1.0
commenter_authenticators:
    livejournal:
        label: 'LiveJournal'
        class: 'Example::MyOpenIDAuth'
        login_form_params: $Example::Example::OpenIDAuth::commenter_auth_params
        condition: $Example::Example::OpenIDAuth::openid_commenter_condition
        logo: 'images/comment/signin_livejournal.png'
        login_form: <<LiveJournal,
<form method="post" action="<mt:var name="script_url">">
<input type="hidden" name="__mode" value="login_external" />
<input type="hidden" name="blog_id" value="<mt:var name="blog_id">" />
<input type="hidden" name="entry_id" value="<mt:var name="entry_id">" />
<input type="hidden" name="static" value="<mt:var name="static" escape="html">" />
<input type="hidden" name="key" value="LiveJournal" />
<fieldset>
<mtapp:setting
    id="livejournal_display"
    label="<__trans phrase="Your LiveJournal Username">">
<input name="openid_userid" style="background: #fff 
    url('<mt:var name="static_uri">images/comment/livejournal_logo.png') 
no-repeat left; padding-left: 18px; padding-bottom: 1px; 
border: 1px solid #5694b6; width: 304px; font-size: 110%;" />
<p class="hint"><__trans phrase="Sign in using your LiveJournal username."></p>
</mtapp:setting>
<div class="pkg">
  <p class="left">
    <input type="submit" name="submit" value="<MT_TRANS phrase="Sign In">" />
  </p>
</div>
<p><img src="<mt:var name="static_uri">images/comment/blue_moreinfo.png"> 
  <a href="http://www.livejournal.com/"><__trans phrase="Learn more about LiveJournal."></a>
</p>
</fieldset>
</form>
LiveJournal

Comment Authenticator Properties

If you strip out all the HTML and template code from the above, you will actually find that the registry for OpenID endpoints is pretty simple:

  • class - the class or package name of the handler for processing form input and

  • label - the display name of the service as it will appear to an end user of the application

  • login_form_params - a subroutine responsible for populating the template context the necessary parameters to properly render the login form for the corresponding service

  • condition - the conditions under which this OpenID endpoint will be displayed as an option to the user. This allows for developers to specify prerequisites that if not satisfied will prevent users from authenticating via this endpoint.

  • logo - a small 16x16 logo used to identify users who have authenticated via this endpoint

  • login_form - A reference to a template file, or the raw template code for the login form. This text can contain MT template tags that will be evaluated when the form is displayed to the user. The login form must contain at least one input parameter called ‘openid_userid’. This parameter is used later to construct the OpenID endpoint or URL.

Next, let’s look at the Perl code associated with an OpenID comment authenticator.

Back