]> www.wagner.pp.ru Git - oss/vjournal.git/blob - bin/login
new description
[oss/vjournal.git] / bin / login
1 #!/usr/bin/perl -T
2
3 =head1 NAME
4
5 vjlogin - authenticate openid users
6
7 =head1 SYNOPSIS
8
9         http://your.server.com/cgi-bin/vjlogin/your-blog-top
10
11 =head1 DESCRIPTION
12
13 Authenticates user with external OpenID provider, creates VJournal
14 session and sets approprieate cookie.
15
16 =head1 WORKFLOW
17
18 =over 4
19
20 =item No paramteters,
21
22 Show login form
23
24 =item Parameters username and site
25
26 Start openid auth
27
28 =item OpenID parameters
29
30 Perform authentication. If successul, create session.
31 If E-mail is provided, redirect back to blog. Otherwise - show form
32 to requset E-Mail. Create  session anyway.
33
34 =item email parameter + cookie
35
36 Update session. Redirect to blog.
37
38 =back
39
40 =cut
41
42 use CGI;
43 use Net::OpenID::Consumer;
44 use VJournal::Session;
45
46 sub verify {
47         my ($cgi,$consumer)=@_;
48         if (my $setup_url = $csr->user_setup_url) {
49                 print $cgi->redirect(-location=>$setup_url);
50                 return;
51         } elsif ($csr->user_cancel) {
52                 show_error("OpenID server cancelled operation");
53         } elsif (my $vident= $csr->verified_identity) {
54                 my $user = $vident->url();
55                 # Getting OPENDID extensions from 
56                 my @extension =grep { defined } (
57                 $vident->signed_extension_fields('http://openid.net/extensions/sreg/1.1'),
58                 $vident->signed_extension_fields('http://openid.net/srv/ax/1.0'),
59
60                 );
61                 
62                 # getting foaf info;
63                 my $foaf = $vident->declared_foaf();
64                 my ($email,$avatar) = ($foaf?get_foaf($foaf):(undef,undef));
65                 my $session = VJournal::Session->create(-cgi=>$cgi,
66                         -name => $name, -idenity=>$user);
67                 if (!$email) {
68                         show_email_form);
69         }
70
71 }
72