TwoFactorAdminLogin

Extends\AuthPluginBase

Base class for plugins.

package

Default

Methods

Constructor for the plugin

__construct(\LimeSurvey\PluginManager\PluginManager $manager,integer $id)
inherited
todo

Add proper type hint in 3.0

Arguments

$manager

\LimeSurvey\PluginManager\PluginManager

The plugin manager instantiating the object

$id

integer

The id for storage

Set username and password by post request

afterLoginFormSubmit(): null
inherited

Response

null

If force 2FA login is enabled, redirect to the 2FA page

afterSuccessfulLogin(): void

Register new table and populate it.

beforeActivate(): void

Add menue to the top bar

beforeAdminMenuRender(): void

Delete the created tables again

beforeDeactivate(): void

Check if config field active is 1. If yes, activate the plugin.

checkActive(\Plugin $pluginModel): void
inherited

This is the 'active-by-default' feature.

Arguments

$pluginModel

\Plugin

Returns true if config file has a higher version than database.

configIsNewVersion(): boolean
inherited

Assumes $this->config is set.

Response

boolean

Checks a 2FA OTP authentication code against the stored secret

confirmKey(string $secretKey,string $authenticationCode): boolean

Arguments

$secretKey

string

$authenticationCode

string

Response

boolean

true on authentication code matching stored secret key

Generates a printed JSON-Response

createJSONResponse(boolean $success,string $message,array $data = array()): boolean

Arguments

$success

boolean

$message

string

$data

array

Response

boolean

$success

Deletes a users secret, effectively ending the 2FA login mechanism for that user CLI version.

deleteKeyForUserId(\PluginEvent $oEvent, $iUserId): string

Returns a String

Arguments

$oEvent

\PluginEvent

$iUserId

Response

string

Deletes a users secret, effectively ending the 2FA login mechanism for that user CLI version.

deleteKeyForUserName(\PluginEvent $oEvent, $sUserName): string

Returns a String

Arguments

$oEvent

\PluginEvent

$sUserName

Response

string

Event direct happen Usage : index --target=value [--function=] [--option=]

direct(): \@void

Response

\@void

Checks a submitted authentication code and stores the underlaying secret key into the Database.

directCallConfirmKey(\PluginEvent $oEvent,\CHttpRequest $oRequest): boolean

Returns a JSON document

Arguments

$oEvent

\PluginEvent

$oRequest

\CHttpRequest

Response

boolean

Renders the content of the modal to create a 2FA key registration

directCallCreateNewKey(\PluginEvent $oEvent,\CHttpRequest $oRequest): string

Arguments

$oEvent

\PluginEvent

$oRequest

\CHttpRequest

Response

string

Deletes a users secret, effectively ending the 2FA login mechanism for that user.

directCallDeleteKey(\PluginEvent $oEvent,\CHttpRequest $oRequest): boolean

Returns a JSON document

Arguments

$oEvent

\PluginEvent

$oRequest

\CHttpRequest

Response

boolean

This function retrieves plugin data. Do not cache this data; the plugin storage engine will handling caching. After the first call to this function, subsequent calls will only consist of a few function calls and array lookups.

get(string $key = null,string $model = null,integer $id = null,mixed $default = null): boolean
inherited

Arguments

$key

string

$model

string

$id

integer

$default

mixed

The default value to use when not was set

Response

boolean

Creates or returns a 2FA-library object Using Rob Janssen TwoFactorAuth - Library https://github.com/RobThree/TwoFactorAuth

get2FAObject(): \TwoFactorAuth

Response

\TwoFactorAuth

Return the description for this plugin

getDescription()
inheritedstatic

To find the plugin locale file, we need late runtime result of __DIR__.

getDir(): string|null
inherited

Get the current event this plugin is responding to

getEvent(): \LimeSurvey\PluginManager\PluginEvent
inherited

Returns the id of the plugin

getId(): integer
inherited

Used by storage model to find settings specific to this plugin

Response

integer

Gets the name for the plugin, this must be unique.

getName(): string
inheritedstatic

Response

string

Plugin name, max length: 20.

Get the password (if set)

getPassword(): string|null
inherited

Response

string|null

Provides meta data on the plugin settings that are available for this plugin.

