root/blosxom_plugins/trunk/auth_openid

Revision 356, 2.1 kB (checked in by miya, 2 years ago)

test

  • Property svn:executable set to *
Line 
1 # Blosxom Plugin: auth_openid
2 # Author: Gosuke Miyashita <miya@mizzy.org>
3 # Version: 2005-11-08
4 # Blosxom Home/Docs/Licensing: http://www.blosxom.com/
5
6 package auth_openid;
7
8 use strict;
9 use CGI qw(:standard);
10 use CGI::Session;
11 use Net::OpenID::Consumer;
12 use File::Cache;
13
14 my $session = CGI::Session->new();
15
16 sub start {
17     return 0 if $session->param('openid_url');
18
19     my $cgi = CGI->new;
20     my $csr = Net::OpenID::Consumer->new(
21                                          args            => $cgi,
22                                          consumer_secret => '012345',
23                                          #cache           => File::Cache->new,
24                                          debug           => 0,
25                                          );
26     if(param('auth_openid')){
27         my $cident = $csr->claimed_identity(param('openid_url'));
28         my $curl = $cident->check_url(
29                                       return_to      => "$blosxom::url/$blosxom::path_info",
30                                       trust_root     => 'http://mizzy.org/',
31                                       delayed_return => 1,
32                                       );
33         print "Location: $curl\n\n";
34         exit;
35     }
36    
37     if(param('openid.sig')){
38         my $vident = $csr->verified_identity or die $!;
39         $session->param('openid_url', $vident->url);
40         return 0;
41     }
42
43     return 1;
44 }
45
46 sub story {
47     my($pkg, $path, $fn, $story_ref, $title_ref, $body_ref) = @_;
48
49     if($meta::access eq 'private'){
50         $$body_ref = << "EOS";
51         <p class="entryBody">
52             OpenID ǧŸÚ€Ç¥š¥ó¥È¥ê€Ë¥¢¥¯¥»¥¹À©žÂ€ò€«€±€ëŒÂž³€Ç€¹¡£Ç§ŸÚ€¬À®žù€¹€ë€È¡¢ËÜÍè€Î¥š¥ó¥È¥ê€ÎÆâÍÆ€òž«€ë€³€È€¬€Ç€­€Þ€¹¡£€Ê€Œ€«Ã΀é€ó€±€É¡¢ videntity.org €Î¥¢¥«¥Š¥ó¥È€Ç€Ï€Š€Þ€¯€€€¯€Î€Ë¡¢livejournal.com €ä typepad.com €Ç€Ï€Š€Þ€¯€€€­€Þ€»€ó¡£»î€·€Æ€ß€¿€€Êý€Ï¡¢videntity.org €Î¥¢¥«¥Š¥ó¥È€Ç€É€Š€Ÿ¡£¡Êlivejournal.com €Ï¡¢»öÁ°€ËǧŸÚ€·€Æ€ª€±€Ð€Š€Þ€¯€€€­€Þ€¹¡£¡Ë
53         </p>
54
55         <p class="entryBody">
56         videntity.org €Ø€Î¥í¥°¥€¥ó€â¡¢livejournal.com ¡ỀǧŸÚ¡Ë€ä typepad.com €ÎURL€Ç€Ï€Š€Þ€¯€€€«€Ê€€€Î€Ç¡¢²¶€Î€»€€€ž€ã€Ê€€€È»×€€€¿€€¡£
57         </p>
58         <form method="post" action="">
59             <p class="entryBody">
60             OpenID URL:
61             <input class="openid_url" type="text" name="openid_url" size="30" />
62             <input type="submit" value="ǧŸÚ" />
63             <input type="hidden" name="auth_openid" value="1" />
64             </p>
65         </form>
66 EOS
67     }
68 }
69
70 sub foot {
71     my $cookie = cookie(
72                         -name   => $session->name,
73                         -value  => $session->id,
74                         );
75     $blosxom::header->{ -cookie } = $cookie;
76 }
77
78
79 1;
Note: See TracBrowser for help on using the browser.