Adjust the default table names to be SQL-standard compliant. Add the other supported...
authorStefan Paetow <stefan.paetow@jisc.ac.uk>
Thu, 18 May 2017 15:28:27 +0000 (16:28 +0100)
committerStefan Paetow <stefan.paetow@jisc.ac.uk>
Thu, 18 May 2017 15:28:27 +0000 (16:28 +0100)
raddb/mods-available/moonshot-targeted-ids
raddb/mods-config/sql/moonshot-targeted-ids/mysql/queries.conf [new file with mode: 0644]
raddb/mods-config/sql/moonshot-targeted-ids/mysql/schema.sql [new file with mode: 0644]
raddb/mods-config/sql/moonshot-targeted-ids/postgresql/queries.conf [new file with mode: 0644]
raddb/mods-config/sql/moonshot-targeted-ids/postgresql/schema.sql [new file with mode: 0644]
raddb/mods-config/sql/moonshot-targeted-ids/sqlite/queries.conf
raddb/mods-config/sql/moonshot-targeted-ids/sqlite/schema.sql
raddb/policy.d/moonshot-targeted-ids

index 87ea1b5..bcf69bc 100644 (file)
@@ -3,7 +3,7 @@
 #  $Id$
 
 #
-#  Write Moonshot-*-TargetedId to the database.
+#  Write Moonshot-*-TargetedId (MSTID) to the database.
 #
 #  Schema      raddb/sql/moonshot-targeted-ids/<DB>/schema.sql
 #  Queries     raddb/sql/moonshot-targeted-ids/<DB>/queries.conf