getPluginSettings(boolean $getValues = true): array
inherited

This does not include enable / disable; a disabled plugin is never loaded.

Arguments

$getValues

boolean

Set to false to not get the current value for each plugin setting.

Response

array

Returns the plugin storage and takes care of instantiating it

getStore(): \LimeSurvey\PluginManager\iPluginStorage
inherited

Get the username (if set)

getUserName(): string|null
inherited

Response

string|null

Translation for plugin

gT(string $sToTranslate,string $sEscapeMode = 'html',string $sLanguage = null): string
inherited

Arguments

$sToTranslate

string

The message that are being translated

$sEscapeMode

string

$sLanguage

string

Response

string

Renders a list of users including their 2FA settings To be called by fullpagewrapper

index(): string

Response

string

init

init()

Call the Yii::log function to log into tmp/runtime/plugin.log The plugin name is the category.

log(string $message,string $level = \CLogger::LEVEL_TRACE): void
inherited

Arguments

$message

string

$level

string

From CLogger, defaults to CLogger::LEVEL_TRACE

Listen to direct requests Necessary for the getMetadata function

newDirectRequest(): void

Add Two-Factor field to login page.

newLoginForm(): void

Control if login is successful by checking the transmitted 2FA-token value

newUserSession(): void

Applies the necessary page scripts to the page through CClientScript derivate

pageScripts(): void

Publishes plugin assets.

publish( $fileName): string
inherited

Arguments

$fileName

Response

string

Read XML config file and store it in $this->config Assumes config file is config.xml and in plugin root folder.

readConfigFile(): boolean
inherited
todo

Could this be moved to plugin model?

Response

boolean

registerCss

registerCss(string $relativePathToCss,string $parentPlugin = null): void
inherited

Arguments

$relativePathToCss

string

$parentPlugin

string

registerScript

registerScript(string $relativePathToScript,string $parentPlugin = null): void
inherited

Arguments

$relativePathToScript

string

$parentPlugin

string

registerSetting

registerSetting(string $name,array $options = array('type' => 'string'))
inherited

Arguments

$name

string

Name of the setting. The type of the setting is either a basic type or choice. The choice type is either a single or a multiple choice setting.

$options

array

Contains parameters for the setting. The 'type' key contains the parameter type. The type is one of: string, int, float, choice. Supported keys per type: String: max-length(int), min-length(int), regex(string). Int: max(int), min(int). Float: max(float), min(float). Choice: choices(array containing values as keys and names as values), multiple(bool) Note that the values for choice will be translated.

Set username and password by event

remoteControlLogin(): null
inherited

Response

null

Look for views in plugin views/ folder and render it

renderPartial(string $viewfile,array $data,boolean $return = false,boolean $processOutput = false): \LimeSurvey\PluginManager\string;
inherited

Arguments

$viewfile

string

Filename of view in views/ folder

$data

array

$return

boolean

$processOutput

boolean

Response

\LimeSurvey\PluginManager\string;

Saves the new version from config into database

saveNewVersion(): boolean
inherited

Response

boolean

Saves the settings for this plugin

saveSettings( $settings): void
inherited

Assumes an array with valid key/value pairs is passed.

Arguments

$settings

This function stores plugin data.

set(string $key,mixed $data,string $model = null,integer $id = null): boolean
inherited

Arguments

$key

string

$data

mixed

$model

string

$id

integer

Response

boolean

Set authentication result to failure.

setAuthFailure(integer $code = self::ERROR_UNKNOWN_IDENTITY,string $message = ''): \LimeSurvey\PluginManager\AuthPluginBase
inherited

Arguments

$code

integer

Any of the constants defined in this class

$message

string

An optional message to return about the failure

Response

\LimeSurvey\PluginManager\AuthPluginBase

Set this plugin to handle the authentication

setAuthPlugin(): \LimeSurvey\PluginManager\AuthPluginBase
inherited

Set authentication result to success for the given user object.

setAuthSuccess(\User $user): \LimeSurvey\PluginManager\AuthPluginBase
inherited

Set the event to the plugin, this method is executed by the PluginManager just before dispatching the event.

setEvent(\LimeSurvey\PluginManager\PluginEvent $event): \LimeSurvey\PluginManager\PluginBase
inherited

