]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/bugs/notifyemail_fails_with_some_openid_providers.mdwn
(no commit message)
[git.ikiwiki.info.git] / doc / bugs / notifyemail_fails_with_some_openid_providers.mdwn
1 This bug affects [[plugins/notifyemail]] but is probably caused more by [[plugins/openid]]. When using OpenID to login to a site, no email notification is sent to the user (pagespec set to `*`) when a modification is done on the wiki. I believe this is because the OpenID plugin assumes the email comes from the OpenID provider - which is not necessarily going to succeed if, for privacy reason, the OpenID provider refuses to transmit the email to ikiwiki.
3 In the OpenID plugin, the email is actually fetched when authenticating and is stored in the session, like so:
5 [[!format perl """
6 sub auth ($$) {
7 # [...]
8                         my @extensions;
9                         if ($vident->can("signed_extension_fields")) {
10                                 @extensions=grep { defined } (
11                                         $vident->signed_extension_fields('http://openid.net/extensions/sreg/1.1'),
12                                         $vident->signed_extension_fields('http://openid.net/srv/ax/1.0'),
13                                 );
14                         }
15                         my $nickname;
16                         foreach my $ext (@extensions) {
17                                 foreach my $field (qw{value.email email}) {
18                                         if (exists $ext->{$field} &&
19                                             defined $ext->{$field} &&
20                                             length $ext->{$field}) {
21                                                 $session->param(email => $ext->{$field});
22                                                 if (! defined $nickname &&
23                                                     $ext->{$field}=~/(.+)@.+/) {
24                                                         $nickname = $1;
25                                                 }
26                                                 last;
27                                         }
28                                 }
30 """]]
32 This is based on the assumption that the openid provider supports "sreg" or "ax" extensions, which is not mandatory, and even then, the provider is not forced to provide the email.
34 Earlier in the plugin, the email field is actually hidden:
36 [[!format perl """
37 sub formbuilder_setup (@) {
38         my %params=@_;
40         my $form=$params{form};
41         my $session=$params{session};
42         my $cgi=$params{cgi};
43         
44         if ($form->title eq "preferences" &&
45                IkiWiki::openiduser($session->param("name"))) {
46                 $form->field(name => "openid_identifier", disabled => 1,
47                         label => htmllink("", "", "ikiwiki/OpenID", noimageinline => 1),
48                         value => "", 
49                         size => 1, force => 1,
50                         fieldset => "login",
51                         comment => $session->param("name"));
52                 $form->field(name => "email", type => "hidden");
53         }
54 }
55 """]]
57 I believe this could be worked around simply by re-enabling that field and allowing the user to specify an email there by hand, making a note that the OpenID provider's email is used by default.
59 [[!template  id=gitbranch branch=anarcat/openid_email author="[[anarcat]]"]]
61 The dumbest [[!taglink patch]] that actually fixes the problem for me is in the branch mentionned here.
63 It would probably be better to add a comment on the field as indicated above, but it's a good proof of concept.
65 Any other ideas? --[[anarcat]]
67 > Note: it seems that my email *is* given by my OpenID provider, no idea why this is not working, but the fix proposed in my branch works. --[[anarcat]]