CheckUser plugin for Statusnet

November 11, 2009

Starting with the proof of concept that I posted in May, Laconica with active directory and auto-registration,  I’m now ready to release a more polished plugin package that enables external user authentication for StatusNet. I developed it against  the 0.9.x branch, but it tested fine against 0.8.2.  You can find the project code at Gitorious under CheckUser plugin for Statusnet, the source tree and download link are here.

The plugin hooks into the  StatusNet Event named “CheckUser” and loads user supplied connectors to perform the authentication. Currently the CheckUser event is not part of the StatusNet core. but it can be added by using the included checkuser.patch.

Connectors are php classes that connect to external services for authentication of the user login (nickname/password) and may optionally return enough data that can be used for account registration. They are configured using the entries in the config.php file.  I’ve included four samples to demonstrate how to write and use a connector.

MockConn.php
——————
This is used to test the plugin with auto-register and demonstrate the connector class methods. Use any “nickname” and for the password append “mock” to the nickname. example: if the nickname is “test” the password will be “mocktest”.

StatusNetConn.php
———————-
This plugin will use the native StatusNet functions for authentication. There is no advantage to using this connector other than to demonstrate how to use the connector.

adLdapConn.php
——————–
This connector uses the adLdap class from the adLDAP project. I use this in production on our Intranet.

PearLdap.php
—————-
Another Ldap connector using the Pear Net Ldap2 extension. This code was based on the original patch from here and here.

Advertisements

i4i v. Microsoft

August 13, 2009

I’m sure that you’ve heard the news that Microsoft has been ordered to stop selling Word. First I would like to point out the irony that is inherent with this turn of the tables for Microsoft. It wasn’t that long ago that they released a threat to sue linux users. But it was the name of the suing party that had me checking the calendar to see if “April Fools” was in play. How perfect is it that the company suing Microsoft is named i4i? Perhaps for this case they should spell it eye for eye, talk about bad karma.

Getting past the headlines and spectacle let me cast my vote for No Software patents and then point you to the post on Groklaw, The i4i v. Microsoft Orders and Permanent Injunction.


Laconica event handlers

June 9, 2009

A month ago I was in a hurry and needed a few specific features to make Laconica work on our Intranet. That was the topic of the my post; Laconica with active directory and auto-registration. Since then I’ve learned about the Laconica event handler and now I would like to re-introduce the LDAP authentication code as a plugin. The code will be at my clone of the Laconica project later this week.


Laconica project at Gitorius

May 17, 2009

Iv’e started a clone of the Laconica project on Gitorious to track all of the code changes I describe in the posts. I’m new to git, but so far so good.


SVN Post-Commit to Laconica

May 14, 2009

Since I am using Laconica to capture notices from my batch jobs(see Microblogging for Applications) I thought it would be nice to add an account for my Subversion repositories and use the post-commit hook to keep me posted.

I’m not an expert with Subversion so if there is an easier way to get this information please let me know. I use two executions of the svnlook command to get the info and then dirs-changed for the folders involved.  My repositories are structured by projects so the first folder is the project name.

This example uses Window batch files:

post-commit.bat

@ECHO OFF
:: *************************************************************
:: * this sets the arguments supplied by Subversion            *
:: *************************************************************
SET REPOS=%1
SET REV=%2

:: *************************************************************
:: * Call your batch file*
:: *************************************************************
CALL Drive:\path\to\batchfile.bat %REPOS% %REV%

batchfile.bat

@ECHO OFF
setlocal enabledelayedexpansion
:: take the path and revision from the post-commit hook and use svnlook to gather info

SET REPOS=%1
SET REV=%2

:: Get Repository name from REPOS path
for /f "tokens=1,2,3,4  delims=/ " %%a in ("%REPOS%") do SET REPOSNAME=%%c

:: Build the svnlook commands
SET INFOCMD=Drive:\path\to\subversion\bin\svnlook info -r %REV% %REPOS%
SET DIRCMD=Drive:\path\to\subversion\bin\svnlook dirs-changed -r %REV% %REPOS%

:: Get USR from Info line 1 and MSG from line 4
SET /a counter=1
FOR /f "usebackq delims=" %%a in (`%INFOCMD%`) DO (
if "!counter!"=="1" SET USR=%%a
if "!counter!"=="4" SET MSG=%%a
set /a counter+=1
)

