ep_headerauth 1.1.48 → 1.1.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -31,7 +31,7 @@ jobs:
|
|
|
31
31
|
uses: actions/checkout@v6
|
|
32
32
|
with:
|
|
33
33
|
repository: ether/etherpad-lite
|
|
34
|
-
- uses: pnpm/action-setup@
|
|
34
|
+
- uses: pnpm/action-setup@v6
|
|
35
35
|
name: Install pnpm
|
|
36
36
|
with:
|
|
37
37
|
version: 10
|
|
@@ -59,12 +59,20 @@ jobs:
|
|
|
59
59
|
[ "${NEW_COMMITS}" -gt 0 ] || exit 0
|
|
60
60
|
git config user.name 'github-actions[bot]'
|
|
61
61
|
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
|
62
|
-
pnpm i
|
|
62
|
+
pnpm i --frozen-lockfile
|
|
63
63
|
# `pnpm version patch` bumps package.json, makes a commit, and creates
|
|
64
64
|
# a `v<new-version>` tag. Capture the new tag name from package.json
|
|
65
65
|
# rather than parsing pnpm's output, which has historically varied.
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
# Bump the patch component directly with Node. pnpm/action-setup@v6
|
|
67
|
+
# sometimes installs pnpm 11 pre-releases even when version: 10.x is
|
|
68
|
+
# requested (pnpm/action-setup#225); those pre-releases either skip
|
|
69
|
+
# the git commit/tag or reject --no-git-tag-version as unknown.
|
|
70
|
+
# Doing the bump in Node sidesteps both failure modes.
|
|
71
|
+
NEW_VERSION=$(node -e "const fs=require('fs');const p=require('./package.json');const v=p.version.split('.');v[2]=String(Number(v[2])+1);p.version=v.join('.');fs.writeFileSync('./package.json',JSON.stringify(p,null,2)+'\n');console.log(p.version);")
|
|
72
|
+
NEW_TAG="v${NEW_VERSION}"
|
|
73
|
+
git add package.json
|
|
74
|
+
git commit -m "${NEW_TAG}"
|
|
75
|
+
git tag -a "${NEW_TAG}" -m "${NEW_TAG}"
|
|
68
76
|
# CRITICAL: use --atomic so the branch update and the tag update
|
|
69
77
|
# succeed (or fail) as a single transaction on the server. The old
|
|
70
78
|
# `git push --follow-tags` was non-atomic per ref: if a concurrent
|
package/README.md
CHANGED
|
@@ -36,6 +36,23 @@ In your `settings.json`:
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
Install from the Etherpad admin UI (**Admin → Manage Plugins**,
|
|
42
|
+
search for `ep_headerauth` and click *Install*), or from the Etherpad
|
|
43
|
+
root directory:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
pnpm run plugins install ep_headerauth
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> ⚠️ Don't run `npm i` / `npm install` yourself from the Etherpad
|
|
50
|
+
> source tree — Etherpad tracks installed plugins through its own
|
|
51
|
+
> plugin-manager, and hand-editing `package.json` can leave the
|
|
52
|
+
> server unable to start.
|
|
53
|
+
|
|
54
|
+
After installing, restart Etherpad.
|
|
55
|
+
|
|
39
56
|
## Copyright and License
|
|
40
57
|
|
|
41
58
|
Copyright © 2020 Richard Hansen <rhansen@rhansen.org>
|
package/index.js
CHANGED
|
@@ -50,8 +50,9 @@ exports.authenticate = (hookName, {req}, cb) => {
|
|
|
50
50
|
return cb([true]);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
exports.handleMessage = async (hookName, {
|
|
53
|
+
exports.handleMessage = async (hookName, {socket, message}) => {
|
|
54
54
|
logger.debug('handleMessage');
|
|
55
|
+
const {session} = socket.client.request;
|
|
55
56
|
if (session.user == null) {
|
|
56
57
|
logger.debug('handleMessage: User info missing from session');
|
|
57
58
|
return;
|
|
@@ -76,7 +77,7 @@ exports.handleMessage = async (hookName, {client: {client: {request: {session}}}
|
|
|
76
77
|
return;
|
|
77
78
|
}
|
|
78
79
|
logger.debug(`handleMessage: getting author ID for token ${token}`);
|
|
79
|
-
const authorId = await authorManager.
|
|
80
|
+
const authorId = await authorManager.getAuthorId(token, session.user);
|
|
80
81
|
logger.debug(`handleMessage: Setting name for ${authorId} to ${displayname}`);
|
|
81
82
|
authorManager.setAuthorName(authorId, displayname);
|
|
82
83
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ep_headerauth",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.49",
|
|
4
4
|
"description": "Etherpad plugin to use a reverse proxy's HTTP headers for authentication.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"eslint": "^8.57.1",
|
|
28
|
-
"eslint-config-etherpad": "^4.0.
|
|
29
|
-
"typescript": "^6.0.
|
|
28
|
+
"eslint-config-etherpad": "^4.0.5",
|
|
29
|
+
"typescript": "^6.0.3"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"lint": "eslint .",
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert').strict;
|
|
4
|
+
const common = require('ep_etherpad-lite/tests/backend/common');
|
|
5
|
+
const authorManager = require('ep_etherpad-lite/node/db/AuthorManager');
|
|
6
|
+
|
|
7
|
+
// Require the plugin with the loadSettings hook already triggered so that the
|
|
8
|
+
// module's private `settings` reference is initialised.
|
|
9
|
+
const plugin = require('../../../..');
|
|
10
|
+
|
|
11
|
+
describe(__filename, function () {
|
|
12
|
+
before(async function () {
|
|
13
|
+
await common.init();
|
|
14
|
+
await new Promise((resolve, reject) => {
|
|
15
|
+
plugin.loadSettings(
|
|
16
|
+
'loadSettings', {settings: {trustProxy: true, users: {}}}, (err) => err ? reject(err) : resolve());
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const makeContext = (message) => ({
|
|
21
|
+
socket: {client: {request: {session: {user: {displayname: 'Alice'}}}}},
|
|
22
|
+
message,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('uses context.socket rather than context.client (regression for #60)', async function () {
|
|
26
|
+
// Calling with context.client would throw TypeError since we destructure
|
|
27
|
+
// the socket-shaped property. Supplying only `socket` must work.
|
|
28
|
+
await plugin.handleMessage('handleMessage',
|
|
29
|
+
makeContext({type: 'COLLABROOM', data: {type: 'USERINFO_UPDATE', userInfo: {name: 'x'}}}));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('calls getAuthorId (not deprecated getAuthor4Token) on CLIENT_READY (regression for #60)',
|
|
33
|
+
async function () {
|
|
34
|
+
const calls = {getAuthorId: 0, getAuthor4Token: 0, setAuthorName: []};
|
|
35
|
+
const origGetAuthorId = authorManager.getAuthorId;
|
|
36
|
+
const origGetAuthor4Token = authorManager.getAuthor4Token;
|
|
37
|
+
const origSetAuthorName = authorManager.setAuthorName;
|
|
38
|
+
authorManager.getAuthorId = async (token, user) => {
|
|
39
|
+
calls.getAuthorId++;
|
|
40
|
+
assert.equal(token, 'tk');
|
|
41
|
+
assert.deepEqual(user, {displayname: 'Alice'});
|
|
42
|
+
return 'a.123';
|
|
43
|
+
};
|
|
44
|
+
authorManager.getAuthor4Token = async () => { calls.getAuthor4Token++; return 'a.old'; };
|
|
45
|
+
authorManager.setAuthorName = (id, name) => { calls.setAuthorName.push([id, name]); };
|
|
46
|
+
try {
|
|
47
|
+
await plugin.handleMessage('handleMessage',
|
|
48
|
+
makeContext({type: 'CLIENT_READY', token: 'tk'}));
|
|
49
|
+
} finally {
|
|
50
|
+
authorManager.getAuthorId = origGetAuthorId;
|
|
51
|
+
authorManager.getAuthor4Token = origGetAuthor4Token;
|
|
52
|
+
authorManager.setAuthorName = origSetAuthorName;
|
|
53
|
+
}
|
|
54
|
+
assert.equal(calls.getAuthorId, 1);
|
|
55
|
+
assert.equal(calls.getAuthor4Token, 0);
|
|
56
|
+
assert.deepEqual(calls.setAuthorName, [['a.123', 'Alice']]);
|
|
57
|
+
});
|
|
58
|
+
});
|