aboutsummaryrefslogtreecommitdiff
path: root/www/authenticate.pl
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2014-05-04 18:35:10 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2014-05-04 18:35:10 +0200
commitd8907f11f5c255727b8a814746a0114e5c62e30a (patch)
tree96b1b1e2531a3043e9ab31e66abdd72507136b1d /www/authenticate.pl
parent36fafa2ae962d6844b6e20ffbbac92ecf36a059d (diff)
Support Google Apps authentication.
Diffstat (limited to 'www/authenticate.pl')
-rwxr-xr-xwww/authenticate.pl48
1 files changed, 48 insertions, 0 deletions
diff --git a/www/authenticate.pl b/www/authenticate.pl
new file mode 100755
index 0000000..a36ad02
--- /dev/null
+++ b/www/authenticate.pl
@@ -0,0 +1,48 @@
+#! /usr/bin/env perl
+# Copyright 2012, Matthias Andreas Benkard <code@mail.matthias.benkard.de>.
+
+use common::sense;
+#use Modern::Perl 2011;
+use Modern::Perl;
+
+use JSON;
+
+use CGI;
+use CGI::Fast;
+use CGI::Session;
+
+use Net::Google::FederatedLogin;
+
+do "common.pl";
+
+while (my $cgi = new CGI::Fast) {
+ load_config();
+
+ my $claimed_email = $cgi->param('email');
+
+ my $g = Net::Google::FederatedLogin->new(
+ claimed_id => $claimed_email,
+ return_to => reluri($cgi, 'login.pl'),
+ extensions => [{ns => 'ax',
+ uri => 'http://openid.net/srv/ax/1.0',
+ attributes => {mode => 'fetch_request',
+ required => 'email',
+ type => {email => 'http://axschema.org/contact/email'}}}]
+ );
+
+ my $cookie = $cgi->cookie('mulkid_session');
+ my $session = new CGI::Session("driver:File", $cookie, {Directory=>"/tmp"});
+ $session->param('claimed_email', $claimed_email);
+ if ($cookie) {
+ print $cgi->redirect(-url => $g->get_auth_url());
+ } else {
+ my $cookie = $cgi->cookie(-name => 'mulkid_session',
+ -value => $session->id,
+ -expires => '+1d',
+ #-secure => 1,
+ -httponly => 1,
+ #-domain => '.'.$::MULKONF->{realm}
+ );
+ print $cgi->redirect(-cookie => $cookie, -url => $g->get_auth_url());
+ }
+}