pretty openid login
* openid: Incorporated a fancy openid-selector signin form. (http://code.google.com/p/openid-selector/) * openid: Use "openid_identifier" as the form field, as required by OpenID Authentication v2.0 spec.master
parent
1b8d2ce36b
commit
f8c2a67b3c
|
@ -7,6 +7,7 @@ use strict;
|
|||
use IkiWiki 3.00;
|
||||
|
||||
sub import {
|
||||
add_underlay("openid-selector");
|
||||
hook(type => "checkconfig", id => "openid", call => \&checkconfig);
|
||||
hook(type => "getopt", id => "openid", call => \&getopt);
|
||||
hook(type => "getsetup", id => "openid", call => \&getsetup);
|
||||
|
@ -19,10 +20,16 @@ sub checkconfig () {
|
|||
if ($config{cgi}) {
|
||||
# Intercept normal signin form, so the openid selector
|
||||
# can be displayed.
|
||||
require IkiWiki::CGI;
|
||||
my $real_cgi_signin=\&IkiWiki::cgi_signin;
|
||||
#
|
||||
# When other auth hooks are registered, give the selector
|
||||
# a reference to the normal signin form.
|
||||
my $real_cgi_signin;
|
||||
if (keys %{$IkiWiki::hooks{auth}} > 1) {
|
||||
require IkiWiki::CGI;
|
||||
$real_cgi_signin=\&IkiWiki::cgi_signin;
|
||||
}
|
||||
inject(name => "IkiWiki::cgi_signin", call => sub ($$) {
|
||||
openid_selector($real_cgi_signin, @_);
|
||||
openid_selector($real_cgi_signin, @_);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -55,15 +62,21 @@ sub openid_selector {
|
|||
my $q=shift;
|
||||
my $session=shift;
|
||||
|
||||
my $openid_url=$q->param('openid_url');
|
||||
my $openid_url=$q->param('openid_identifier');
|
||||
my $openid_error;
|
||||
|
||||
if (defined $q->param("action") && $q->param("action") eq "verify") {
|
||||
if (! load_openid_module()) {
|
||||
if ($real_cgi_signin) {
|
||||
$real_cgi_signin->($q, $session);
|
||||
}
|
||||
error(sprintf(gettext("failed to load openid module: "), @_));
|
||||
}
|
||||
elsif (defined $q->param("action") && $q->param("action") eq "verify") {
|
||||
validate($q, $session, $openid_url, sub {
|
||||
$openid_error=shift;
|
||||
});
|
||||
}
|
||||
elsif ($q->param("do") eq "signin" || ! load_openid_module()) {
|
||||
elsif ($q->param("do") eq "signin" && $real_cgi_signin) {
|
||||
$real_cgi_signin->($q, $session);
|
||||
exit;
|
||||
}
|
||||
|
@ -73,8 +86,7 @@ sub openid_selector {
|
|||
cgiurl => $config{cgiurl},
|
||||
(defined $openid_error ? (openid_error => $openid_error) : ()),
|
||||
(defined $openid_url ? (openid_url => $openid_url) : ()),
|
||||
# TODO only if other auth methods are available
|
||||
nonopenidurl => IkiWiki::cgiurl(do => "signin"),
|
||||
($real_cgi_signin ? (nonopenidurl => IkiWiki::cgiurl(do => "signin")) : ()),
|
||||
loginlabel => loginlabel(),
|
||||
);
|
||||
|
||||
|
@ -90,45 +102,9 @@ sub formbuilder_setup (@) {
|
|||
my $session=$params{session};
|
||||
my $cgi=$params{cgi};
|
||||
|
||||
if ($form->title eq "signin") {
|
||||
return unless load_openid_module();
|
||||
|
||||
# This avoids it displaying a redundant label for the
|
||||
# OpenID fieldset.
|
||||
$form->fieldsets("OpenID");
|
||||
|
||||
$form->field(
|
||||
name => "openid_url",
|
||||
label => loginlabel(),
|
||||
fieldset => "OpenID",
|
||||
size => 30,
|
||||
comment => ($config{openidsignup} ? " | <a href=\"$config{openidsignup}\">".gettext("Get an OpenID")."</a>" : "")
|
||||
);
|
||||
|
||||
# Handle submission of an OpenID as validation.
|
||||
if ($form->submitted && $form->submitted eq "Login" &&
|
||||
defined $form->field("openid_url") &&
|
||||
length $form->field("openid_url")) {
|
||||
$form->field(
|
||||
name => "openid_url",
|
||||
validate => sub {
|
||||
validate($cgi, $session, shift, sub {
|
||||
# Display error in the form.
|
||||
$form->field(name => "openid_url", comment => shift);
|
||||
});
|
||||
},
|
||||
);
|
||||
# Skip all other required fields in this case.
|
||||
foreach my $field ($form->field) {
|
||||
next if $field eq "openid_url";
|
||||
$form->field(name => $field, required => 0,
|
||||
validate => '/.*/');
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ($form->title eq "preferences" &&
|
||||
if ($form->title eq "preferences" &&
|
||||
IkiWiki::openiduser($session->param("name"))) {
|
||||
$form->field(name => "openid_url", disabled => 1,
|
||||
$form->field(name => "openid_identifier", disabled => 1,
|
||||
label => htmllink("", "", "ikiwiki/OpenID", noimageinline => 1),
|
||||
value => $session->param("name"),
|
||||
size => 50, force => 1,
|
||||
|
|
|
@ -10,8 +10,10 @@ ikiwiki (3.20100505) UNRELEASED; urgency=low
|
|||
* inline: Call indexhtml when inlining internal pages, so their
|
||||
text can be indexed for searching.
|
||||
* Delete hooks are passed deleted internal pages.
|
||||
* openid: Incorporated a fancy openid-selector signin form
|
||||
(http://code.google.com/p/openid-selector/).
|
||||
* openid: Incorporated a fancy openid-selector signin form.
|
||||
(http://code.google.com/p/openid-selector/)
|
||||
* openid: Use "openid_identifier" as the form field, as required
|
||||
by OpenID Authentication v2.0 spec.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Wed, 05 May 2010 18:07:29 -0400
|
||||
|
||||
|
|
|
@ -193,11 +193,15 @@ Files: cvs.pm
|
|||
Copyright: © 2009 Amitai Schlair
|
||||
License: BSD-C2
|
||||
|
||||
Files: underlays/javascript/ikiwiki/openid-selector/*
|
||||
Files: underlays/openid-selector/ikiwiki/openid/*
|
||||
Copyright: © 2008-2010 andyjm, david.j.boden
|
||||
License: BSD-C2
|
||||
From http://code.google.com/p/openid-selector/
|
||||
|
||||
Files: underlays/openid-selector/ikiwiki/openid/jquery.js
|
||||
Copyright: © 2005-2008 by John Resig, Branden Aaron & Jörn Zaefferer
|
||||
License: GPL-2
|
||||
|
||||
License: BSD-C2
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
|
|
@ -319,16 +319,6 @@ legend {
|
|||
float: left;
|
||||
margin: 2px 0;
|
||||
}
|
||||
#signin_openid_url_label {
|
||||
float: left;
|
||||
margin-right: 1ex;
|
||||
}
|
||||
#signin_openid {
|
||||
padding: 10px 10px;
|
||||
border: 1px solid #aaa;
|
||||
background: #eee;
|
||||
color: black !important;
|
||||
}
|
||||
label.block {
|
||||
display: block;
|
||||
}
|
||||
|
@ -342,13 +332,6 @@ ol.form {
|
|||
li.form {
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
input#openid_url {
|
||||
background: url(wikiicons/openidlogin-bg.gif) no-repeat;
|
||||
background-color: #fff;
|
||||
background-position: 0 50%;
|
||||
color: #000;
|
||||
padding-left: 18px;
|
||||
}
|
||||
input#searchbox {
|
||||
background: url(wikiicons/search-bg.gif) no-repeat;
|
||||
background-color: #fff;
|
||||
|
@ -440,3 +423,43 @@ li.L8 { list-style: upper-alpha; }
|
|||
color: white !important;
|
||||
background: #ff9900;
|
||||
}
|
||||
|
||||
/* openid selector */
|
||||
#openid_choice {
|
||||
display: none;
|
||||
}
|
||||
#openid_input_area {
|
||||
clear: both;
|
||||
padding: 10px;
|
||||
}
|
||||
#openid_btns, #openid_btns br {
|
||||
clear: both;
|
||||
}
|
||||
#openid_highlight {
|
||||
padding: 3px;
|
||||
background-color: #FFFCC9;
|
||||
float: left;
|
||||
}
|
||||
.openid_large_btn {
|
||||
width: 100px;
|
||||
height: 60px;
|
||||
border: 1px solid #DDD;
|
||||
margin: 3px;
|
||||
float: left;
|
||||
}
|
||||
.openid_small_btn {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border: 1px solid #DDD;
|
||||
margin: 3px;
|
||||
float: left;
|
||||
}
|
||||
a.openid_large_btn:focus {
|
||||
outline: none;
|
||||
}
|
||||
a.openid_large_btn:focus {
|
||||
-moz-outline-style: none;
|
||||
}
|
||||
.openid_selected {
|
||||
border: 4px solid #DDD;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ BEGIN {
|
|||
else {
|
||||
eval q{use Test::More tests => 11};
|
||||
}
|
||||
use_ok("IkiWiki::Plugin::openid");
|
||||
use_ok("IkiWiki");
|
||||
}
|
||||
|
||||
# Some typical examples:
|
||||
|
|
|
@ -5,7 +5,7 @@ use Test::More 'no_plan';
|
|||
|
||||
ok(! system("mkdir t/tmp"));
|
||||
ok(! system("make -s ikiwiki.out"));
|
||||
ok(! system("perl -I. ./ikiwiki.out -plugin inline -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -templatedir=templates t/tinyblog t/tmp/out"));
|
||||
ok(! system("perl -I. ./ikiwiki.out -plugin inline -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -set underlaydirbase=underlays -templatedir=templates t/tinyblog t/tmp/out"));
|
||||
# This guid should never, ever change, for any reason whatsoever!
|
||||
my $guid="http://example.com/post/";
|
||||
ok(length `grep '<guid>$guid</guid>' t/tmp/out/index.rss`);
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
<script type="text/javascript" src="ikiwiki/openid-selector/jquery.js"></script>
|
||||
<script type="text/javascript" src="ikiwiki/openid-selector/openid-jquery.js"></script>
|
||||
<script type="text/javascript" src="ikiwiki/openid/jquery.js"></script>
|
||||
<script type="text/javascript" src="ikiwiki/openid/openid-jquery.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
openid.init('openid_url');
|
||||
openid.init('openid_identifier');
|
||||
});
|
||||
</script>
|
||||
|
||||
<TMPL_IF OPENID_ERROR>
|
||||
<div class="error"><TMPL_VAR OPENID_ERROR></span>
|
||||
</TMPL_IF>
|
||||
</div>
|
||||
|
||||
<form action="<TMPL_VAR CGIURL>" method="get" id="openid_form">
|
||||
<input type="hidden" name="do" value="signin" />
|
||||
<input type="hidden" name="action" value="verify" />
|
||||
<div id="openid_choice">
|
||||
<p><TMPL_VAR LOGINLABEL>:</p>
|
||||
<div id="openid_btns">
|
||||
<fieldset>
|
||||
<legend><TMPL_VAR LOGINLABEL></legend>
|
||||
<div id="openid_choice">
|
||||
<div id="openid_btns">
|
||||
</div>
|
||||
<TMPL_IF NONOPENIDURL>
|
||||
<a href="<TMPL_VAR NONOPENIDURL>">local account</a>
|
||||
</TMPL_IF>
|
||||
</div>
|
||||
<TMPL_IF NONOPENIDURL>
|
||||
<a href="<TMPL_VAR NONOPENIDURL>">local account</a>
|
||||
<div id="openid_input_area">
|
||||
<input id="openid_identifier" name="openid_identifier" type="text" value="<TMPL_VAR OPENID_URL>"/>
|
||||
<input id="openid_submit" type="submit" value="Login"/>
|
||||
</div>
|
||||
<TMPL_IF OPENID_ERROR>
|
||||
<div class="error"><TMPL_VAR OPENID_ERROR></div>
|
||||
</TMPL_IF>
|
||||
</div>
|
||||
|
||||
<span id="openid_input_area">
|
||||
<input id="openid_url" name="openid_url" type="text" value="<TMPL_VAR OPENID_URL>"/>
|
||||
<input id="openid_submit" type="submit" value="Login"/>
|
||||
</span>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue