Fix forbidden access to the logged endpoints after successful auth/restore.#260
Open
KLarpen wants to merge 1 commit intometarhia:masterfrom
Open
Fix forbidden access to the logged endpoints after successful auth/restore.#260KLarpen wants to merge 1 commit intometarhia:masterfrom
KLarpen wants to merge 1 commit intometarhia:masterfrom
Conversation
Problem: forbidden access to the logged endpoints after successful `auth/restore`. Closes: metarhia#238
Contributor
Author
|
Please review @tshemsedinov . The fix ready to be applied. Additionally I had tried to write test for checking the right session restoration behavior but didn't commit it. Because the test passes successfully even without fix code applied due to test environment didn't reach the problematic part of it. So there is no sense in committing the test that can't catch an issue this PR references. The test itself is possibly good candidate to review my approaches at the next call. Anyway this PR ready to land without this additional test. Not commited test case ({
name: 'Auth session test',
async run(t) {
const url = 'ws://127.0.0.1:8001/api';
const metacom = metarhia.metacom.Metacom.create(url);
await metacom.load('auth', 'example');
const initial = await metacom.api.auth.signin({
login: 'marcus',
password: 'marcus',
});
const { token } = initial;
await t.test('Start logged session', async () => {
node.assert.strictEqual(initial.status, 'logged');
node.assert.strictEqual(typeof token, 'string');
});
await t.test(`Call logged endpoint`, async () => {
const res = await metacom.api.example.wait({ delay: 1 });
node.assert.strictEqual(res, 'done');
});
const reloadedClient = metarhia.metacom.Metacom.create(url);
await reloadedClient.load('auth', 'example');
await t.test('Restore the session from token', async () => {
const restored = await reloadedClient.api.auth.restore({ token });
node.assert.strictEqual(restored.status, 'logged');
});
await t.test(`Recall logged endpoint`, async () => {
const res = await reloadedClient.api.example.wait({ delay: 1 });
node.assert.strictEqual(res, 'done');
});
},
}); |
tshemsedinov
approved these changes
Dec 28, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #238
npm t)npm run fmt)