[ Index ]
 

Code source de DokuWiki 2006-11-06

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/inc/ -> auth.php (sommaire)

Authentication library Including this file will automatically try to login a user by calling auth_login()

Author: Andreas Gohr <andi@splitbrain.org>
License: GPL 2 (http://www.gnu.org/licenses/gpl.html)
Poids: 810 lignes (23 kb)
Inclus ou requis: 7 fois
Référencé: 0 fois
Nécessite: 5 fichiers
 inc/auth/basic.class.php
 inc/mail.php
 inc/blowfish.php
 inc/io.php
 inc/common.php

Définit 15 fonctions

  auth_login()
  auth_browseruid()
  auth_cookiesalt()
  auth_logoff()
  auth_quickaclcheck()
  auth_aclcheck()
  auth_nameencode()
  auth_pwgen()
  auth_sendPassword()
  register()
  updateprofile()
  act_resendpwd()
  isvalidemail()
  auth_cryptPassword()
  auth_verifyPassword()

Fonctions
Fonctions qui ne font pas partie d'une Classe:

auth_login($user,$pass,$sticky=false)   X-Ref
This tries to login the user based on the sent auth credentials

The authentication works like this: if a username was given
a new login is assumed and user/password are checked. If they
are correct the password is encrypted with blowfish and stored
together with the username in a cookie - the same info is stored
in the session, too. Additonally a browserID is stored in the
session.

If no username was given the cookie is checked: if the username,
crypted password and browserID match between session and cookie
no further testing is done and the user is accepted

If a cookie was found but no session info was availabe the
blowfish encrypted password from the cookie is decrypted and
together with username rechecked by calling this function again.

On a successful login $_SERVER[REMOTE_USER] and $USERINFO
are set.

author: Andreas Gohr <andi@splitbrain.org>
param: string  $user    Username
param: string  $pass    Cleartext Password
param: bool    $sticky  Cookie should not expire
return: bool             true on successful auth

auth_browseruid()   X-Ref
Builds a pseudo UID from browser and IP data

This is neither unique nor unfakable - still it adds some
security. Using the first part of the IP makes sure
proxy farms like AOLs are stil okay.

author: Andreas Gohr <andi@splitbrain.org>
return: string  a MD5 sum of various browser headers

auth_cookiesalt()   X-Ref
Creates a random key to encrypt the password in cookies

This function tries to read the password for encrypting
cookies from $conf['metadir'].'/_htcookiesalt'
if no such file is found a random key is created and
and stored in this file.

author: Andreas Gohr <andi@splitbrain.org>
return: string

auth_logoff()   X-Ref
This clears all authenticationdata and thus log the user
off

author: Andreas Gohr <andi@splitbrain.org>

auth_quickaclcheck($id)   X-Ref
Convinience function for auth_aclcheck()

This checks the permissions for the current user

author: Andreas Gohr <andi@splitbrain.org>
param: string  $id  page ID
return: int          permission level

auth_aclcheck($id,$user,$groups)   X-Ref
Returns the maximum rights a user has for
the given ID or its namespace

author: Andreas Gohr <andi@splitbrain.org>
param: string  $id     page ID
param: string  $user   Username
param: array   $groups Array of groups the user is in
return: int             permission level

auth_nameencode($name,$skip_group=false)   X-Ref
Encode ASCII special chars

Some auth backends allow special chars in their user and groupnames
The special chars are encoded with this function. Only ASCII chars
are encoded UTF-8 multibyte are left as is (different from usual
urlencoding!).

Decoding can be done with rawurldecode

author: Andreas Gohr <gohr@cosmocode.de>

auth_pwgen()   X-Ref
Create a pronouncable password

author: Andreas Gohr <andi@splitbrain.org>
return: string  pronouncable password

auth_sendPassword($user,$password)   X-Ref
Sends a password to the given user

author: Andreas Gohr <andi@splitbrain.org>
return: bool  true on success

register()   X-Ref
Register a new user

This registers a new user - Data is read directly from $_POST

author: Andreas Gohr <andi@splitbrain.org>
return: bool  true on success, false on any error

updateprofile()   X-Ref
Update user profile

author: Christopher Smith <chris@jalakai.co.uk>

act_resendpwd()   X-Ref
Send a  new password

This function handles both phases of the password reset:

- handling the first request of password reset
- validating the password reset auth token

author: Benoit Chesneau <benoit@bchesneau.info>
author: Chris Smith <chris@jalakai.co.uk>
author: Andreas Gohr <andi@splitbrain.org>
return: bool true on success, false on any error

isvalidemail($email)   X-Ref
Uses a regular expresion to check if a given mail address is valid

May not be completly RFC conform!

param: string $email the address to check
return: bool          true if address is valid

auth_cryptPassword($clear,$method='',$salt='')   X-Ref
Encrypts a password using the given method and salt

If the selected method needs a salt and none was given, a random one
is chosen.

The following methods are understood:

smd5  - Salted MD5 hashing
md5   - Simple MD5 hashing
sha1  - SHA1 hashing
ssha  - Salted SHA1 hashing
crypt - Unix crypt
mysql - MySQL password (old method)
my411 - MySQL 4.1.1 password

author: Andreas Gohr <andi@splitbrain.org>
return: string  The crypted password

auth_verifyPassword($clear,$crypt)   X-Ref
Verifies a cleartext password against a crypted hash

The method and salt used for the crypted hash is determined automatically
then the clear text password is crypted using the same method. If both hashs
match true is is returned else false

author: Andreas Gohr <andi@splitbrain.org>
return: bool



Généré le : Tue Apr 3 20:47:31 2007 par Balluche grâce à PHPXref 0.7