VuFind API Documentation

MultiILS extends ILS
in package

Multiple ILS authentication module that works with MultiBackend driver

Tags
category

VuFind

author

Franck Borel franck.borel@gbv.de

author

Demian Katz demian.katz@villanova.edu

author

Ere Maijala ere.maijala@helsinki.fi

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Table of Contents

$authenticator  : ILSAuthenticator
$catalog  : Connection
Catalog connection
$config  : Config
Configuration settings
$configValidated  : bool
Has the configuration been validated?
$dbServiceManager  : PluginManager
Database service plugin manager
$emailAuthenticator  : EmailAuthenticator|null
$translator  : TranslatorInterface
Translator
$userSetterMap  : mixed
Map of database column name to setter method for UserEntityInterface objects.
__construct()  : mixed
Constructor
authenticate()  : UserEntityInterface
Attempt to authenticate the current user. Throws exception if login fails.
create()  : UserEntityInterface
Create a new user account from the request.
getCatalog()  : Connection
Get the ILS driver associated with this object (or load the default from the service manager.
getConfig()  : Config
Get configuration (load automatically if not previously set). Throw an exception if the configuration is invalid.
getDbService()  : T
Get a database service object.
getDbServiceManager()  : PluginManager
Get the service plugin manager. Throw an exception if it is missing.
getDefaultLoginTarget()  : array<string|int, mixed>
Get default login target (ILS driver/source ID)
getDelegateAuthMethod()  : string|bool
Returns any authentication method this request should be delegated to.
getILSLoginMethod()  : string
What login method does the ILS use (password, email, vufind)
getLoginTargets()  : array<string|int, mixed>
Get login targets (ILS drivers/source ID's)
getPasswordPolicy()  : array<string|int, mixed>
Get password policy for a new password (e.g. minLength, maxLength)
getPolicyConfig()  : array<string|int, mixed>
Get a policy configuration
getSessionInitiator()  : bool|string
Get the URL to establish a session (needed when the internal VuFind login form is inadequate). Returns false when no session initiator is needed.
getTranslator()  : TranslatorInterface
Get translator object.
getTranslatorLocale()  : string
Get the locale from the translator.
getUsernamePolicy()  : array<string|int, mixed>
Get username policy for a new account (e.g. minLength, maxLength)
getUserService()  : UserServiceInterface
Get access to the user table.
isExpired()  : bool
Has the user's login expired?
logout()  : string
Perform cleanup at logout time.
needsCsrfCheck()  : bool
Whether this authentication method needs CSRF checking for the request.
preLoginCheck()  : void
Inspect the user's request prior to processing a login request; this is essentially an event hook which most auth modules can ignore. See ChoiceAuth for a use case example.
resetState()  : void
Reset any internal status; this is essentially an event hook which most auth modules can ignore. See ChoiceAuth for a use case example.
setCatalog()  : void
Set the ILS connection for this object.
setConfig()  : void
Set configuration.
setDbServiceManager()  : void
Set the service plugin manager.
setTranslator()  : TranslatorAwareInterface
Set a translator
supportsConnectingLibraryCard()  : bool
Does this authentication method support connecting library card of currently authenticated user?
supportsCreation()  : bool
Does this authentication method support account creation?
supportsPasswordChange()  : bool
Does this authentication method support password changing
supportsPasswordRecovery()  : bool
Does this authentication method support password recovery
translate()  : string
Translate a string (or string-castable object)
translateWithPrefix()  : string
Translate a string (or string-castable object) using a prefix, or without the prefix if a prefixed translation is not found.
updatePassword()  : UserEntityInterface
Update a user's password from the request.
validateCredentials()  : bool
Validate the credentials in the provided request, but do not change the state of the current logged-in user. Return true for valid credentials, false otherwise.
debug()  : void
Log a debug message.
extractTextDomain()  : array<string|int, mixed>
Given a translation string with or without a text domain, return an array with the raw string and the text domain separated.
getCannedPolicyHint()  : string|null
Return a canned username or password policy hint when available
getDebugTranslation()  : string
Build a debug-mode translation
getLoggedInPatron()  : array<string|int, mixed>|null
Get the Currently Logged-In Patron
getOrCreateUserByUsername()  : UserEntityInterface
Look up a user by username; create a new entity if no match is found.
getUsernameField()  : string
Gets the configured username field.
handleLogin()  : UserEntityInterface
Handle the actual login with the ILS.
log()  : void
Send a message to the logger.
logError()  : void
Log an error message.
logWarning()  : void
Log a warning message.
processILSUser()  : UserEntityInterface
Update the database using details from the ILS, then return the User object.
sanitizeTranslationKey()  : string
Make sure there are not any illegal characters in the translation key that might prevent successful lookup in language files.
setUserValueByField()  : void
Set a value in a UserEntityObject using a field name.
translateString()  : string
Get translation for a string
validateConfig()  : void
Validate configuration parameters. This is a support method for getConfig(), so the configuration MUST be accessed using $this->config; do not call $this->getConfig() from within this method!
validatePasswordAgainstPolicy()  : void
Verify that a password fulfills the password policy. Throws exception if the password is invalid.
validatePasswordUpdate()  : void
Make sure passwords match and fulfill ILS policy
validateStringAgainstPolicy()  : void
Verify that a username or password fulfills the given policy. Throws exception if the string is invalid.
validateUsernameAgainstPolicy()  : void
Verify that a username fulfills the username policy. Throws exception if the username is invalid.

Properties

$config

Configuration settings

protected Config $config = null

$configValidated

Has the configuration been validated?

protected bool $configValidated = false

$userSetterMap

Map of database column name to setter method for UserEntityInterface objects.

protected mixed $userSetterMap = ['cat_username' => 'setCatUsername', 'college' => 'setCollege', 'email' => 'setEmail', 'firstname' => 'setFirstname', 'lastname' => 'setLastname', 'home_library' => 'setHomeLibrary', 'major' => 'setMajor']

Methods

authenticate()

Attempt to authenticate the current user. Throws exception if login fails.

public authenticate(Request $request) : UserEntityInterface
Parameters
$request : Request

Request object containing account credentials.

Tags
throws
Auth
Return values
UserEntityInterface

Object representing logged-in user.

create()

Create a new user account from the request.

public create(Request $request) : UserEntityInterface
Parameters
$request : Request

Request object containing new account details.

Tags
throws
Auth
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
UserEntityInterface

New user entity.

getCatalog()

Get the ILS driver associated with this object (or load the default from the service manager.

public getCatalog() : Connection
Return values
Connection

getConfig()

Get configuration (load automatically if not previously set). Throw an exception if the configuration is invalid.

public getConfig() : Config
Tags
throws
Auth
Return values
Config

getDbService()

Get a database service object.

public getDbService(class-string<\VuFind\Db\Service\T> $name) : T
Parameters
$name : class-string<\VuFind\Db\Service\T>

Name of service to retrieve

Tags
template

T

Return values
T

getDefaultLoginTarget()

Get default login target (ILS driver/source ID)

public getDefaultLoginTarget() : array<string|int, mixed>
Return values
array<string|int, mixed>

getDelegateAuthMethod()

Returns any authentication method this request should be delegated to.

public getDelegateAuthMethod(Request $request) : string|bool
Parameters
$request : Request

Request object.

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
string|bool

getILSLoginMethod()

What login method does the ILS use (password, email, vufind)

public getILSLoginMethod([string $target = '' ]) : string
Parameters
$target : string = ''

Login target (MultiILS only)

Return values
string

getLoginTargets()

Get login targets (ILS drivers/source ID's)

public getLoginTargets() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPasswordPolicy()

Get password policy for a new password (e.g. minLength, maxLength)

public getPasswordPolicy() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPolicyConfig()

Get a policy configuration

public getPolicyConfig(string $type) : array<string|int, mixed>
Parameters
$type : string

Policy type (password or username)

Return values
array<string|int, mixed>

getSessionInitiator()

Get the URL to establish a session (needed when the internal VuFind login form is inadequate). Returns false when no session initiator is needed.

public getSessionInitiator(string $target) : bool|string
Parameters
$target : string

Full URL where external authentication method should send user after login (some drivers may override this).

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
bool|string

getTranslator()

Get translator object.

public getTranslator() : TranslatorInterface
Return values
TranslatorInterface

getTranslatorLocale()

Get the locale from the translator.

public getTranslatorLocale([string $default = 'en' ]) : string
Parameters
$default : string = 'en'

Default to use if translator absent.

Return values
string

getUsernamePolicy()

Get username policy for a new account (e.g. minLength, maxLength)

public getUsernamePolicy() : array<string|int, mixed>
Return values
array<string|int, mixed>

isExpired()

Has the user's login expired?

public isExpired() : bool
Return values
bool

logout()

Perform cleanup at logout time.

public logout(string $url) : string
Parameters
$url : string

URL to redirect user to after logging out.

Return values
string

Redirect URL (usually same as $url, but modified in some authentication modules).

needsCsrfCheck()

Whether this authentication method needs CSRF checking for the request.

public needsCsrfCheck(Request $request) : bool
Parameters
$request : Request

Request object.

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
bool

preLoginCheck()

Inspect the user's request prior to processing a login request; this is essentially an event hook which most auth modules can ignore. See ChoiceAuth for a use case example.

public preLoginCheck(Request $request) : void
Parameters
$request : Request

Request object.

Tags
throws
Auth
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
void

resetState()

Reset any internal status; this is essentially an event hook which most auth modules can ignore. See ChoiceAuth for a use case example.

public resetState() : void
Return values
void

setCatalog()

Set the ILS connection for this object.

public setCatalog(Connection $connection) : void
Parameters
$connection : Connection

ILS connection to set

Return values
void

setConfig()

Set configuration.

public setConfig(Config $config) : void
Parameters
$config : Config

Configuration to set

Return values
void

supportsConnectingLibraryCard()

Does this authentication method support connecting library card of currently authenticated user?

public supportsConnectingLibraryCard() : bool
Return values
bool

supportsCreation()

Does this authentication method support account creation?

public supportsCreation() : bool
Return values
bool

supportsPasswordChange()

Does this authentication method support password changing

public supportsPasswordChange() : bool
Return values
bool

supportsPasswordRecovery()

Does this authentication method support password recovery

public supportsPasswordRecovery() : bool
Return values
bool

translate()

Translate a string (or string-castable object)

public translate(string|object|array<string|int, mixed> $target[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, bool $useIcuFormatter = false ][, array<string|int, string> $fallbackDomains = [] ]) : string
Parameters
$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

$fallbackDomains : array<string|int, string> = []

Text domains to check if no match is found in the domain specified in $target

Return values
string

translateWithPrefix()

Translate a string (or string-castable object) using a prefix, or without the prefix if a prefixed translation is not found.

public translateWithPrefix(string $prefix, string|object|array<string|int, mixed> $target[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, bool $useIcuFormatter = false ][, array<string|int, string> $fallbackDomains = [] ]) : string
Parameters
$prefix : string

Translation key prefix

$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

$fallbackDomains : array<string|int, string> = []

Text domains to check if no match is found in the domain specified in $target

Return values
string

updatePassword()

Update a user's password from the request.

public updatePassword(Request $request) : UserEntityInterface
Parameters
$request : Request

Request object containing new account details.

Tags
throws
Auth
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
UserEntityInterface

Updated user entity.

validateCredentials()

Validate the credentials in the provided request, but do not change the state of the current logged-in user. Return true for valid credentials, false otherwise.

public validateCredentials(Request $request) : bool
Parameters
$request : Request

Request object containing account credentials.

Tags
throws
Auth
Return values
bool

debug()

Log a debug message.

protected debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

extractTextDomain()

Given a translation string with or without a text domain, return an array with the raw string and the text domain separated.

protected extractTextDomain(string|object|array<string|int, mixed> $target) : array<string|int, mixed>
Parameters
$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

Return values
array<string|int, mixed>

getCannedPolicyHint()

Return a canned username or password policy hint when available

protected getCannedPolicyHint(string $type, string|null $pattern) : string|null
Parameters
$type : string

Policy type (password or username)

$pattern : string|null

Current policy pattern

Return values
string|null

getDebugTranslation()

Build a debug-mode translation

protected getDebugTranslation(string $domain, string $str, array<string|int, mixed> $tokens) : string
Parameters
$domain : string

Text domain

$str : string

String to translate

$tokens : array<string|int, mixed>

Tokens to inject into the translated string

Return values
string

getLoggedInPatron()

Get the Currently Logged-In Patron

protected getLoggedInPatron() : array<string|int, mixed>|null
Tags
throws
Auth
Return values
array<string|int, mixed>|null

Patron or null if no credentials exist

getOrCreateUserByUsername()

Look up a user by username; create a new entity if no match is found.

protected getOrCreateUserByUsername(string $username) : UserEntityInterface
Parameters
$username : string

Username

Tags
throws
Exception
Return values
UserEntityInterface

getUsernameField()

Gets the configured username field.

protected getUsernameField() : string
Return values
string

handleLogin()

Handle the actual login with the ILS.

protected handleLogin(string $username, string $password, string $loginMethod, bool $rememberMe) : UserEntityInterface
Parameters
$username : string

User name

$password : string

Password

$loginMethod : string

Login method

$rememberMe : bool

Whether to remember the login

Tags
throws
Auth
Return values
UserEntityInterface

Processed User object.

log()

Send a message to the logger.

protected log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
$level : string

Log level

$message : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = false

Prepend class name to message?

Return values
void

logError()

Log an error message.

protected logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

logWarning()

Log a warning message.

protected logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

processILSUser()

Update the database using details from the ILS, then return the User object.

protected processILSUser(array<string|int, mixed> $info) : UserEntityInterface
Parameters
$info : array<string|int, mixed>

User details returned by ILS driver.

Tags
throws
Auth
Return values
UserEntityInterface

Processed User object.

sanitizeTranslationKey()

Make sure there are not any illegal characters in the translation key that might prevent successful lookup in language files.

protected sanitizeTranslationKey(string $key) : string
Parameters
$key : string

Key to sanitize

Return values
string

Sanitized key

setUserValueByField()

Set a value in a UserEntityObject using a field name.

protected setUserValueByField(UserEntityInterface $user, string $field, mixed $value) : void
Parameters
$user : UserEntityInterface

User to update

$field : string

Field name being updated

$value : mixed

New value to set

Tags
throws
Exception
Return values
void

translateString()

Get translation for a string

protected translateString(string $rawStr[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, string $domain = 'default' ][, bool $useIcuFormatter = false ]) : string
Parameters
$rawStr : string

String to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$domain : string = 'default'

Text domain (omit for default)

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

Return values
string

validateConfig()

Validate configuration parameters. This is a support method for getConfig(), so the configuration MUST be accessed using $this->config; do not call $this->getConfig() from within this method!

protected validateConfig() : void
Tags
throws
Auth
Return values
void

validatePasswordAgainstPolicy()

Verify that a password fulfills the password policy. Throws exception if the password is invalid.

protected validatePasswordAgainstPolicy(string $password) : void
Parameters
$password : string

Password to verify

Tags
throws
Auth
Return values
void

validatePasswordUpdate()

Make sure passwords match and fulfill ILS policy

protected validatePasswordUpdate(array<string|int, mixed> $params) : void
Parameters
$params : array<string|int, mixed>

request parameters

Return values
void

validateStringAgainstPolicy()

Verify that a username or password fulfills the given policy. Throws exception if the string is invalid.

protected validateStringAgainstPolicy(string $type, array<string|int, mixed> $policy, string $string) : void
Parameters
$type : string

Policy type (password or username)

$policy : array<string|int, mixed>

Policy configuration

$string : string

String to verify

Tags
throws
Auth
Return values
void

validateUsernameAgainstPolicy()

Verify that a username fulfills the username policy. Throws exception if the username is invalid.

protected validateUsernameAgainstPolicy(string $username) : void
Parameters
$username : string

Password to verify

Tags
throws
Auth
Return values
void

Search results