:: Get folder from dirs-changed ... only need the first line
FOR /f usebackq  %%a IN (`%DIRCMD%`) DO (
SET  DIR=%%a
GOTO GetProject
)

:: Get project name from DIR ... it is the first folder
:GetProject
for /f "tokens=1 delims=/ " %%a in ("%DIR%") do SET PROJECT=%%a

:End
CALL twittercurl.bat "#%PROJECT% updated by #%USR% in the #%REPOSNAME% repsoitory. %MSG%"

The CALL to twittercurl.bat is described here: Microblogging for Applications

Please post any corrections and ideas!


Microblogging for Applications

May 14, 2009

I’ve been using the open source project Laconica to track my time at work. It is a Twitter clone and aims to support the open micro blogging protocol and is also compatible to the Twitter api.

While doing a little research on command line tools I discovered that posting to Twitter and therefore Laconica was a simple task using cURL. So I threw together a little batch file to test it. Then I decided to add to all my nightly batch jobs. Here is how it works.

Step 1
On an installation of Laconica(or Twitter) register an account for your application.

  • For Nickname use a simple single word
  • Email is optional
  • Full Name can be multiple words and more descriptive
  • If your app has a link put it in the Homepage
  • Add a little description to the Bio section
  • I use the Location field to identify the primary server it is hosted on

That’s it! Log Out

Step 2

  • Create a batch file or script to execute the cURL command
    Windows twittercurl.bat

    @echo off
    :: send a post to a laconica site using curl
    SET CURLPATH=D:\usr\curl\curl.exe
    SET URL=http://site.domain.com/laconica/api/statuses/update.xml
    SET USER=nickname
    SET PASS=pass4nickname
    
    %CURLPATH% -u %USER%:%PASS% -d status=%1 %URL%
    

    Bash twittercurl.sh

    #!/bin/bash
    # requires curl
    
    ### CONFIG
    USER=nickname
    PASS=pass4nickname
    URL="http://site.domain.com/laconica/api/statuses/update.xml"
    
    ### COMMAND
    curl -u $USER:$PASS -d status="$*" -s -o /dev/null ${URL}
    
  • Edit the USER and PASS variables to use the nickname and password

Step 3
Now all you need to do is to CALL your script and pass it a message. In the message you can tag a keyword that you would like to use by appending the # to the word.

Example: CALL twittercurl.bat “#update nightly batch job completed”

Step 4
Track your application by going to the site/ + nickname or use the API for more options:

Conclusion
Now I have a quick review of my nightly jobs and scheduled events during the day.

This is just a start, there are a lot of features and even more possibilities. Since it is a Twitter clone there are all sorts of twitter-like things that you can do, but that is another topic.

My example uses the command line, so if you can type it then you can post it. For advanced use the web API is available to any application progam that can POST to a URL.

Please post any corrections and ideas!


Laconica multi-site installation

May 14, 2009

I want to have several installations of Laconica on our Intranet but want only one code base.  Here is how I am doing this.

Setup

  • Place the Laconica install in a non-public folder.
  • Edit path for the config files in lib/common.php
//$_config_files[] = INSTALLDIR.'/config.php';
$_config_files[] = SITEDIR.'/config.php';
  • Create a new folder in the public web space and add the following folders/files from the Laconica install folder.

avatar/
file/
js/
local/
theme/
config.php
index.php
install.php
favicon.ico

Installation

In both the index.php and install.php files, edit the INSTALLDIR to point to your Laconica installation base and add a define for SITEDIR.

define('INSTALLDIR', '/web/laconica');
define('SITEDIR', dirname(__FILE__));

In the file install.php change all paths using INSTALLDIR to SITEDIR with the following exceptions

$res = runDbScript(INSTALLDIR.'/db/laconica.sql', $conn);
$res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn);
  • Run install.php

Post Install

Add site timezone and fancy-urls to config.php

$config['site']['timezone'] = 'America/Detroit';
$config['site']['fancy'] = TRUE;
  • Edit the .htaccess file to set the correct RewriteBase
  • Remove the install.php file