Apache2-AuthAny

 view release on metacpan or  search on metacpan

db/auth_any.sql  view on Meta::CPAN

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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
-- MySQL dump 10.11
--
-- Host: localhost    Database: auth_any
-- ------------------------------------------------------
-- Server version       5.0.51a-24+lenny5
 
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
 
--
-- Table structure for table `user`
--
 
DROP TABLE IF EXISTS `user`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `user` (
  `UID` int(11) NOT NULL auto_increment,
  `username` varchar(32) NOT NULL,
  `created` datetime NOT NULL,
  `active` tinyint(1) default NULL,
  `timeout` int(11) default NULL,
  `firstName` tinytext,
  `lastName` tinytext,
  PRIMARY KEY  (`UID`),
  UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM AUTO_INCREMENT=166 DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
 
--
-- Table structure for table `userAACookie`
--
 
DROP TABLE IF EXISTS `userAACookie`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `userAACookie` (
  `PID` varchar(100) NOT NULL,
  `SID` tinytext,
  `authId` varchar(100) default NULL,
  `authProvider` varchar(100) default NULL,
  `last` int(11) default NULL,
  `created` datetime NOT NULL,
  `state` enum('logged_out','recognized','authenticated') NOT NULL default 'logged_out',
  `logoutKey` tinytext NOT NULL,
  PRIMARY KEY  (`PID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
 
--
-- Table structure for table `userIdent`
--
 
DROP TABLE IF EXISTS `userIdent`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `userIdent` (
  `UID` int(10) unsigned NOT NULL,
  `authId` varchar(100) NOT NULL,
  `authProvider` varchar(100) NOT NULL,
  PRIMARY KEY  (`authId`,`authProvider`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
 
--
-- Table structure for table `userRole`
--
 
DROP TABLE IF EXISTS `userRole`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `userRole` (
  `UID` int(11) NOT NULL,
  `role` varchar(200) NOT NULL,
  UNIQUE KEY `UID_2` (`UID`,`role`),
  KEY `UID` (`UID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
 
--
-- Table structure for table `userRoleChoice`
--
 
DROP TABLE IF EXISTS `userRoleChoice`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `userRoleChoice` (
  `UID` int(11) NOT NULL,
  `role` varchar(200) NOT NULL,
  UNIQUE KEY `UID` (`UID`,`role`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
 
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

examples/demo-config/demo_auth_any_database.sql  view on Meta::CPAN

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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
-- MySQL dump 10.11
--
-- Host: localhost    Database: auth_any
-- ------------------------------------------------------
-- Server version       5.0.51a-24+lenny5
 
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
 
--
-- Table structure for table `user`
--
 
DROP TABLE IF EXISTS `user`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `user` (
  `UID` int(11) NOT NULL auto_increment,
  `username` varchar(32) NOT NULL,
  `created` datetime NOT NULL,
  `active` tinyint(1) default NULL,
  `timeout` int(11) default NULL,
  `firstName` tinytext,
  `lastName` tinytext,
  PRIMARY KEY  (`UID`),
  UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM AUTO_INCREMENT=166 DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
 
--
-- Dumping data for table `user`
--
 
LOCK TABLES `user` WRITE;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` VALUES (164,'babbage','2011-01-17 16:23:52',1,30,'Charles','Babbage'),(165,'turing','2011-01-17 20:40:21',1,120,'Alan','Turing');
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
UNLOCK TABLES;
 
--
-- Table structure for table `userAACookie`
--
 
DROP TABLE IF EXISTS `userAACookie`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `userAACookie` (
  `PID` varchar(100) NOT NULL,
  `SID` tinytext,
  `authId` varchar(100) default NULL,
  `authProvider` varchar(100) default NULL,
  `last` int(11) default NULL,
  `created` datetime NOT NULL,
  `state` enum('logged_out','recognized','authenticated') NOT NULL default 'logged_out',
  `logoutKey` tinytext NOT NULL,
  PRIMARY KEY  (`PID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
 
--
-- Dumping data for table `userAACookie`
--
 
LOCK TABLES `userAACookie` WRITE;
/*!40000 ALTER TABLE `userAACookie` DISABLE KEYS */;
INSERT INTO `userAACookie` VALUES ('0257682d03bee509c98df8eba48abc10','0f867d18bf8c0d4f21af10f3af1981e6','aatest3','basic',1299612418,'2011-02-10 10:09:33','recognized','639ae4fb44d92ff26b2554f1456aaac4'),('5d5acf85adfbbc586bafac708b86f732','7705f3ab...
/*!40000 ALTER TABLE `userAACookie` ENABLE KEYS */;
UNLOCK TABLES;
 
--
-- Table structure for table `userIdent`
--
 
DROP TABLE IF EXISTS `userIdent`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `userIdent` (
  `UID` int(10) unsigned NOT NULL,
  `authId` varchar(100) NOT NULL,
  `authProvider` varchar(100) NOT NULL,
  PRIMARY KEY  (`authId`,`authProvider`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
 
--
-- Dumping data for table `userIdent`
--
 
LOCK TABLES `userIdent` WRITE;
/*!40000 ALTER TABLE `userIdent` DISABLE KEYS */;
INSERT INTO `userIdent` VALUES (164,'aatest2','basic'),(165,'aatest4','basic'),(164,'aatest3','basic'),(164,'kgoldov@gmail.com','google');
/*!40000 ALTER TABLE `userIdent` ENABLE KEYS */;
UNLOCK TABLES;
 
--
-- Table structure for table `userRole`
--
 
DROP TABLE IF EXISTS `userRole`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `userRole` (
  `UID` int(11) NOT NULL,
  `role` varchar(200) NOT NULL,
  UNIQUE KEY `UID_2` (`UID`,`role`),
  KEY `UID` (`UID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
 
--
-- Dumping data for table `userRole`
--
 
LOCK TABLES `userRole` WRITE;
/*!40000 ALTER TABLE `userRole` DISABLE KEYS */;
INSERT INTO `userRole` VALUES (164,'admin'),(164,'scientist'),(165,'scientist');
/*!40000 ALTER TABLE `userRole` ENABLE KEYS */;
UNLOCK TABLES;
 
--
-- Table structure for table `userRoleChoice`
--
 
DROP TABLE IF EXISTS `userRoleChoice`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `userRoleChoice` (
  `UID` int(11) NOT NULL,
  `role` varchar(200) NOT NULL,
  UNIQUE KEY `UID` (`UID`,`role`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
 
--
-- Dumping data for table `userRoleChoice`
--
 
LOCK TABLES `userRoleChoice` WRITE;
/*!40000 ALTER TABLE `userRoleChoice` DISABLE KEYS */;
INSERT INTO `userRoleChoice` VALUES (165,'scientist');
/*!40000 ALTER TABLE `userRoleChoice` ENABLE KEYS */;

examples/demo-gate/gate-logic.php  view on Meta::CPAN

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
   $dbUserName = $_SERVER[AUTH_ANY_DB_USER];
   $projectDbName = $_SERVER[AUTH_ANY_DB_NAME];
   $projectDbHost = $_SERVER[AUTH_ANY_DB_HOST];
   $host = $projectDbHost ? $projectDbHost : 'localhost';
 
   $conection = @mysql_connect($host, $dbUserName, $dbPassword);
   mysql_select_db($projectDbName) or die (mysql_error());
 
   $sql = "SELECT logoutKey FROM userAACookie WHERE PID = '$_COOKIE[AA_PID]'";
 
   mysql_query('set character set utf8');
   $content = mysql_query($sql) or die (mysql_error());
   $rs = mysql_fetch_array($content);
   $logoutKey = $rs['logoutKey'];
   $provider_string = $provider . "_aa-key_" . $logoutKey;
   return("/aa_auth/$provider_string/redirect?req=$encoded_req");
}
 
?>

google/check-auth.php  view on Meta::CPAN

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# add to DB
$dbPassword = trim(file_get_contents($_SERVER[AUTH_ANY_DB_PW_FILE]));
$dbUserName = $_SERVER[AUTH_ANY_DB_USER];
$projectDbName = $_SERVER[AUTH_ANY_DB_NAME];
$projectDbHost = $_SERVER[AUTH_ANY_DB_HOST];
$host = $projectDbHost ? $projectDbHost : 'localhost';
 
$conection = @mysql_connect($host, $dbUserName, $dbPassword);
mysql_select_db($projectDbName) or abortSignin( mysql_error() );
 
mysql_query('set character set utf8');
 
$nowsec = time();
$psql = "UPDATE userAACookie SET authId = '$result[email]', authProvider = '$atype',
                                SID = '$sid', state = 'authenticated', last = '$nowsec'
     WHERE PID = '$pid'";
 
if (mysql_query($psql)) {
    setcookie($c_name, $c_value, $c_expire, $c_path, $c_domain);
 
} else {

lib/Apache2/AuthAny/DB.pm  view on Meta::CPAN

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
        chomp $dbPassword;      #remove the trailing new line
        die "Could not get password" unless $dbPassword;
        my $dbName = $ENV{AUTH_ANY_DB_NAME} || die "Env variable AUTH_ANY_DB_NAME required";
        my $db;
        $db = $ENV{AUTH_ANY_DB} || "mysql";
        my $dsn = "database=$dbName";
        my $dbHost = $ENV{AUTH_ANY_DB_HOST};
 
        $dsn .= ";host=$dbHost" if $dbHost;
        $dbHandle = DBI->connect("DBI:$db:$dsn", $dbUser, $dbPassword) or die "user: $dbUser, errstr: $DBI::errstr";
        $dbHandle->do('SET CHARACTER SET utf8');
    }
 
    bless ($self, $class);
    return $self;
}
 
sub useDB {
    return;
    my $self = shift;
    my $auth_any_db = $self->{auth_any_db};



( run in 0.580 second using v1.01-cache-2.11-cpan-49f99fa48dc )