-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauth_openid
More file actions
executable file
·80 lines (67 loc) · 2.14 KB
/
auth_openid
File metadata and controls
executable file
·80 lines (67 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl
# Blosxom Plugin: auth_openid
# Author: Gosuke Miyashita <miya@mizzy.org>
# Version: 2005-11-08
# Blosxom Home/Docs/Licensing: http://www.blosxom.com/
package auth_openid;
use strict;
use CGI qw(:standard);
use CGI::Session;
use Net::OpenID::Consumer;
use File::Cache;
my $session = CGI::Session->new();
sub start {
return 0 if $session->param('openid_url');
my $cgi = CGI->new;
my $csr = Net::OpenID::Consumer->new(
args => $cgi,
consumer_secret => '012345',
#cache => File::Cache->new,
debug => 0,
);
if(param('auth_openid')){
my $cident = $csr->claimed_identity(param('openid_url'));
my $curl = $cident->check_url(
return_to => "$blosxom::url/$blosxom::path_info",
trust_root => 'http://mizzy.org/',
delayed_return => 1,
);
print "Location: $curl\n\n";
exit;
}
if(param('openid.sig')){
my $vident = $csr->verified_identity or die $!;
$session->param('openid_url', $vident->url);
return 0;
}
return 1;
}
sub story {
my($pkg, $path, $fn, $story_ref, $title_ref, $body_ref) = @_;
if($meta::access eq 'private'){
$$body_ref = << "EOS";
<p class="entryBody">
OpenID 認証でエントリにアクセス制限をかける実験です。認証が成功すると、本来のエントリの内容を見ることができます。なぜか知らんけど、 videntity.org のアカウントではうまくいくのに、livejournal.com や typepad.com ではうまくいきません。試してみたい方は、videntity.org のアカウントでどうぞ。(livejournal.com は、事前に認証しておけばうまくいきます。)
</p>
<p class="entryBody">
videntity.org へのログインも、livejournal.com (未認証)や typepad.com のURLではうまくいかないので、俺のせいじゃないと思いたい。
</p>
<form method="post" action="">
<p class="entryBody">
OpenID URL:
<input class="openid_url" type="text" name="openid_url" size="30" />
<input type="submit" value="認証" />
<input type="hidden" name="auth_openid" value="1" />
</p>
</form>
EOS
}
}
sub foot {
my $cookie = cookie(
-name => $session->name,
-value => $session->id,
);
$blosxom::header->{ -cookie } = $cookie;
}
1;