Viewing File: /usr/lib/python2.7/site-packages/passlib/apache.pyc


Xc@sdZddlmZddlZejeZddlZddlm	Z	ddl
mZmZddl
mZddlmZddlmZdd	lmZmZmZdd
lmZddlmZmZmZmZdd
gZeZ dZ!dZ"dZ#dZ$dZ%defdYZ&e'Z(dZ)e)Z*dZ+e+Z,de&fdYZ-d
e&fdYZ.dS(s(passlib.apache - apache password supporti(twith_statementN(twarn(texctregistry(tCryptContext(tExpectedStringError(thtdigest(trender_bytestto_bytestis_ascii_codec(tdeprecated_method(t
join_bytestunicodetBytesIOtPY3tHtpasswdFiletHtdigestFilet:t#s:

	tskippedtrecordt_CommonFilecBs=eZdZdZdZdZdZeZ	dZ
dZedZ
edZdeeededZdZedZejdZedZd	Zded
ZdZdZd
ZdZdZddZdZdZ dZ!dZ"dZ#ddZ$dZ%RS(s0common framework for HtpasswdFile & HtdigestFilecKs8d|krtdn||}|j||S(screate new object from raw string.

        :type data: unicode or bytes
        :arg data:
            database to load, as single string.

        :param \*\*kwds:
            all other keywords are the same as in the class constructor
        tpaths$'path' not accepted by from_string()(t	TypeErrortload_string(tclstdatatkwdstself((s2/usr/lib/python2.7/site-packages/passlib/apache.pytfrom_stringKs

cKs||}|j||S(screate new object from file, without binding object to file.

        :type path: str
        :arg path:
            local filepath to load from

        :param \*\*kwds:
            all other keywords are the same as in the class constructor
        (tload(RRRR((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt	from_path\s
sutf-8cCs|s(tdtddd}t}nt|sCtdn||_||_||_||_d|_	|stdtddt
}n|r|r|jni|_g|_
dS(Ns``encoding=None`` is deprecated as of Passlib 1.6, and will cause a ValueError in Passlib 1.8, use ``return_unicode=False`` instead.t
stacklevelisutf-8s'encoding must be 7-bit ascii compatibleisp``autoload=False`` is deprecated as of Passlib 1.6, and will be removed in Passlib 1.8, use ``new=True`` instead(RtDeprecationWarningtFalseR	t
ValueErrortencodingtreturn_unicodetautosavet_patht_mtimetTrueRt_recordst_source(RRtnewtautoloadR&R$R%((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt__init__ns(
						
	

	cCsyd}|jr|d7}n|jr9|d|j7}n|jdkr\|d|j7}nd|jjt||fS(Nts autosave=Trues path=%rsutf-8s encoding=%rs<%s 0x%0x%s>(R&R'R$t	__class__t__name__tid(Rttail((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt__repr__s	
	cCs|jS(N(R'(R((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRscCs(||jkrd|_n||_dS(Ni(R'R((Rtvalue((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRscCs|jS(s7modify time when last loaded (if bound to a local file)(R((R((s2/usr/lib/python2.7/site-packages/passlib/apache.pytmtimescCsU|jstd|n|jrG|jtjj|jkrGtS|jtS(sBReload from ``self.path`` only if file has changed since last loads%r is not bound to a local file(	R'tRuntimeErrorR(tosRtgetmtimeR"RR)(R((s2/usr/lib/python2.7/site-packages/passlib/apache.pytload_if_changeds	'
cCs|dk	r=t|d}d|_|j|WdQXn|sstdtd|jjtdd|j	S|j
rt|j
d,}tjj
|j
|_|j|WdQXntd|jjtS(	sLoad state from local file.
        If no path is specified, attempts to load from ``self.path``.

        :type path: str
        :arg path: local file to load from

        :type force: bool
        :param force:
            if ``force=False``, only load from ``self.path`` if file
            has changed since last load.

            .. deprecated:: 1.6
                This keyword will be removed in Passlib 1.8;
                Applications should use :meth:`load_if_changed` instead.
        trbiNs%(name)s.load(force=False) is deprecated as of Passlib 1.6,and will be removed in Passlib 1.8; use %(name)s.load_if_changed() instead.tnameR is2%s().path is not set, an explicit path is required(tNonetopenR(t_load_linesRtdictR0R1R!R:R'R8RR9R7R)(RRtforcetfh((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRs 	

	cCs5t||jd}d|_|jt|dS(s@Load state from unicode or bytes string, replacing current stateRiN(RR$R(R?R
(RR((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRs	cCs'|j}i}g}d}xt|D]\}}|j}|sV|jtrf||7}q(n|||d\}	}
|	|krtjd|	||7}q(n|r|jt|fd}n|
||	<|jt	|	fq(W|j
r|jt|fn||_||_dS(sload from sequence of listsR/is1username occurs multiple times in source file: %rN(
t
_parse_recordt	enumeratetlstript
startswitht_BHASHtlogtwarningtappendt_SKIPPEDt_RECORDtrstripR*R+(RtlinestparsetrecordstsourceRtidxtlinettmptkeyR5((s2/usr/lib/python2.7/site-packages/passlib/apache.pyR?s.	

	
	cCstddS(s)parse line of file into (key, value) pairs!should be implemented in subclassN(tNotImplementedError(RRtlineno((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRCscCsB|j}||k}|||<|s>|jjt|fn|S(s
        helper for setting record which takes care of inserting source line if needed;

        :returns:
            bool if key already present
        (R*R+RJRL(RRUR5RPtexisting((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt_set_records	
cCs#|jr|jr|jndS(s0subclass helper to call save() after any changesN(R&R'tsave(R((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt	_autosave!scCs|dk	r:t|d}|j|jWdQXnJ|jrn|j|jtjj|j|_	nt
d|jjdS(shSave current state to file.
        If no path is specified, attempts to save to ``self.path``.
        twbNs%%s().path is not set, cannot autosave(
R=R>t
writelinest_iter_linesR'RZR8RR9R(R7R0R1(RRRB((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRZ&s	cCst|jS(s)Export current state as a string of bytes(RR^(R((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt	to_string4sccs|j}t|}xq|jD]f\}}|tkr?|Vq|tksQt||krcqn|j|||V|j|qW|std|fdS(s#iterator yielding lines of databases'failed to write all records: missing=%rN(R*tsetR+RKRLtAssertionErrort_render_recordtremove(RRPtpendingtactiontcontent((s2/usr/lib/python2.7/site-packages/passlib/apache.pyR^@s	cCstddS(s,given key/value pair, encode as line of files!should be implemented in subclassN(RV(RRUR5((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRb[scCs|j|dS(s)user-specific wrapper for _encode_field()tuser(t
_encode_field(RRg((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt_encode_userbscCs|j|dS(s*realm-specific wrapper for _encode_field()trealm(Rh(RRj((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt
_encode_realmfstfieldcCst|tr$|j|j}n!t|tsEt||nt|dkrptd||fntd|Drtd||fn|S(s+convert field to internal representation.

        internal representation is always bytes. byte strings are left as-is,
        unicode strings encoding using file's default encoding (or ``utf-8``
        if no encoding has been specified).

        :raises UnicodeEncodeError:
            if unicode value cannot be encoded using default encoding.

        :raises ValueError:
            if resulting byte string contains a forbidden character,
            or is too long (>255 bytes).

        :returns:
            encoded identifer as bytes
        is%%s must be at most 255 characters: %rcss|]}|tkVqdS(N(t_INVALID_FIELD_CHARS(t.0tc((s2/usr/lib/python2.7/site-packages/passlib/apache.pys	<genexpr>ss"%s contains invalid characters: %r(	t
isinstanceRtencodeR$tbytesRtlenR#tany(RR5tparam((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRhjscCs<t|tstd|jr4|j|jS|SdS(sWdecode field from internal representation to format
        returns by users() method, etc.

        :raises UnicodeDecodeError:
            if unicode value cannot be decoded using default encoding.
            (usually indicates wrong encoding set for file).

        :returns:
            field as unicode or bytes, as appropriate.
        sexpected value to be bytesN(RpRrRaR%tdecodeR$(RR5((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt
_decode_fields	N(&R1t
__module__t__doc__R=R$R%R'R(R"R&R*R+tclassmethodRRR)RR.R4tpropertyRtsetterR6R:RRR?RCRYR[RZR_R^RbRiRkRhRw(((s2/usr/lib/python2.7/site-packages/passlib/apache.pyR,s>"			$		*								cCsd}x-ddgD]}tj|r|}PqqWtjdrKdnd}tj|stjdddddgntd|pdd	dd|p|pdd
|pdd|pddd}|jd|dd|d|S(Ntbcrypttsha256_crypttportable_apache_24thost_apache_24tlinux_apache_24tportablethostt
apr_md5_crypttportable_apache_22thost_apache_22tlinux_apache_22(R=Rthas_os_crypt_supportthas_backendt_warn_no_bcrypttcleartupdateR@(t	host_bestR<R}tdefaults((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt_init_default_schemess*
		
cCsrdddddddg}|jtj|d dg|}tt|d	|j}t|d
tdS(NR}R~tsha512_cryptt	des_cryptRt	ldap_sha1t	plaintextiRUtdefaultR(textendRtget_supported_os_crypt_schemestsortedR`tindexRthtpasswd_defaults(tschemest	preferred((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt_init_htpasswd_contexts	cBseZdZddedZdZdZdZdZ	e
dddd	d
ddZd
ZdZ
e
dddd	d
ddZdZdZe
dddd	d
ddZRS(sclass for reading & writing Htpasswd files.

    The class constructor accepts the following arguments:

    :type path: filepath
    :param path:

        Specifies path to htpasswd file, use to implicitly load from and save to.

        This class has two modes of operation:

        1. It can be "bound" to a local file by passing a ``path`` to the class
           constructor. In this case it will load the contents of the file when
           created, and the :meth:`load` and :meth:`save` methods will automatically
           load from and save to that file if they are called without arguments.

        2. Alternately, it can exist as an independant object, in which case
           :meth:`load` and :meth:`save` will require an explicit path to be
           provided whenever they are called. As well, ``autosave`` behavior
           will not be available.

           This feature is new in Passlib 1.6, and is the default if no
           ``path`` value is provided to the constructor.

        This is also exposed as a readonly instance attribute.

    :type new: bool
    :param new:

        Normally, if *path* is specified, :class:`HtpasswdFile` will
        immediately load the contents of the file. However, when creating
        a new htpasswd file, applications can set ``new=True`` so that
        the existing file (if any) will not be loaded.

        .. versionadded:: 1.6
            This feature was previously enabled by setting ``autoload=False``.
            That alias has been deprecated, and will be removed in Passlib 1.8

    :type autosave: bool
    :param autosave:

        Normally, any changes made to an :class:`HtpasswdFile` instance
        will not be saved until :meth:`save` is explicitly called. However,
        if ``autosave=True`` is specified, any changes made will be
        saved to disk immediately (assuming *path* has been set).

        This is also exposed as a writeable instance attribute.

    :type encoding: str
    :param encoding:

        Optionally specify character encoding used to read/write file
        and hash passwords. Defaults to ``utf-8``, though ``latin-1``
        is the only other commonly encountered encoding.

        This is also exposed as a readonly instance attribute.

    :type default_scheme: str
    :param default_scheme:
        Optionally specify default scheme to use when encoding new passwords.

        This can be any of the schemes with builtin Apache support,
        OR natively supported by the host OS's :func:`crypt.crypt` function.

        * Builtin schemes include ``"bcrypt"`` (apache 2.4+), ``"apr_md5_crypt"`,
          and ``"des_crypt"``.

        * Schemes commonly supported by Unix hosts
          include ``"bcrypt"``, ``"sha256_crypt"``, and ``"des_crypt"``.

        In order to not have to sort out what you should use,
        passlib offers a number of aliases, that will resolve
        to the most appropriate scheme based on your needs:

        * ``"portable"``, ``"portable_apache_24"`` -- pick scheme that's portable across hosts
          running apache >= 2.4. **This will be the default as of Passlib 2.0**.

        * ``"portable_apache_22"`` -- pick scheme that's portable across hosts
          running apache >= 2.4. **This is the default up to Passlib 1.9**.

        * ``"host"``, ``"host_apache_24"`` -- pick strongest scheme supported by
           apache >= 2.4 and/or host OS.

        * ``"host_apache_22"`` -- pick strongest scheme supported by
           apache >= 2.2 and/or host OS.

        .. versionadded:: 1.6
            This keyword was previously named ``default``. That alias
            has been deprecated, and will be removed in Passlib 1.8.

        .. versionchanged:: 1.6.3

            Added support for ``"bcrypt"``, ``"sha256_crypt"``, and ``"portable"`` alias.

        .. versionchanged:: 1.7

            Added apache 2.4 semantics, and additional aliases.

    :type context: :class:`~passlib.context.CryptContext`
    :param context:
        :class:`!CryptContext` instance used to create
        and verify the hashes found in the htpasswd file.
        The default value is a pre-built context which supports all
        of the hashes officially allowed in an htpasswd file.

        This is also exposed as a readonly instance attribute.

        .. warning::

            This option may be used to add support for non-standard hash
            formats to an htpasswd file. However, the resulting file
            will probably not be usable by another application,
            and particularly not by Apache.

    :param autoload:
        Set to ``False`` to prevent the constructor from automatically
        loaded the file from disk.

        .. deprecated:: 1.6
            This has been replaced by the *new* keyword.
            Instead of setting ``autoload=False``, you should use
            ``new=True``. Support for this keyword will be removed
            in Passlib 1.8.

    :param default:
        Change the default algorithm used to hash new passwords.

        .. deprecated:: 1.6
            This has been renamed to *default_scheme* for clarity.
            Support for this alias will be removed in Passlib 1.8.

    Loading & Saving
    ================
    .. automethod:: load
    .. automethod:: load_if_changed
    .. automethod:: load_string
    .. automethod:: save
    .. automethod:: to_string

    Inspection
    ================
    .. automethod:: users
    .. automethod:: check_password
    .. automethod:: get_hash

    Modification
    ================
    .. automethod:: set_password
    .. automethod:: delete

    Alternate Constructors
    ======================
    .. automethod:: from_string

    Attributes
    ==========
    .. attribute:: path

        Path to local file that will be used as the default
        for all :meth:`load` and :meth:`save` operations.
        May be written to, initialized by the *path* constructor keyword.

    .. attribute:: autosave

        Writeable flag indicating whether changes will be automatically
        written to *path*.

    Errors
    ======
    :raises ValueError:
        All of the methods in this class will raise a :exc:`ValueError` if
        any user name contains a forbidden character (one of ``:\r\n\t\x00``),
        or is longer than 255 characters.
    cKsd|kr1tdtdd|jd}n|r|tkrZtd|tjntj||}|jd|}n||_	t
t|j||dS(NRs{``default`` is deprecated as of Passlib 1.6, and will be removed in Passlib 1.8, it has been renamed to ``default_scheem``.R isPHtpasswdFile: no bcrypt backends available, using fallback for default scheme %r(
RR!tpopRRtPasslibSecurityWarningRtgettcopytcontexttsuperRR.(RRtdefault_schemeRR((s2/usr/lib/python2.7/site-packages/passlib/apache.pyR.s

	cCs>|jjt}t|dkr:td|n|S(Nis/malformed htpasswd file (error reading line %d)(RMtsplitt_BCOLONRsR#(RRRWtresult((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRCs

cCstd||S(Ns%s:%s
(R(RRgthash((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRbscCs#g|jD]}|j|^q
S(s6
        Return list of all users in database
        (R*Rw(RRg((s2/usr/lib/python2.7/site-packages/passlib/apache.pytusersscCs"|jj|}|j||S(sSet password for user; adds user if needed.

        :returns:
            * ``True`` if existing user was updated.
            * ``False`` if user account was added.

        .. versionchanged:: 1.6
            This method was previously called ``update``, it was renamed
            to prevent ambiguity with the dictionary method.
            The old alias is deprecated, and will be removed in Passlib 1.8.
        (RRtset_hash(RRgtpasswordR((s2/usr/lib/python2.7/site-packages/passlib/apache.pytset_passwordst
deprecateds1.6tremoveds1.8treplacementRcCs|j||S(sset password for user(R(RRgR((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRscCs1y|j|j|SWntk
r,dSXdS(sReturn hash stored for user, or ``None`` if user not found.

        .. versionchanged:: 1.6
            This method was previously named ``find``, it was renamed
            for clarity. The old name is deprecated, and will be removed
            in Passlib 1.8.
        N(R*RitKeyErrorR=(RRg((s2/usr/lib/python2.7/site-packages/passlib/apache.pytget_hash	s
cCsYtr*t|tr*|j|j}n|j|}|j||}|j|S(s
        semi-private helper which allows writing a hash directly;
        adds user if needed.

        .. warning::
            does not (currently) do any validation of the hash string

        .. versionadded:: 1.7
        (RRptstrRqR$RiRYR[(RRgRRX((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRs
RcCs
|j|S(sreturn hash for user(R(RRg((s2/usr/lib/python2.7/site-packages/passlib/apache.pytfind(scCs:y|j|j|=Wntk
r+tSX|jtS(sDelete user's entry.

        :returns:
            * ``True`` if user deleted.
            * ``False`` if user not found.
        (R*RiRR"R[R)(RRg((s2/usr/lib/python2.7/site-packages/passlib/apache.pytdelete/s

cCs|j|}|jj|}|dkr1dSt|trU|j|j}n|jj	||\}}|r|dk	r||jkst
||j|<|jn|S(sM
        Verify password for specified user.
        If algorithm marked as deprecated by CryptContext, will automatically be re-hashed.

        :returns:
            * ``None`` if user not found.
            * ``False`` if user found, but password does not match.
            * ``True`` if user found and password matches.

        .. versionchanged:: 1.6
            This method was previously called ``verify``, it was renamed
            to prevent ambiguity with the :class:`!CryptContext` method.
            The old alias is deprecated, and will be removed in Passlib 1.8.
        N(RiR*RR=RpRRqR$Rtverify_and_updateRaR[(RRgRRtoktnew_hash((s2/usr/lib/python2.7/site-packages/passlib/apache.pytcheck_password=s

RcCs|j||S(sverify password for user(R(RRgR((s2/usr/lib/python2.7/site-packages/passlib/apache.pytverify\sN(R1RxRyR=thtpasswd_contextR.RCRbRRR
RRRRRRR(((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRs 					
			cBseZdZdZdddZdZdZdZdZ	dZ
dZddZde
d	Zed
ddd
dddZddZde
dZed
ddd
dddZddZdZde
dZed
ddd
dddZRS(sclass for reading & writing Htdigest files.

    The class constructor accepts the following arguments:

    :type path: filepath
    :param path:

        Specifies path to htdigest file, use to implicitly load from and save to.

        This class has two modes of operation:

        1. It can be "bound" to a local file by passing a ``path`` to the class
           constructor. In this case it will load the contents of the file when
           created, and the :meth:`load` and :meth:`save` methods will automatically
           load from and save to that file if they are called without arguments.

        2. Alternately, it can exist as an independant object, in which case
           :meth:`load` and :meth:`save` will require an explicit path to be
           provided whenever they are called. As well, ``autosave`` behavior
           will not be available.

           This feature is new in Passlib 1.6, and is the default if no
           ``path`` value is provided to the constructor.

        This is also exposed as a readonly instance attribute.

    :type default_realm: str
    :param default_realm:

        If ``default_realm`` is set, all the :class:`HtdigestFile`
        methods that require a realm will use this value if one is not
        provided explicitly. If unset, they will raise an error stating
        that an explicit realm is required.

        This is also exposed as a writeable instance attribute.

        .. versionadded:: 1.6

    :type new: bool
    :param new:

        Normally, if *path* is specified, :class:`HtdigestFile` will
        immediately load the contents of the file. However, when creating
        a new htpasswd file, applications can set ``new=True`` so that
        the existing file (if any) will not be loaded.

        .. versionadded:: 1.6
            This feature was previously enabled by setting ``autoload=False``.
            That alias has been deprecated, and will be removed in Passlib 1.8

    :type autosave: bool
    :param autosave:

        Normally, any changes made to an :class:`HtdigestFile` instance
        will not be saved until :meth:`save` is explicitly called. However,
        if ``autosave=True`` is specified, any changes made will be
        saved to disk immediately (assuming *path* has been set).

        This is also exposed as a writeable instance attribute.

    :type encoding: str
    :param encoding:

        Optionally specify character encoding used to read/write file
        and hash passwords. Defaults to ``utf-8``, though ``latin-1``
        is the only other commonly encountered encoding.

        This is also exposed as a readonly instance attribute.

    :param autoload:
        Set to ``False`` to prevent the constructor from automatically
        loaded the file from disk.

        .. deprecated:: 1.6
            This has been replaced by the *new* keyword.
            Instead of setting ``autoload=False``, you should use
            ``new=True``. Support for this keyword will be removed
            in Passlib 1.8.

    Loading & Saving
    ================
    .. automethod:: load
    .. automethod:: load_if_changed
    .. automethod:: load_string
    .. automethod:: save
    .. automethod:: to_string

    Inspection
    ==========
    .. automethod:: realms
    .. automethod:: users
    .. automethod:: check_password(user[, realm], password)
    .. automethod:: get_hash

    Modification
    ============
    .. automethod:: set_password(user[, realm], password)
    .. automethod:: delete
    .. automethod:: delete_realm

    Alternate Constructors
    ======================
    .. automethod:: from_string

    Attributes
    ==========
    .. attribute:: default_realm

        The default realm that will be used if one is not provided
        to methods that require it. By default this is ``None``,
        in which case an explicit realm must be provided for every
        method call. Can be written to.

    .. attribute:: path

        Path to local file that will be used as the default
        for all :meth:`load` and :meth:`save` operations.
        May be written to, initialized by the *path* constructor keyword.

    .. attribute:: autosave

        Writeable flag indicating whether changes will be automatically
        written to *path*.

    Errors
    ======
    :raises ValueError:
        All of the methods in this class will raise a :exc:`ValueError` if
        any user name or realm contains a forbidden character (one of ``:\r\n\t\x00``),
        or is longer than 255 characters.
    cKs&||_tt|j||dS(N(t
default_realmRRR.(RRRR((s2/usr/lib/python2.7/site-packages/passlib/apache.pyR.s	cCsY|jjt}t|dkr:td|n|\}}}||f|fS(Nis/malformed htdigest file (error reading line %d)(RMRRRsR#(RRRWRRgRjR((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRCs
cCs|\}}td|||S(Ns	%s:%s:%s
(R(RRURRgRj((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRb
scCs7|dkr3|j}|dkr3tdq3n|S(NsGyou must specify a realm explicitly, or set the default_realm attribute(R=RR(RRj((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt_require_realms
	cCs|j|}|j|dS(NRj(RRh(RRj((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRkscCs|j||j|fS(N(RiRk(RRgRj((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt_encode_keyscCs9td|jD}g|D]}|j|^q S(s%Return list of all realms in databasecss|]}|dVqdS(iN((RnRU((s2/usr/lib/python2.7/site-packages/passlib/apache.pys	<genexpr>#s(R`R*Rw(RtrealmsRj((s2/usr/lib/python2.7/site-packages/passlib/apache.pyR!scCsF|j|}g|jD])}|d|kr|j|d^qS(sReturn list of all users in specified realm.

        * uses ``self.default_realm`` if no realm explicitly provided.
        * returns empty list if realm not found.
        ii(RkR*Rw(RRjRU((s2/usr/lib/python2.7/site-packages/passlib/apache.pyR&scCs\|tkrd|}}n|j|}tj|||d|j}|j|||S(sSet password for user; adds user & realm if needed.

        If ``self.default_realm`` has been set, this may be called
        with the syntax ``set_password(user, password)``,
        otherwise it must be called with all three arguments:
        ``set_password(user, realm, password)``.

        :returns:
            * ``True`` if existing user was updated
            * ``False`` if user account added.
        R$N(t_UNSETR=RRRR$R(RRgRjRR((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRHs
Rs1.6Rs1.8RRcCs|j|||S(sset password for user(R(RRgRjR((s2/usr/lib/python2.7/site-packages/passlib/apache.pyR[scCsS|j||}|jj|}|dkr4dStrO|j|j}n|S(sReturn :class:`~passlib.hash.htdigest` hash stored for user.

        * uses ``self.default_realm`` if no realm explicitly provided.
        * returns ``None`` if user or realm not found.

        .. versionchanged:: 1.6
            This method was previously named ``find``, it was renamed
            for clarity. The old name is deprecated, and will be removed
            in Passlib 1.8.
        N(RR*RR=RRvR$(RRgRjRUR((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRascCsx|tkrd|}}ntrFt|trF|j|j}n|j||}|j||}|j	|S(s
        semi-private helper which allows writing a hash directly;
        adds user & realm if needed.

        If ``self.default_realm`` has been set, this may be called
        with the syntax ``set_hash(user, hash)``,
        otherwise it must be called with all three arguments:
        ``set_hash(user, realm, hash)``.

        .. warning::
            does not (currently) do any validation of the hash string

        .. versionadded:: 1.7
        N(
RR=RRpRRqR$RRYR[(RRgRjRRURX((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRts
RcCs|j||S(sreturn hash for user(R(RRgRj((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRscCsC|j||}y|j|=Wntk
r4tSX|jtS(sDelete user's entry for specified realm.

        if realm is not specified, uses ``self.default_realm``.

        :returns:
            * ``True`` if user deleted,
            * ``False`` if user not found in realm.
        (RR*RR"R[R)(RRgRjRU((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRs	

cCsm|j|}|j}g|D]}|d|kr|^q}x|D]
}||=qHW|jt|S(sDelete all users for specified realm.

        if realm is not specified, uses ``self.default_realm``.

        :returns: number of users deleted (0 if realm not found)
        i(RkR*R[Rs(RRjRPRUtkeys((s2/usr/lib/python2.7/site-packages/passlib/apache.pytdelete_realms	)

cCs|tkrd|}}n|j|}|j|}|jj||f}|dkrbdStj||||d|jS(sVerify password for specified user + realm.

        If ``self.default_realm`` has been set, this may be called
        with the syntax ``check_password(user, password)``,
        otherwise it must be called with all three arguments:
        ``check_password(user, realm, password)``.

        :returns:
            * ``None`` if user or realm not found.
            * ``False`` if user found, but password does not match.
            * ``True`` if user found and password matches.

        .. versionchanged:: 1.6
            This method was previously called ``verify``, it was renamed
            to prevent ambiguity with the :class:`!CryptContext` method.
            The old alias is deprecated, and will be removed in Passlib 1.8.
        R$N(	RR=RiRkR*RRRR$(RRgRjRR((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRsRcCs|j|||S(sverify password for user(R(RRgRjR((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRsN(R1RxRyR=RR.RCRbRRkRRRRRR
RRRRRRRR(((s2/usr/lib/python2.7/site-packages/passlib/apache.pyRis,
						"	(/Ryt
__future__Rtloggingt	getLoggerR1RHR8twarningsRtpasslibRRtpasslib.contextRtpasslib.excRtpasslib.hashRt
passlib.utilsRRR	tpasslib.utils.decorR
tpasslib.utils.compatRRR
Rt__all__tobjectRRRGRmRKRLRR`RRRRRRR(((s2/usr/lib/python2.7/site-packages/passlib/apache.pyt<module>s<"				(		%	b
Back to Directory File Manager