[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/core/ -> authentication_api.php (summary)

Authentication API

Copyright: Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
Copyright: Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
File Size: 860 lines (25 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 25 functions

  auth_ensure_user_authenticated()
  auth_is_user_authenticated()
  auth_prepare_username()
  auth_prepare_password()
  auth_attempt_login()
  auth_attempt_script_login()
  auth_logout()
  auth_automatic_logon_bypass_form()
  auth_does_password_match()
  auth_process_plain_password()
  auth_generate_random_password()
  auth_generate_confirm_hash()
  auth_set_cookies()
  auth_clear_cookies()
  auth_generate_unique_cookie_string()
  auth_is_cookie_string_unique()
  auth_get_current_user_cookie()
  auth_set_tokens()
  auth_reauthenticate()
  auth_reauthenticate_page()
  auth_is_cookie_valid()
  auth_get_current_user_id()
  auth_http_prompt()
  auth_http_set_logout_pending()
  auth_http_is_logout_pending()

Functions
Functions that are not part of a class:

auth_ensure_user_authenticated( $p_return_page = '' )   X-Ref
Check that there is a user logged-in and authenticated
If the user's account is disabled they will be logged out
If there is no user logged in, redirect to the login page
If parameter is given it is used as a URL to redirect to following
successful login.  If none is given, the URL of the current page is used

param: string $p_return_page Page to redirect to following successful logon, defaults to current page

auth_is_user_authenticated()   X-Ref
Return true if there is a currently logged in and authenticated user, false otherwise

param: boolean auto-login anonymous user
return: bool

auth_prepare_username( $p_username )   X-Ref
prepare/override the username provided from logon form (if necessary)

param: string $p_username
return: string prepared username

auth_prepare_password( $p_password )   X-Ref
prepare/override the password provided from logon form (if necessary)

param: string $p_password
return: string prepared password

auth_attempt_login( $p_username, $p_password, $p_perm_login = false )   X-Ref
Attempt to login the user with the given password
If the user fails validation, false is returned
If the user passes validation, the cookies are set and
true is returned.  If $p_perm_login is true, the long-term
cookie is created.

param: string $p_username a prepared username
param: string $p_password a prepared password
param: bool $p_perm_login whether to create a long-term cookie
return: bool indicates if authentication was successful

auth_attempt_script_login( $p_username, $p_password = null )   X-Ref
Allows scripts to login using a login name or ( login name + password )

param: string $p_username username
param: string $p_password username
return: bool indicates if authentication was successful

auth_logout()   X-Ref
Logout the current user and remove any remaining cookies from their browser
Returns true on success, false otherwise


auth_automatic_logon_bypass_form()   X-Ref
Identicates whether to bypass logon form e.g. when using http auth

return: bool

auth_does_password_match( $p_user_id, $p_test_password )   X-Ref
Return true if the password for the user id given matches the given
password (taking into account the global login method)

param: int $p_user_id User id to check password against
param: string $p_test_password Password
return: bool indicating whether password matches given the user id

auth_process_plain_password( $p_password, $p_salt = null, $p_method = null )   X-Ref
Encrypt and return the plain password given, as appropriate for the current
global login method.

When generating a new password, no salt should be passed in.
When encrypting a password to compare to a stored password, the stored
password should be passed in as salt.  If the auth method is CRYPT then
crypt() will extract the appropriate portion of the stored password as its salt

param: string $p_password
param: string $p_salt salt, defaults to null
param: string $p_method logon method, defaults to null (use config login method)
return: string processed password, maximum PASSLEN chars in length

auth_generate_random_password( $p_email )   X-Ref
Generate a random 16 character password.

param: string $p_email unused
return: string 16 character random password

auth_generate_confirm_hash( $p_user_id )   X-Ref
Generate a confirmation code to validate password reset requests.

param: int $p_user_id User ID to generate a confirmation code for
return: string Confirmation code (384bit) encoded according to the base64 with URI safe alphabet approach described in RFC4648

auth_set_cookies( $p_user_id, $p_perm_login = false )   X-Ref
Set login cookies for the user
If $p_perm_login is true, a long-term cookie is created

param: int $p_user_id user id
param: bool $p_perm_login indicates whether to generate a long-term cookie

auth_clear_cookies()   X-Ref
Clear login cookies, return true if they were cleared

return: bool indicating whether cookies were cleared

auth_generate_unique_cookie_string()   X-Ref
Generate a random and unique string to use as the identifier for the login
cookie.

return: string Random and unique 384bit cookie string of encoded according to the base64 with URI safe alphabet approach described in RFC4648

auth_is_cookie_string_unique( $p_cookie_string )   X-Ref
Return true if the cookie login identifier is unique, false otherwise

param: string $p_cookie_string
return: bool indicating whether cookie string is unique

auth_get_current_user_cookie( $p_login_anonymous=true )   X-Ref
Return the current user login cookie string,
note that the cookie cached by a script login superceeds the cookie provided by
the browser. This shouldn't normally matter, except that the password verification uses
this routine to bypass the normal authentication, and can get confused when a normal user
logs in, then runs the verify script. the act of fetching config variables may get the wrong
userid.
if no user is logged in and anonymous login is enabled, returns cookie for anonymous user
otherwise returns '' (an empty string)

param: boolean auto-login anonymous user
return: string current user login cookie string

auth_set_tokens( $p_user_id )   X-Ref
Set authentication tokens for secure session.

param: integer User ID

auth_reauthenticate()   X-Ref
Check for authentication tokens, and display re-authentication page if needed.
Currently, if using BASIC or HTTP authentication methods, or if logged in anonymously,
this function will always "authenticate" the user (do nothing).

return: bool

auth_reauthenticate_page( $p_user_id, $p_username )   X-Ref
Generate the intermediate authentication page.

param: integer User ID
param: string Username
return: bool

auth_is_cookie_valid( $p_cookie_string )   X-Ref
is cookie valid?

param: string $p_cookie_string
return: bool

auth_get_current_user_id()   X-Ref
Retrieve user id of current user

return: int user id

auth_http_prompt()   X-Ref


auth_http_set_logout_pending( $p_pending )   X-Ref

param: bool $p_pending

auth_http_is_logout_pending()   X-Ref

return: bool



Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7