@@ -20,7 +20,7 @@ sql moonshot_tid_sql {
        # The sub-module to use to execute queries. This should match
        # the database you're attempting to connect to.
        #
-       # There are CUI queries available for:
+       # There are MSTID queries available for:
        #    * rlm_sql_mysql
        #    * rlm_sql_postgresql
        #    * rlm_sql_sqlite
@@ -33,8 +33,8 @@ sql moonshot_tid_sql {
                bootstrap = ${modconfdir}/${..:name}/moonshot-targeted-ids/sqlite/schema.sql
        }
 
-       # Write CUI queries to a logfile. Useful for debugging.
-#      logfile = ${logdir}/cuilog.sql
+       # Write MSTID queries to a logfile. Useful for debugging.
+#      logfile = ${logdir}/moonshot-targeted-id-log.sql
 
        pool {
                start = 5
@@ -46,7 +46,11 @@ sql moonshot_tid_sql {
                idle_timeout = 60
        }
 
-       moonshot_tid_table = "moonshot-targeted-ids"
+       #  If you adjust the table name here, you must also modify the table name in
+       #  the moonshot_get_targeted_id.post-auth policy in policy.d/moonshot-targeted-ids
+       #  and the schema.sql files in the mods-config/sql/moonshot-targeted-ids tree.
+       #
+       moonshot_tid_table = "moonshot_targeted_ids"
        sql_user_name = "%{User-Name}"
 
        $INCLUDE ${modconfdir}/${.:name}/moonshot-targeted-ids/${dialect}/queries.conf
diff --git a/raddb/mods-config/sql/moonshot-targeted-ids/mysql/queries.conf b/raddb/mods-config/sql/moonshot-targeted-ids/mysql/queries.conf
new file mode 100644 (file)
index 0000000..68306db
--- /dev/null
@@ -0,0 +1,15 @@
+# -*- text -*-
+#
+#  moonshot-targeted-ids/mysql/queries.conf -- Queries to update a MySQL Moonshot-Targeted-Ids table.
+#
+#  $Id$
+
+post-auth {
+       #  Query to store the Moonshot-*-TargetedId
+       query = "\
+               INSERT IGNORE INTO ${..moonshot_tid_table} \
+                       (gss_acceptor, namespace, username, targeted_id) \
+               VALUES \
+                       ('%{control:Moonshot-MSTID-GSS-Acceptor}', '%{control:Moonshot-MSTID-Namespace}', \
+                       '%{tolower:%{User-Name}}', '%{control:Moonshot-MSTID-TargetedId}')"
+}
diff --git a/raddb/mods-config/sql/moonshot-targeted-ids/mysql/schema.sql b/raddb/mods-config/sql/moonshot-targeted-ids/mysql/schema.sql
new file mode 100644 (file)
index 0000000..8a33dc1
--- /dev/null
@@ -0,0 +1,8 @@
+CREATE TABLE `moonshot_targeted_ids` (
+  `gss_acceptor` varchar(254) NOT NULL default '',
+  `namespace` varchar(36) NOT NULL default '',
+  `username` varchar(64) NOT NULL default '',
+  `targeted_id` varchar(128) NOT NULL default '',
+  `creationdate` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  PRIMARY KEY  (`username`,`gss_acceptor`,`namespace`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/raddb/mods-config/sql/moonshot-targeted-ids/postgresql/queries.conf b/raddb/mods-config/sql/moonshot-targeted-ids/postgresql/queries.conf
new file mode 100644 (file)
index 0000000..f757a87
--- /dev/null
@@ -0,0 +1,15 @@
+# -*- text -*-
+#
+#  moonshot-targeted-ids/postgresql/queries.conf -- Queries to update a PostgreSQL Moonshot-*-Targeted-Ids table.
+#
+#  $Id$
+
+post-auth {
+       #  Query to store the Moonshot-*-TargetedId
+       query = "\
+               INSERT INTO ${..moonshot_tid_table} \
+                       (gss_acceptor, namespace, username, targeted_id) \
+               VALUES \
+                       ('%{control:Moonshot-MSTID-GSS-Acceptor}', '%{control:Moonshot-MSTID-Namespace}', \
+                       '%{tolower:%{User-Name}}', '%{control:Moonshot-MSTID-TargetedId}')"
+}
diff --git a/raddb/mods-config/sql/moonshot-targeted-ids/postgresql/schema.sql b/raddb/mods-config/sql/moonshot-targeted-ids/postgresql/schema.sql
new file mode 100644 (file)
index 0000000..649c627
--- /dev/null
@@ -0,0 +1,8 @@
+CREATE TABLE moonshot_targeted_ids (
+  gss_acceptor varchar(254) NOT NULL DEFAULT '',
+  namespace varchar(36) NOT NULL DEFAULT '',
+  username varchar(64) NOT NULL DEFAULT '',
+  targeted_id varchar(128) NOT NULL DEFAULT '',
+  creationdate TIMESTAMP with time zone NOT NULL default 'now()',
+  PRIMARY KEY  (username, gss_acceptor, namespace)
+);
index 9418b17..8cdb803 100644 (file)
@@ -7,7 +7,7 @@
 post-auth {
        #  Query to store the Moonshot-*-TargetedId
        query = "\
-               INSERT INTO `${..moonshot_tid_table}` \
+               INSERT INTO ${..moonshot_tid_table} \
                        (gss_acceptor, namespace, username, targeted_id) \
                VALUES \
                        ('%{control:Moonshot-MSTID-GSS-Acceptor}', '%{control:Moonshot-MSTID-Namespace}', \
index 50241c7..71195ad 100644 (file)
@@ -1,4 +1,4 @@
-CREATE TABLE `moonshot-targeted-ids` (
+CREATE TABLE `moonshot_targeted_ids` (
   `gss_acceptor` varchar(254) NOT NULL default '',
   `namespace` varchar(36) NOT NULL default '',
   `username` varchar(64) NOT NULL default '',
index 40682fa..ae8941e 100644 (file)
@@ -208,7 +208,7 @@ moonshot_get_targeted_id.post-auth {
                #
                update control {
                        Moonshot-MSTID-TargetedId := "%{moonshot_tid_sql:\
-                               SELECT targeted_id FROM `moonshot-targeted-ids` \
+                               SELECT targeted_id FROM moonshot_targeted_ids \
                                WHERE gss_acceptor = '%{control:Moonshot-MSTID-GSS-Acceptor}' \
                                AND namespace = '%{control:Moonshot-MSTID-Namespace}' \
                                AND username = '%{tolower:%{User-Name}}'}"