MCImageManager:Perl

From Moxiecode Documentation Wiki

Jump to: navigation, search

Contents

Perl integration instructions

If you use Perl and you want to integrate authentication with the one of your system, you need to use ExternalAuthenticator in order to share sessions between Perl and PHP/.NET. It's not that difficult: since the Perl ExternalAuthenticator is not provided, you can find one I wrote myself here.

MCImageManager configuration

File to edit is likely config.php. If you use Web.config, these instructions still apply. First of all, you need to enable the ExternalAuthenticator:

$mcImageManagerConfig['authenticator'] = "ExternalAuthenticator";

Scroll down a bit and you'll find the relevant configuration options for ExternalAuthenticator:

// ExternalAuthenticator config
$mcImageManagerConfig['ExternalAuthenticator.external_auth_url'] = "/manage/tinymce_auth.pl";

$mcImageManagerConfig['ExternalAuthenticator.secret_key'] = "TheKey";

tinymce_auth.pl

Put this file at the location you specified in config.php. You need to edit some parth: the secret key and, of course, the part which verifies the user is authenticated.

#!/usr/bin/perl

use strict;
use warnings;

use CGI::Carp qw/fatalsToBrowser/;
use CGI::Simple;
use CGI::Session;
use HTML::Entities;
use Digest::MD5 qw/md5_hex/;

# Must match the one in config.php
my $secretKey = "TheKey";

my $q = CGI::Simple->new();
print $q->header(
    -type   => 'text/html; charset=UTF-8',
);

my $session = CGI::Session->new();

# See if session-id is OK
if ( !$session->param('idadmin') =~ /^\d+$/ ) {
     print "Not logged in";
     exit;
}

# Come configuration variables can be overridden here
my %configuration = (
    #'filesystem.rootpath'   => '/some/path',
    #'filesystem.path'       => '/some/path',
);

my $data = '';
for my $cv (values %configuration) {
    $data .= $cv;
}
my $key = md5_hex($data . $secretKey);

print '<html>';
print '<body onload="document.forms[0].submit();">';
print '<form method="post" action="' . encode_entities($q->param('return_url')) . '">';
print '<input type="hidden" name="key" value="'. encode_entities($key) . '" />';
for my $ck (keys %configuration) {
     my $enc_ck = $ck; $enc_ck =~ s/\./_/g;
     print '<input type="hidden" name="'
        . encode_entities($enc_ck)
        . '" value="'
        . encode_entities($configuration{$ck})
        . '" />'
    ;
}
print '</form></body></html>';

Author

Michele Beltrame - mb@italpro.net

This work is free software, by , and is provided as-is. If you need support, ask in the TinyMCE forum.

Personal tools