OSDN Git Service

BugTrack2/373 AUTH_TYPE_EXTERNAL - Add Log-in and Log-out menu
authorumorigu <umorigu@gmail.com>
Fri, 22 Jan 2016 16:28:53 +0000 (01:28 +0900)
committerumorigu <umorigu@gmail.com>
Fri, 22 Jan 2016 16:28:53 +0000 (01:28 +0900)
lib/auth.php
lib/html.php
pukiwiki.ini.php

index 710908f..e23ac01 100644 (file)
@@ -182,7 +182,6 @@ function basic_auth($page, $auth_flag, $exit_flag, $auth_pages, $title_cannot)
 {
        global $auth_method_type, $auth_users, $_msg_auth, $auth_user, $auth_groups;
        global $auth_user_groups, $auth_type, $g_query_string;
-       global $auth_external_login_url;
        // Checked by:
        $target_str = '';
        if ($auth_method_type == 'pagename') {
@@ -212,15 +211,13 @@ function basic_auth($page, $auth_flag, $exit_flag, $auth_pages, $title_cannot)
                        } elseif (AUTH_TYPE_FORM === $auth_type) {
                                $url_after_login = get_script_uri() . '?' . $g_query_string;
                                $loginurl = get_script_uri() . '?plugin=loginform'
-                                       . '&page=' . pagename_urlencode($page)
+                                       . '&page=' . rawurlencode($page)
                                        . '&url_after_login=' . rawurlencode($url_after_login);
                                header('HTTP/1.0 302 Found');
                                header('Location: ' . $loginurl);
                        } elseif (AUTH_TYPE_EXTERNAL === $auth_type) {
                                $url_after_login = get_script_uri() . '?' . $g_query_string;
-                               $loginurl = $auth_external_login_url . '?'
-                                       . '&page=' . pagename_urlencode($page)
-                                       . '&url_after_login=' . rawurlencode($url_after_login);
+                               $loginurl = get_auth_external_login_url($page, $url_after_login);
                                header('HTTP/1.0 302 Found');
                                header('Location: ' . $loginurl);
                        }
@@ -458,3 +455,18 @@ function form_auth_redirect($location, $page)
                header('Location: ' . $url);
        }
 }
+
+/**
+ * Get External Auth log-in URL
+ */
+function get_auth_external_login_url($page, $url_after_login) {
+       global $auth_external_login_url_base;
+       $sep = '&';
+       if (strpos($auth_external_login_url_base, '?') === FALSE) {
+               $sep = '?';
+       }
+       $url = $auth_external_login_url_base . $sep
+               . 'page=' . rawurlencode($page)
+               . '&url_after_login=' . rawurlencode($url_after_login);
+       return $url;
+}
index 139bccb..8be5be4 100644 (file)
@@ -26,7 +26,7 @@ function catbody($title, $page, $body)
 
        $enable_login = false;
        $enable_logout = false;
-       if (AUTH_TYPE_FORM === $auth_type) {
+       if (AUTH_TYPE_FORM === $auth_type || AUTH_TYPE_EXTERNAL === $auth_type) {
                if ($auth_user) {
                        $enable_logout = true;
                } else {
@@ -70,7 +70,15 @@ function catbody($title, $page, $body)
        $_LINK['top']      = "$script?" . pagename_urlencode($defaultpage);
        $_LINK['unfreeze'] = "$script?cmd=unfreeze&amp;page=$r_page";
        $_LINK['upload']   = "$script?plugin=attach&amp;pcmd=upload&amp;page=$r_page";
-       $_LINK['login']    = "$script?plugin=loginform&amp;pcmd=login&amp;page=$r_page";
+       switch ($auth_type) {
+               case AUTH_TYPE_FORM:
+                       $login_link = "$script?plugin=loginform&pcmd=login&page=$r_page";
+                       break;
+               case AUTH_TYPE_EXTERNAL:
+                       $login_link = get_auth_external_login_url($_page, $_LINK['reload']);
+                       break;
+       }
+       $_LINK['login']    = htmlsc($login_link);
        $_LINK['logout']   = "$script?plugin=loginform&amp;pcmd=logout&amp;page=$r_page";
 
        // Compat: Skins for 1.4.4 and before
index 6da71a5..bd89e71 100644 (file)
@@ -237,7 +237,7 @@ $auth_groups = array(
 // Authentication type
 // AUTH_TYPE_FORM, AUTH_TYPE_BASIC or AUTH_TYPE_EXTERNAL
 // $auth_type = AUTH_TYPE_FORM;
-// $auth_external_login_url = './exlogin.php';
+// $auth_external_login_url_base = './exlogin.php';
 
 /////////////////////////////////////////////////
 // Authentication method