From 002d4d4b8b8508229d000f620c1db9be53f7cae9 Mon Sep 17 00:00:00 2001 From: Martin Haase <martin.haase@daasi.de> Date: Wed, 20 Oct 2010 15:48:11 +0000 Subject: [PATCH] so far ready, but no slc git-svn-id: https://textgridlab.org/svn/textgrid/trunk/middleware/tgauth@7508 7c539038-3410-0410-b1ec-0f2a7bf1c452 --- .../WebAuthN/PutAttributes.php | 16 ++++++++-------- .../WebAuthN/TextGrid-WebAuth-Community.php | 10 +++++----- .../tglib/RBAC.class.php | 14 +++++++++++--- .../tglib/WebUtils.class.php | 2 +- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/info.textgrid.middleware.tgauth.webauth/WebAuthN/PutAttributes.php b/info.textgrid.middleware.tgauth.webauth/WebAuthN/PutAttributes.php index 2463852..26815aa 100755 --- a/info.textgrid.middleware.tgauth.webauth/WebAuthN/PutAttributes.php +++ b/info.textgrid.middleware.tgauth.webauth/WebAuthN/PutAttributes.php @@ -41,19 +41,22 @@ $thedisplayname = "anonymous"; //phpinfo(); foreach ($attributes as $a) { if ($util->isBoolean($a)) { - if (isset ( $_REQUEST[$a->name])) { + if (isset ( $_REQUEST[$a->name]) && $_REQUEST[$a->name] == TRUE) { $na = new StdClass(); $na->name = $a->name; - $na->value = TRUE; + $na->value = "TRUE"; $newattributes[] = $na; } else { $na = new StdClass(); $na->name = $a->name; - $na->value = FALSE; + $na->value = "FALSE"; $newattributes[] = $na; } - } else if (isset ( $_REQUEST[$a->name]) && !isset ($a->value) - || ( isset( $a->value) && !$_REQUEST[$a->name] === $a->value)) { + } else if (isset ( $_REQUEST[$a->name]) + && strlen($_REQUEST[$a->name]) > 0 + && (!isset ($a->value) + || ( isset( $a->value) + && !($_REQUEST[$a->name] === $a->value)))) { $na = new StdClass(); $na->name = $a->name; $na->value = $_REQUEST[$a->name]; @@ -62,9 +65,6 @@ foreach ($attributes as $a) { if ($a->name === "displayname" && isset ($a->value)) { // set Display Name $thedisplayname = $a->value; } - if ($na->name === "displayname") { // Overwrite if set anew - $thedisplayname = $na->value; - } } $res = $rbac->setAttributes($newattributes, $Sid, $loginmode ); diff --git a/info.textgrid.middleware.tgauth.webauth/WebAuthN/TextGrid-WebAuth-Community.php b/info.textgrid.middleware.tgauth.webauth/WebAuthN/TextGrid-WebAuth-Community.php index 4d2a4d3..4eb42bb 100644 --- a/info.textgrid.middleware.tgauth.webauth/WebAuthN/TextGrid-WebAuth-Community.php +++ b/info.textgrid.middleware.tgauth.webauth/WebAuthN/TextGrid-WebAuth-Community.php @@ -45,7 +45,7 @@ if (isset ($_REQUEST["loginname"]) && strlen($_REQUEST["loginname"]) > 0 // Variant 2: Shibboleth gave us the right REMOTE_USER. -// We create a Session here, also vor Variant1 +// We create a Session here, also for Variant1 if (isset ($_SERVER["REMOTE_USER"])) { // this holds for shib, too // now creating session, activating roles, etc, in RBAC @@ -81,9 +81,9 @@ if (isset ($_SERVER["REMOTE_USER"])) { // this holds for shib, too } } // This is Variant 3: No Session Creation, but just a desire to see (and update) User Attributes -else if (isset ($_REQUEST["sid"]) && strlen($_REQUEST["sid"]) > 0 ) { +else if (isset ($_REQUEST["Sid"]) && strlen($_REQUEST["Sid"]) > 0 ) { // we might have come directly here using the sid and use an earlier session - $Sid = $_REQUEST["sid"]; + $Sid = $_REQUEST["id"]; } else { trigger_error("WebAuth does not know what to do, exiting.", E_USER_WARNING); exit; @@ -101,10 +101,10 @@ if ($rbac->enoughUserAttributes( $Sid ) && isset ($_SERVER["REMOTE_USER"])) { $CSResult["rbachash"], array("slcmode" => FALSE) // SLCs only via Shibboleth ); - $rbac->updateAttributes ( $ProvidedAttributes, $AttributeMap ); // not vital and second-order + $rbac->updateAttributes ( $ProvidedAttributes, $AttributeMap, $Sid ); // not vital and second-order } else { // now presenting the form, let JavaScript take care for the non-empty-check and the help - // the form will return either displaying the Sid or just a ACK + // the form will return either displaying the Sid or just an ACK $util->printAttributeForm( $attributes, $ProvidedAttributes, $AttributeMap, $Sid, $authZinstance, $_SERVER["REMOTE_USER"]); } diff --git a/info.textgrid.middleware.tgauth.webauth/tglib/RBAC.class.php b/info.textgrid.middleware.tgauth.webauth/tglib/RBAC.class.php index 35c6e6e..c8fc3f9 100644 --- a/info.textgrid.middleware.tgauth.webauth/tglib/RBAC.class.php +++ b/info.textgrid.middleware.tgauth.webauth/tglib/RBAC.class.php @@ -302,9 +302,17 @@ class RBAC { return TRUE; } - function updateAttributes ( $map ) { - - return TRUE; + function updateAttributes ( $attrs, $map, $Sid ) { + $newattributes = array(); + foreach ($map as $name => $value) { + if (isset($attrs[$value])) { + $na = new StdClass(); + $na->name = $name; + $na->value = $attrs[$value]; + $newattributes[] = $na; + } + } + return $this->setAttributes ($newattributes, $Sid, TRUE); } function setAttributes ( $attrs, $Sid, $loginmode ) { diff --git a/info.textgrid.middleware.tgauth.webauth/tglib/WebUtils.class.php b/info.textgrid.middleware.tgauth.webauth/tglib/WebUtils.class.php index f6c2d77..8294382 100644 --- a/info.textgrid.middleware.tgauth.webauth/tglib/WebUtils.class.php +++ b/info.textgrid.middleware.tgauth.webauth/tglib/WebUtils.class.php @@ -152,7 +152,7 @@ class WebUtils { foreach ($existingAttrs as $a) { if ($a->mandatory) { echo " if (document.Formular.". $a->name . ".value == \"\") {\n"; - echo " alert(\"Please specify your ".$a->displayname .". \\n(".$a->description . ").\");\n"; + echo " alert(\"Please specify your ".$a->displayname . "\\n(".$a->description . ").\");\n"; echo " document.Formular.". $a->name . ".focus();\n"; echo " return false;\n"; echo " }\n"; -- GitLab