The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::OpenID::Server::Standalone - personal standalone OpenID server ready-to-use out-of-the-box

SYNOPSIS

id script use this:

Net::OpenID::Server::Standalone::id;

setup script use this:

Net::OpenID::Server::Standalone::setup;

Some kind of Net::OpenID::Server::Standalone::Config is a must. For more sophisticated use see "USAGE" below.

DESCRIPTION

Nossa is dedicated for fast installation of your own OpenID 'Server' on a CGI/FCGI::Spawn - enabled hosting. There is a lot of tweaks for common needs known as: your own identity source to be pluggable with Config.pm, your own design for user setup pages, location of your CGI::Session storage, your SRE information, redirect to your HTTPS server for setup, etc.

Typical layout follows:

./ --- application root, e. g. $HOME on your hosting.
  lib/Net/OpenID/Server/Standalone/
    Config.pm --- configuration of your OpenID server,
                  created from sample Config.pm
  www/ or public_html/
    index.html or whatever to be your XRD document like it is at 
    http://peter.vereshagin.org.
  cgi/ or perl/ or cgi-bin/ or www/
    id.cgi    or id.pl    or id    --- id script
    setup.cgi or setup.pl or setup --- setup script

Of course those mentioned last three can be on the different servers as different URLs. The workflow is as follows: id script checks user identity and setup shows forms. Target of those forms is an id script, too.

You may use your own MyApp.pm and MyApp/Config.pm ( see below ).

PREREQUISITES

Net::OpenID::Server, Data::UUID, MIME::Base64, HTML::Entities, Digest::MD5, CGI, CGI::Session.

Variables and Subs

  • $htmlStyle

    hash reference for HTML code for your setup pages: the 'start' key holds a value for start of the page, and the 'end' key holds a value for trhe end.

  • hashFunction()

    is a function that provides hash for your password storage. MD5 is the default.

  • new()

    Object constructor, starts session and so on.

  • id()

    performs identification, should be pointed as an 'openid.delegate' URL in your XRD document ( located on your OpenID URL ).

  • setup()

    shows forms for login, logout and for trust the requesting URL. For use in the 'setup' script.

  • redirect() and redirectMessage()

    overrideable for your inherited package needs. Use to take HTTP status and URL location as parameters. redirectMessage returns the message for user.

  • cgiHiddens()

    function that turns OpenID values for the default setup_map of the Net::OpenID::Server into the hidden inputs for the form on the setup URL.

  • printLoginForm()

    prints login form for setup script;

  • printLoginForm()

    prints 'trust this root' form for setup script;

  • printLoginForm()

    prints logout form for setup script;

USAGE

For 'do it quick' see the examples: index.html, id and setup. Also, Net::OpenID::Server::Standalone::Config is an example about how you could set up your own ::Config. You should do it in any case.

For more custom-made setup you can inherit Nossa like this:

$ cat lib/MyApp/Nossa.pm
package MyApp::Nossa;

use strict;
use warnings;

# inheritance stuff
use base qw/Net::OpenID::Server::Standalone/;

# your own hash function initialization
use Digest::SHA256;
my $dig = Digest::SHA256::new( 512 );

# your own stylings around forms; override the print*Form methods for even more and/or inner styling
our $htmlStyle = { start  => "<html><body height='100%'><table width='100%' height='100%'"
                            ."><tr><td height='100%' align='center' valign='middle'"
                            .">",
                   end    => "</td></tr>"
                            ."</table></form></td></tr></table></body></html>",
};

# the hash function
sub hashFunction{
  my $pass = shift;
  $dig->hexhash( $pass );
}

1;

$ cat lib/MyApp/Nossa/Config.pm
package MyApp::Nossa::Config;

use strict;
use warnings;

use base qw/Net::OpenID::Server::Standalone::Config/;

our $config = {
  # set up your values here as described in L<Net::OpenID::Server::Standalone::Config>
};

1;

for different storage methods, you may want to set up your own get() in your Config package. You shouldn't need to 'use base N:O:S:Sa::Config' in such a case.

$ cat id
#!/usr/bin/perl

use warnings;
use strict;
our $nossaLibDir;

BEGIN{
  use File::Basename qw/dirname/;
  use Cwd qw/realpath/;
  $nossaLibDir = realpath( dirname( __FILE__ ).'/../lib' );
  push( @INC, $nossaLibDir  )
    unless grep { $_ eq $nossaLibDir } @INC;
}

use MyApp::Nossa;

MyApp::Nossa->id;

Same goes here for setup script except

MyApp::Nossa->setup;

is the last line.

Downloads and more info

http://gitweb.vereshagin.org/nossa - browseable repository with snapshots

http://code.google.com/p/nossa/ - home page with actual links, etc.

http://github.com/petr999/nossa - GitHub page

http://bugs.vereshagin.org/buglist.cgi?product=Nossa for bugs and reporting of them

VCS downloads

Git users use this:

git clone git://github.com/petr999/nossa

Subversion users use one of these:

svn checkout http://nossa.googlecode.com/svn/trunk/ nossa-read-only
svn checkout http://svn.github.com/petr999/nossa.git

AUTHOR, LICENSE

Peter Vereshagin <peter@vereshagin.org> ( http://vereshagin.org ). Based on stuff from:

# Author: Alex Efros <powerman-asdf@yandex.ru>, 2008
# License: Public Domain

License: consider BSD is the closest to be of that domain.