DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:password

Password Plugin

Compatible with DokuWiki

2006-03-09

plugin Hides passwords from plain view

Last updated on
2007-09-26
Provides
Syntax

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to toggle

Tagged with hide, password

Description

This password syntax plugin screens text from view. It may be used for storing clear-text passwords which otherwise would be stored fully visible. Only users with write access to the page can view the wiki source. This may be just enough security for non-important passwords or group access in an internal wiki.

Security notice

Use at your own risk! Usage of ACL is recommended. Don't put anything really important in a wiki. Valuable passwords need to be properly encrypted when stored at all. Passwords are still visible in page diffs and in search results!

Usage

Format the text to hide with the following markup:

Password: <PASSWORD>Mew3obrIt4</PASSWORD>

shows

Password: [see wiki source]

Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

<?php
/**
 * Plugin Password: hides passwords with syntax <PASSWORD></PASSWORD>
 * 
 * @license    GPL2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Roland Eckert <roland.eckert@gmail.com>
 */
 
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
 
/**
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
 */
class syntax_plugin_password extends DokuWiki_Syntax_Plugin {
 
    /**
     * return some info
     */
    function getInfo(){
        return array(
            'author' => 'Roland Eckert',
            'email'  => 'roland.eckert@gmail.com',
            'date'   => '2007-09-26',
            'name'   => 'Password Plugin',
            'desc'   => 'This plugin hides passwords from plain view',
            'url'    => 'http://www.dokuwiki.org/plugin:password',
        );
    }
 
    /**
     * What kind of syntax are we?
     */
    function getType(){
        return 'protected';
    }
 
    /**
     * Where to sort in?
     */ 
    function getSort(){
        return 201;
    }
 
    /**
     * Connect pattern to lexer
     */
    function connectTo($mode) {
        $this->Lexer->addEntryPattern('<PASSWORD>(?=.*?</PASSWORD>)',$mode,'plugin_password');
    }
 
    function postConnect() {
        $this->Lexer->addExitPattern('</PASSWORD>','plugin_password');
    }
 
    /**
     * Handle the match
     */
    function handle($match, $state, $pos, &$handler){
        switch ($state) {
            case DOKU_LEXER_ENTER : 
                return array($state, '');
            break;
            case DOKU_LEXER_UNMATCHED :
                return array($state, $match);
            break;
            case DOKU_LEXER_EXIT :
                return array($state, '');
            break;
        }
        return array();
    }
 
    /**
     * Create output
     */
    function render($mode, &$renderer, $data) {
        if($mode == 'xhtml'){
 
           list($state, $match) = $data;
            switch ($state) {
                case DOKU_LEXER_ENTER :      
                    list($color, $background) = $match;
                    $renderer->doc.= '<span style="color:#aaaaaa; padding:2px; border: 1px grey dotted;">';
                    break;
                case DOKU_LEXER_UNMATCHED :
                    $renderer->doc.= 'see wiki source';
                    break;
                case DOKU_LEXER_EXIT :
                    $renderer->doc .= "</span>";
                    break;
            }
            return true;
        }
        return false;
    }
}
?>
plugin/password.txt · Last modified: 2018-06-05 22:00 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki