Skip to content

Commit bdc3e98

Browse files
authored
Merge pull request #41 from udzuki/feat-25-xapi-lti-alternatename
feat: LTI連携のログで機関のスコープをalternatenameから取得(xAPIステートメント変換)
2 parents eb79f50 + 21d804d commit bdc3e98

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

xapi_stmt_gen/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM node:12.22.0
22

3-
LABEL version="2.8.0"
3+
LABEL version="2.9.0"
44

55
WORKDIR /usr/local/src
66
RUN mkdir xapi_stmt_gen

xapi_stmt_gen/xapi_stmt_gen/generator.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3700,7 +3700,7 @@ module.exports = async function main() { // eslint-disable-line max-statements
37003700

37013701
// Retrieve all users
37023702
const users = await USER.findAll({
3703-
attributes: ['id', 'username'],
3703+
attributes: ['id', 'auth', 'username', 'alternatename'],
37043704
raw: true
37053705
}).catch(err => {
37063706
process.exitCode = 1;
@@ -3719,18 +3719,25 @@ module.exports = async function main() { // eslint-disable-line max-statements
37193719
let userAttrs = [];
37203720
let newEppns = [];
37213721
for (const user of users) {
3722+
// Use alternatename as username
3723+
// if authenticated using GakuNinLMS's LTI plugin
3724+
const username = (
3725+
(user.auth === 'lti' && config.LRS.ePPNScoped)
3726+
? user.alternatename
3727+
: user.username
3728+
);
37223729
const eppn = eppns.find((eppn) => {
3723-
if (eppn['username'] === user.username) {
3730+
if (eppn['username'] === username) {
37243731
return eppn;
37253732
}
37263733
});
37273734
if (eppn) {
37283735
userAttrs[user.id] = eppn;
37293736
} else {
3730-
const hash = crypto.createHash('sha256').update(user.username).digest('hex');
3731-
const scope = getScopeFromEppn(user.username);
3737+
const hash = crypto.createHash('sha256').update(username).digest('hex');
3738+
const scope = getScopeFromEppn(username);
37323739
userAttrs[user.id] = {
3733-
username: user.username, // may not be ePPN format
3740+
username: username, // may not be ePPN format
37343741
hash: hash,
37353742
scope: scope, // nullable
37363743
acl: scope ? scope.replace(/[.-]/g, '_') : null // used for RLS

0 commit comments

Comments
 (0)