LenAuth Features

Plugin opportunities and advantages as for Moodle administrator or its user

Operating principle / how LenAuth works

Configure additional users profile fields for more correct work of some social networks

It's better to describe OAuth-authorization operation principle in applications for your understanding, first of all. It's quite simple:

  1. Application registration in a corresponding social network
  2. Special keys receiving (hash lines like dfs78dgksnvm6s99s......)
  3. Special request formation with the usage of corresponding keys to the respective social network web service on OAuth protocol
  4. Token receiving and its validation
  5. Information receiving (response) from social network web service in a special form (name, surname, date of birth, id in a corresponding social network, gender, email, etc.)

LenAuth build requests and parse responses from web services, seems like everything is easy. But not to all of them. Some social networks web services rules prohibit email, family name return. Why, they are the once we identify whether a student has a profile in your Moodle base.

But! All web services return users id in social networks. Thus for more correct plugin work it is necessary to set conformities of the additional student profile fields with the corresponding LenAuth fields. It allows to write these ids to database, and identify user uniqueness with its help. Plugin does it automatically.

LenAuth Plugin installation and setting

Detailed steps of plugin installation on your Moodle

Requirements: correctly working Moodle 2.6.5+

Download link: LenAuth 1.2.4 (official Moodle repository)

Plugin upload by FTP

Download plugin from the official plugins Moodle repository. Load lenauth folder in FTP (for example, with the help of FileZilla program) in auth folder of your Moodle website.

FTP at Moodle

Plugin activation in Moodle

Moodle has wired-in check of new modules, so that when you load new plugin by FTP, the system will automatically ask you to activate it.

New plugin activation

Enabling in settings

In Administration widget choose Site administration → Plugins → Authentication → Manage authentication.

Enable LenAuth

Enabling in settings

This section presents the full list of all available authentication ways in Moodle, including LenAuth. It's disabled by default, but it should be enabled.

enabling LenAuth

Setting

After you enable the plugin in settings, it'll appear in your menu Site administration → Plugins → Authentication → LenAuth.

New plugin activation

Start LenAuth configuration

You can configure the plugin after its installation, activation and enabling. But first of all you have to create OAuth applications, it's written below how to do it.

Настройка

OAuth applications setting

Descriptions how to make applications

Facebook is the largest social network in the world, its daily audience is about 700 million users all over the world, and the total amount of users is 1.3 billion people. You should have Facebook account.

You should have Facebook account.

  1. Register as Facebook developer. This procedure is non-committal; this is the Facebook rule for OAuth-applications development. The developer console will be available after registration.
  2. Application platform (type) — choose Website
  3. In a pop-up fill in Display Name, Category (for example, Education), do not touch the rest, press Create App ID
Join the Facebook application for OAuth LenAuth
Type OAuth Facebook application website
Configuring OAuth-application

Buttons output on Moodle website

How to output ready buttons template on your Moodle website

You have to correct your current Moodle template to output links/buttons students will press for authorization.

How to know current Moodle template? For this you should move to ADMINISTRATION → Site administration → Appearance → Themes → Theme selector (or the theme name will be in the same menu in Theme selector). If you entered in Theme selector, the theme name in Information column will be shown.

For example, your current theme name is Clean (this is a basic theme in Moodle 2.7.2 base on CSS framework Bootstrap), then your working folder on Moodle FTP is /theme/clean(in case if current theme is clean)/layout. Working php-files of new websites output are Inside layout folder. Usually output files are called like this: frontpage.php, general.php, columns3.php, columns2.php, columns1.php

Insert code can be found in administration panel of plugin in styles table of Output settings in column Theme PHP-code. For example, for LenAuth smooth-w64-classic-circle buttons output template it's necessary to insert code in the right place:
<?php if ( file_exists( $CFG->dirroot . '/auth/lenauth/out.php' ) ) : include_once $CFG->dirroot . '/auth/lenauth/out.php'; echo auth_lenauth_out::getInstance()->lenauth_output('smooth-w64-classic-circle'); endif; ?>

Also you can output buttons via HTML-code. At LenAuth admin screen above PHP-code for theme click Static HTML, new window will open with static HTML-code. Notice that after change OAuth-application settings, you need to update static HTML-code in your theme.

ATTENTION! Some socials has different logos for Russian and International users, for example, Yandex and VK.com. By default is International logos. If you want Russian logos, you need to select Russian logos at settings.

Social buttons templates

Here all possible button types and its descriptions are shown

The plugin allows several buttons templates from just text links to beautiful buttons/links with logos of socials. You can see and test it at LenAuth admin screen in section «Output settings». In this table, for clarity, shown only two buttons/links: Facebook and Twitter. It styles in the table is as live style (margins, width).

Extended settings

All about unordinary plugin settings

«Main settings» section

  1. User prefix: Each student that has signed in through LenAuth has its own internal ID, also any Moodle user should have their username, in other words, login for entry. Prefix does user login as (Prefix)+(ID in LenAuth). This login is assigned to student during registration through LenAuth, he/she can change it later. We advise to keep the login prefix as lenauth_user_.
  2. Default country: Not all social networks OAuth-providers return user country of residence. Therefore, if most of your students represent a definite country, you can set this country by default, and it will be automatically set while student registration. He/she can always change it.
  3. International logos / Russian logos: some Russian services that has not only Russian users has an own international logos, for example, Yandex and VK.com (VKontakte)
  4. User can reset/change an internal password:This option is extremely important, as user do not set the password while registration by default and the system can admit the user only through LenAuth checking his data in Moodle database. Therefore, if you want to give users an opportunity to «get rid» of sign in ONLY with LenAuth, and to sign in with an ordinary sign in form with login and password, turn on this option.
  5. Moderate new users: new users will have to confirm their email and they will receive a Moodle system mail with the special link. Account will be activated as user click on the link.