We need a component for each plugin to load correct locale file.

setLocaleComponent(): void
inherited

Set the password to use for authentication

setPassword(string $password): \LimeSurvey\PluginManager\AuthPluginBase
inherited

Arguments

$password

string

Response

\LimeSurvey\PluginManager\AuthPluginBase

Set the username to use for authentication

setUsername(string $username): \LimeSurvey\PluginManager\AuthPluginBase
inherited

Arguments

$username

string

The username

Response

\LimeSurvey\PluginManager\AuthPluginBase

Show an error message about malformed config.json file.

showConfigErrorNotification(): void
inherited

This function subscribes the plugin to receive an event.

subscribe(string $event,string $function = null)
inherited

Arguments

$event

string

$function

string

This function unsubscribes the plugin from an event.

unsubscribe(string $event)
inherited

Arguments

$event

string

Renders the user configuration page To be called by fullpagewrapper

userindex(): string

Response

string

Constants

These constants reflect the error codes to be used by the identity, they are copied from LSUserIdentity and CBaseUserIdentity for easier access.

ERROR_NONE
inherited

ERROR_NOT_ADDED

ERROR_NOT_ADDED
inherited

ERROR_USERNAME_INVALID

ERROR_USERNAME_INVALID
inherited

ERROR_PASSWORD_INVALID

ERROR_PASSWORD_INVALID
inherited

ERROR_AUTH_METHOD_INVALID

ERROR_AUTH_METHOD_INVALID
inherited

ERROR_IP_LOCKED_OUT

ERROR_IP_LOCKED_OUT
inherited

ERROR_UNKNOWN_HANDLER

ERROR_UNKNOWN_HANDLER
inherited

ERROR_UNKNOWN_IDENTITY

ERROR_UNKNOWN_IDENTITY
inherited

ERROR_INVALID_EMAIL

ERROR_INVALID_EMAIL
inherited

ERROR_ALREADY_EXISTING_USER

ERROR_ALREADY_EXISTING_USER
inherited

ERROR_LDAP_CONNECTION

ERROR_LDAP_CONNECTION
inherited

ERROR_LDAP_MODE

ERROR_LDAP_MODE
inherited

ERROR_LDAP_NO_EMAIL

ERROR_LDAP_NO_EMAIL
inherited

ERROR_LDAP_NO_FULLNAME

ERROR_LDAP_NO_FULLNAME
inherited

ERROR_LDAP_NO_BIND

ERROR_LDAP_NO_BIND
inherited

ERROR_LDAP_NO_SEARCH_RESULT

ERROR_LDAP_NO_SEARCH_RESULT
inherited

LDAP_INVALID_PASSWORD_TEXT

LDAP_INVALID_PASSWORD_TEXT
inherited

Properties

description

description :string
inheritedstatic
var

Type(s)

string

name

name :string
inheritedstatic
var

Type(s)

string

o2FA

o2FA :

Type(s)

storage

storage :string
inherited
var

Type(s)

string

Global settings of plugin

settings :array<mixed,array>
inherited
var

Type(s)

array<mixed,array>

_username

_username :
inherited

Type(s)

_password

_password :
inherited

Type(s)

api

api :\LimeSurvey\PluginManager\LimesurveyApi
inherited

event

event :\LimeSurvey\PluginManager\PluginEvent
inherited

id

id :integer
inherited
var

Type(s)

integer

store

store :\LimeSurvey\PluginManager\?
inherited
var

Type(s)

\LimeSurvey\PluginManager\?

This holds the pluginmanager that instantiated the plugin

pluginManager :\LimeSurvey\PluginManager\PluginManager
inherited

config.xml

config :\SimpleXMLElement|null
inherited
todo

Use ExtensionConfig

var

Type(s)

\SimpleXMLElement|null

List of allowed public method, null mean all method are allowed.

allowedPublicMethods :array<mixed,string>|null
inherited

Else method must be in the list. Used in public controller :

  • PluginHelper::ajax (admin/pluginhelper&sa=ajax)
  • PluginHelper::fullpagewrapper (admin/pluginhelper&sa=fullpagewrapper)
  • PluginHelper::sidebody (admin/pluginhelper&sa=sidebody)
var

Type(s)

array<mixed,string>|null