OpenID consumer support live on LiveJournal.com
Martin Atkins
mart at degeneration.co.uk
Mon Jun 27 18:52:17 PDT 2005
Troy Benjegerdes wrote:
>
> Now, what's the minimal set of code I need to be able to use the
> Net::OpenID::Server perl module without installing a whole livejournal
> server? ;)
>
I'm sure that now there's a very public, useful OpenID consumer
available it won't be long before someone writes a quick and easy
CGI-based OpenID server that can both drop in and be used and also serve
as a simple example for implementers.
It'll probably look something like this:
Net::OpenID::Server->new(
get_args => $QUERY_STRING_PARAMS || {},
post_args => $POST_PARAMS || {},
get_user => sub {
# Return some token about the remote user that you want
# to be passed into is_identity as $user
},
is_identity => sub {
my ($user, $ident) = @_;
# Is the remote user the given identity?
# your code here
},
is_trusted => sub {
my ($user, $trust_root, $is_identity) = @_;
# Is the trust_root already trusted?
# your code here...
},
setup_url => "http://example.com/openid/approve",
server_secret => \&get_some_secret,
secret_gen_interval => 3600,
secret_expire_age => 86400 * 14,
);
my ($type, $data) = $nos->handle_page(redirect_for_setup => 1);
if ($type eq "redirect") {
return do_redirect($data);
} else {
set_content_type($type) if $type;
return $data;
}
That was just quickly hacked together based on the LiveJournal code.
I've not actually tested it because it's not a complete program!
Hopefully that'll give you something to work from, though.
You need to provide the subroutines get_some_secret, do_redirect and
set_content_type that are suitable for your application. I think the
server_secret thing can also just be a scalar value, though I'm not sure
what form it should take.
More information about the yadis
mailing list