There are several reports in the forums about LTI authentication failing when the LTI source (the external LMS) is sending multi-byte UTF8 characters as part of the request parameters.
This is an issue with releases 2.13 and 2.14 and possibly with earlier releases which already had LTI support. It is not critically connected to the internationalization/localization project, as even regular "English only" WW sites may have student names which contain accented (or other special) characters which are encoded by multiple bytes in UTF8 which is used as the default encoding for the transfer of the form data, including the LTI authentication data.
The core issue
The issue is related to the fact the the Perl Net::OAuth module used to verify the LTI authentication process requires the input to be in "internal Perl character encoding" and not encoded as bytes in UTF8. See: https://metacpan.org/pod/release/KGRENNAN/Net-OAuth-0.28/lib/Net/OAuth.pm and in particular the section called I18N near the bottom which states:
Per the OAuth spec, when making the signature Net::OAuth first encodes parameters to UTF-8. This means that any parameters you pass to Net::OAuth, if they might be outside of ASCII character set, should be run through Encode::decode() (or an equivalent PerlIO layer) first to decode them to Perl's internal character structure.
Beta version of a fix is ready to be tested by people with a working WW-LMS LTI setup.
After looking into the issue, I have made a beta-version of a fix available.
- It applies
utf8::decode() to values in the %request_hash which match the same regexp as Net::OAuth uses to trigger the error message.
- The revised code is currently only via my personal repository in a feature branch. https://github.com/taniwallach/webwork2/tree/LTI-patch-multi-byte-characters
- Modified files (raw mode):
- Without access to a LTI system to test with, I cannot test this code.
- Once some people review and test the code, a hot-fix pull request can be made.
- The code is doubly protected to avoid damage to what currently works:
- The code will only run if a special variable is set to 1:
$allow_WW_LTI_code_to_fix_what_appear_as_multi_byte_characters and an explanation and a comment out line to do this were added to conf/authen_LTI.conf.dist in the feature branch.
- The code will only tamper with values which match the same regexp as Net::OAuth uses to trigger the error message, so is not expected to break any request data which currently can be verified.
Testing
Testing requires a course which allows LTI authentication, and connecting from an LMS properly configured to access the WeBWorK server via LTI.
- Setup: It should suffice to update the relevant one of:
lib/WeBWorK/Authen/LTIAdvanced.pm
lib/WeBWorK/Authen/LTIBasic.pm
- and to set
$allow_WW_LTI_code_to_fix_what_appear_as_multi_byte_characters=1 in conf/authen_LTI.conf (or in a course specific config file).
- Testing should be done with both LTI data which contains and which does not contain multi-byte characters. (The simplest test cases are probably student names with accented characters.)
- Desired outcome: successful authentication in all valid cases.
- Negative feedback on failed authentication with details would help debug this.
There are several reports in the forums about LTI authentication failing when the LTI source (the external LMS) is sending multi-byte UTF8 characters as part of the request parameters.
This is an issue with releases 2.13 and 2.14 and possibly with earlier releases which already had LTI support. It is not critically connected to the internationalization/localization project, as even regular "English only" WW sites may have student names which contain accented (or other special) characters which are encoded by multiple bytes in UTF8 which is used as the default encoding for the transfer of the form data, including the LTI authentication data.
The core issue
The issue is related to the fact the the Perl Net::OAuth module used to verify the LTI authentication process requires the input to be in "internal Perl character encoding" and not encoded as bytes in UTF8. See: https://metacpan.org/pod/release/KGRENNAN/Net-OAuth-0.28/lib/Net/OAuth.pm and in particular the section called
I18Nnear the bottom which states:Beta version of a fix is ready to be tested by people with a working WW-LMS LTI setup.
After looking into the issue, I have made a beta-version of a fix available.
utf8::decode()to values in the%request_hashwhich match the same regexp as Net::OAuth uses to trigger the error message.$allow_WW_LTI_code_to_fix_what_appear_as_multi_byte_charactersand an explanation and a comment out line to do this were added toconf/authen_LTI.conf.distin the feature branch.Testing
Testing requires a course which allows LTI authentication, and connecting from an LMS properly configured to access the WeBWorK server via LTI.
lib/WeBWorK/Authen/LTIAdvanced.pmlib/WeBWorK/Authen/LTIBasic.pm$allow_WW_LTI_code_to_fix_what_appear_as_multi_byte_characters=1inconf/authen_LTI.conf(or in a course specific config file).