«Buttons settings» section

In LenAuth administration panel each style has two button types: Facebook and Twitter — This is the example of button location and style (with spaces and location you configured). You can approximately assume how a definite button style will be looked like on your Moodle website.

  1. Buttons location: two options are available
    1. Inline: buttons will follow each other abreast
    2. Block: Buttons will be presented in a list under each other (sometimes on a whole width of the button area)
  2. Width (0 = auto): each button width (CSS-property width). Not for all button templates is available!;
  3. Margin top (px): margin-top of each button in pixels (CSS-property margin-top);
  4. Margin right (px): margin-right of each button in pixels (CSS-property margin-right);
  5. margin bottom (px): margin-bottom of each button in pixels (CSS-property margin-bottom);
  6. Margin left (px): margin-left of each button in pixels (CSS-property margin-left);

«Buttons area settings» section

Buttons area — is an invisible section/block (div) with css-class lenauth-buttons, where buttons are located. It's like a buttons «cover». It can have the same features as buttons have (margins and location).

  1. Area location: two options are available
    1. Inline: button area will have line feature that means that buttons will not spread on a whole parental area width
    2. Block: button area will be in an ordinary condition on the whole width of the parental area
  2. Width (0 = auto): buttons area width (CSS-property width);
  3. Margin top (px): margin-top of buttons area in pixels (CSS-property margin-top);
  4. Margin right (px): margin-right of buttons area in pixels (CSS-property margin-right);
  5. Margin bottom (px): margin-bottom of buttons area in pixels (CSS-property margin-bottom);
  6. Margin left (px): margin-left of buttons area in pixels (CSS-property margin-left);

Settings with the help of your theme additional CSS

All buttons have similar HTML-structure: «area-cover» (buttons area, usually it is div) with css-class lenauth-buttons. There is ul list inside it without css-classes and li list elements. There is a link a with its css-classes inside each list element. Different elements can be inside the link, it depends on the concrete buttons output style. Accordingly, HTML-structure has this type:

<div class="lenauth-buttons some-additional-classes-if-needed">
    <ul>
        <li>
            <a class="twitter-or-facebook-or-yahoo some-additional-classes-if-needed">some-content</a>
        </li>
        <li>
            <a class="twitter-or-facebook-or-yahoo some-additional-classes-if-needed">some-content</a>
        </li>
        .......
    </ul>
</div>

If you are not enough with those features that LenAuth settings offer, you can edit CSS of your current theme in Moodle. Don't forget that in some cases, probably, it'll be needed to use additional CSS-property !important.

Possible system errors description

Do not afraid of system errors, they can be and have their own descriptions and codes. The main thing is to understand what kind of error it is

Moodle as most similar system has its own «catching exceptions» system (errors system). Such errors can be as «native» (integrated in system and those that appear during working with the system directly without plugin), also as additional, that is Moodle developers foresee possible problems and, if they happen, warn about these errors. Error text appears in English.

Error textError description
Service not enabled in your LenAuth SettingsThis error is unlikely to happen. It can only occur only in a case if you try to press the entry button through some social network, but it is disabling in the settings, thus this button shouldn't be visible. The error will happen in a case if an advanced user forge link GET-parameters and login though it.
Unknown OAuth ProviderThis error is unlikely to happen. It can occur in a case if an advanced user edit link entry GET-parameters though LenAuth.
Can not get access for "access_token" or/and "expires" params after requestThis error can occur. It means that the system wasn't able to receive access token from web service it is trying to connect.
Someting wrong, maybe expiresIf such error occurs all settings should be checked and try to connect once more. If this error occurred please contact us via info@lms-service.org and attach detailed screen-shots of your actions, we'll try to make it out.
Native VK Error some text with description: some textThis error means about, for some reason, VK.com webservice returns an error. Check VK.com settings in LenAuth.
Mail.RU invalid OAuth settings. Check your Private Key and Secret KeyCheck your settings of Mail.Ru in LenAuth.
Mail.RU Unknown Error with code: 000Unknown error from Mail.Ru webservice with some code. Look at errors codes Mail.Ru for method users.getInfo
Your social account is not verifiedDuring registration this or that social network user have to confirm itself (receive verified status), web services return this parameter and if this status is absent LenAuth prohibit entry and give this error.
Empty Social UIDFor some reasons web service hasn't received internal user ID. Error is unlikely to happen.
Final request returns nothingRequest for user data obtaining has nothing returned. Check your social networks OAuth applications settings in LenAuth.
Could not get access to access token. Check your App SettingsOne more error due to the empty meaning access token reason. Check your settings.
Something wrong with usernames of LenAuth users. Limit of 20 queries is out. Check last mdl_user table of MoodleThis error is unlikely to happen. It protects advanced users, who can change username, to make a lot of system MySQL requests, 20 requests limit. Check table mdl_user in your DataBase.
Native Google errorNative Google error. Check settings. Try to go to APIs & auth → APIs of Google client and turn on Google+ API or try to go to APIs & auth → Credentials and click Reset secret to refresh CLIENT SECRET, but don't forget to update it at LenAuth.