tips:format_user
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | tips:format_user [2005-10-05 09:55] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Using CN (or other portion) from Client Cert ====== | ||
+ | ** Background ** | ||
+ | |||
+ | All access to edit our wiki is controlled using client certificates (over SSL). | ||
+ | |||
+ | This means REMOTE_USER is set to the entire certificate subject, which can be very very long as those using certificates for authentication probably know. | ||
+ | |||
+ | The long subject as username makes it difficult to determine the actual user when looking at revision history or page footers, and clutters the overall experience. | ||
+ | |||
+ | ** Patch ** | ||
+ | |||
+ | The following patch makes it easy to pick out a portion of the certificate subject to use as the " | ||
+ | |||
+ | This is a non-destructive change, the entire subject is still stored with edits, but only the portion you select is displayed on the page. This portion may be changed at any time. | ||
+ | |||
+ | dokuwiki_format_user.diff | ||
+ | < | ||
+ | Index: inc/ | ||
+ | =================================================================== | ||
+ | --- inc/ | ||
+ | +++ inc/ | ||
+ | @@ -370,7 +370,7 @@ | ||
+ | print '< | ||
+ | | ||
+ | print '< | ||
+ | - print $lang[' | ||
+ | + print $lang[' | ||
+ | print '</ | ||
+ | } | ||
+ | print ' '; | ||
+ | @@ -382,13 +382,13 @@ | ||
+ | print $date; | ||
+ | | ||
+ | print ' ' | ||
+ | - print $INFO[' | ||
+ | + print format_user($INFO[' | ||
+ | } | ||
+ | | ||
+ | print ' & | ||
+ | print $lang[' | ||
+ | print ': '; | ||
+ | - print $INFO[' | ||
+ | + print format_user($INFO[' | ||
+ | } | ||
+ | } | ||
+ | print '</ | ||
+ | @@ -628,7 +628,7 @@ | ||
+ | print $INFO[' | ||
+ | print ' <span class=" | ||
+ | print $INFO[' | ||
+ | - if($INFO[' | ||
+ | + if($INFO[' | ||
+ | print ' | ||
+ | |||
+ | print ' | ||
+ | @@ -644,7 +644,7 @@ | ||
+ | print $info[' | ||
+ | print ' <span class=" | ||
+ | print $info[' | ||
+ | - if($info[' | ||
+ | + if($info[' | ||
+ | print ' | ||
+ | |||
+ | print '<a href="' | ||
+ | @@ -673,7 +673,7 @@ | ||
+ | print ' ' | ||
+ | print ' <span class=" | ||
+ | print $recents[$id][' | ||
+ | - if($recents[$id][' | ||
+ | + if($recents[$id][' | ||
+ | print ' | ||
+ | print '</ | ||
+ | } | ||
+ | Index: inc/ | ||
+ | =================================================================== | ||
+ | --- inc/ | ||
+ | +++ inc/ | ||
+ | @@ -562,4 +562,19 @@ | ||
+ | | ||
+ | } | ||
+ | |||
+ | +/** | ||
+ | + * Extracts common name (CN) from client certificates when displaying user info. | ||
+ | + * | ||
+ | + * @author August Zajonc < | ||
+ | + */ | ||
+ | +function format_user($user) { | ||
+ | + | ||
+ | + if (strpos($user, | ||
+ | + if (preg_match(" | ||
+ | + return $matches[1]; | ||
+ | + } | ||
+ | + | ||
+ | + | ||
+ | +} | ||
+ | + | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | augustz@augustz.com |
tips/format_user.txt · Last modified: 2005-10-05 09:55 by 127.0.0.1