• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

PukiWiki


Commit MetaInfo

修訂103b575cf95f8b1a16ec7519bac56cfadc58b0d3 (tree)
時間2016-01-23 01:28:53
作者umorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack2/373 AUTH_TYPE_EXTERNAL - Add Log-in and Log-out menu

Change Summary

差異

--- a/lib/auth.php
+++ b/lib/auth.php
@@ -182,7 +182,6 @@ function basic_auth($page, $auth_flag, $exit_flag, $auth_pages, $title_cannot)
182182 {
183183 global $auth_method_type, $auth_users, $_msg_auth, $auth_user, $auth_groups;
184184 global $auth_user_groups, $auth_type, $g_query_string;
185- global $auth_external_login_url;
186185 // Checked by:
187186 $target_str = '';
188187 if ($auth_method_type == 'pagename') {
@@ -212,15 +211,13 @@ function basic_auth($page, $auth_flag, $exit_flag, $auth_pages, $title_cannot)
212211 } elseif (AUTH_TYPE_FORM === $auth_type) {
213212 $url_after_login = get_script_uri() . '?' . $g_query_string;
214213 $loginurl = get_script_uri() . '?plugin=loginform'
215- . '&page=' . pagename_urlencode($page)
214+ . '&page=' . rawurlencode($page)
216215 . '&url_after_login=' . rawurlencode($url_after_login);
217216 header('HTTP/1.0 302 Found');
218217 header('Location: ' . $loginurl);
219218 } elseif (AUTH_TYPE_EXTERNAL === $auth_type) {
220219 $url_after_login = get_script_uri() . '?' . $g_query_string;
221- $loginurl = $auth_external_login_url . '?'
222- . '&page=' . pagename_urlencode($page)
223- . '&url_after_login=' . rawurlencode($url_after_login);
220+ $loginurl = get_auth_external_login_url($page, $url_after_login);
224221 header('HTTP/1.0 302 Found');
225222 header('Location: ' . $loginurl);
226223 }
@@ -458,3 +455,18 @@ function form_auth_redirect($location, $page)
458455 header('Location: ' . $url);
459456 }
460457 }
458+
459+/**
460+ * Get External Auth log-in URL
461+ */
462+function get_auth_external_login_url($page, $url_after_login) {
463+ global $auth_external_login_url_base;
464+ $sep = '&';
465+ if (strpos($auth_external_login_url_base, '?') === FALSE) {
466+ $sep = '?';
467+ }
468+ $url = $auth_external_login_url_base . $sep
469+ . 'page=' . rawurlencode($page)
470+ . '&url_after_login=' . rawurlencode($url_after_login);
471+ return $url;
472+}
--- a/lib/html.php
+++ b/lib/html.php
@@ -26,7 +26,7 @@ function catbody($title, $page, $body)
2626
2727 $enable_login = false;
2828 $enable_logout = false;
29- if (AUTH_TYPE_FORM === $auth_type) {
29+ if (AUTH_TYPE_FORM === $auth_type || AUTH_TYPE_EXTERNAL === $auth_type) {
3030 if ($auth_user) {
3131 $enable_logout = true;
3232 } else {
@@ -70,7 +70,15 @@ function catbody($title, $page, $body)
7070 $_LINK['top'] = "$script?" . pagename_urlencode($defaultpage);
7171 $_LINK['unfreeze'] = "$script?cmd=unfreeze&amp;page=$r_page";
7272 $_LINK['upload'] = "$script?plugin=attach&amp;pcmd=upload&amp;page=$r_page";
73- $_LINK['login'] = "$script?plugin=loginform&amp;pcmd=login&amp;page=$r_page";
73+ switch ($auth_type) {
74+ case AUTH_TYPE_FORM:
75+ $login_link = "$script?plugin=loginform&pcmd=login&page=$r_page";
76+ break;
77+ case AUTH_TYPE_EXTERNAL:
78+ $login_link = get_auth_external_login_url($_page, $_LINK['reload']);
79+ break;
80+ }
81+ $_LINK['login'] = htmlsc($login_link);
7482 $_LINK['logout'] = "$script?plugin=loginform&amp;pcmd=logout&amp;page=$r_page";
7583
7684 // Compat: Skins for 1.4.4 and before
--- a/pukiwiki.ini.php
+++ b/pukiwiki.ini.php
@@ -237,7 +237,7 @@ $auth_groups = array(
237237 // Authentication type
238238 // AUTH_TYPE_FORM, AUTH_TYPE_BASIC or AUTH_TYPE_EXTERNAL
239239 // $auth_type = AUTH_TYPE_FORM;
240-// $auth_external_login_url = './exlogin.php';
240+// $auth_external_login_url_base = './exlogin.php';
241241
242242 /////////////////////////////////////////////////
243243 // Authentication method