Repository navigation
Making proper use of strictOrigins - #1118
Conversation
|
I realize the number of changes introduced in @kjetilk @RubenVerborgh @dmitrizagidulin let me know if you want me to ungroup the tests in that file, it should reduce the number of changes a lot. But it also makes it harder to get an overview of the tests =/ (which had already created some redundant tests) |
|
Could also move |
| const agentOrigin = this.agentOrigin ? rdf.sym(this.agentOrigin) : null | ||
| const trustedOrigins = this.trustedOrigins ? this.trustedOrigins.map(trustedOrigin => rdf.sym(trustedOrigin)) : null | ||
| const agentOrigin = this.strictOrigin && this.agentOrigin ? rdf.sym(this.agentOrigin) : null | ||
| const trustedOrigins = this.strictOrigin && this.trustedOrigins ? this.trustedOrigins.map(trustedOrigin => rdf.sym(trustedOrigin)) : null |
There was a problem hiding this comment.
We do this every time? That might get expensive.
There was a problem hiding this comment.
Are you thinking of the use of Array.prototype.map-method and/or the use of ternary operators?
| // (https://github.com/solid/node-solid-server/pull/835#issuecomment-426429003) | ||
| if (!argv.host.allowsSessionFor(userId, origin, trustedOrigins) && !isLogoutRequest(req)) { | ||
| // We only want to do this check if strictOrigin is set to false, since we trust WebACL to handle origins otherwise | ||
| // If we don't allow authentication with cookies we can't handle ACLs properly wrt trusted origins |
There was a problem hiding this comment.
That's not the right explanation. We can handle ACLs properly; with non-cookie auth mechanisms.
The full explanation is:
Authentication cookies are an optimization:
instead of going through the process of
fully validating authentication on every request,
we go through this process once,
and store its successful result in a cookie
that will be reused upon the next request.
However, that cookie can then be sent by any server,
even servers that have not gone through the proper authentication mechanism.
However, if trusted origins are enabled,
then any origin is allowed to take the shortcut route,
since malicious origins will be banned at the ACL checking phase.
There was a problem hiding this comment.
I'm having problem wrapping my head around the reasoning for this part of the code, so thank you for the explanation. I think it's a good explanation, so I added it to the PR, hope that's ok.
| if (originHost === userHost) return true | ||
| if (trustedOrigins.includes(origin)) return true | ||
| return false | ||
| return !!trustedOrigins.includes(origin) |
There was a problem hiding this comment.
which by default included the user's own domain?
There was a problem hiding this comment.
Apparently not, given the test: is this intended?
There was a problem hiding this comment.
I tried to reuse ldp.getTrustedOrigins, which includes the user's own domain if the server is a multiuser server.
I thought we could remove some redundant code, but maybe I should revert this change back, since others might not use ldp.getTrustedOrigins?
Closes #1106.
We had some faulty handling where we returned 403 even if the user wasn't authenticated. (This fixes #1117.) 1. I discovered some redundant tests in test/integration/authentication-oidc-test.js, and moved some tests into groups for better overview. This makes for a lot of changes, but I think it's worth it. 2. I duplicated authentication-oidc-test into authentication-oidc-with-strict-origins-turned-off-test to make sure we handle those permutations correctly as well. This required a lot of setup, which are all of the new files in this commit. 3. I tried to consolidate the use of getTrustedOrigins in create-app.js, which made a test obsolete
My previous explanation was wrong
|
I just discovered that some tests will fail if run by themselves, but succeed if run as part of running all tests in that file... An example of this is "ACL with WebID+OIDC over HTTP > Origin > user1 should be able to access test directory". This should actually fail, at least if I understand the logic correctly. I will try to commit a fix for this soon. |
|
Added two more commits that removes the need of ordering in tests running in I think these commits could've been extracted into a separate PR for clarity. Let me know if this is desired. |
This branch is dependent on https://github.com/solid/acl-check/tree/feature/trusted-app and should be merged after #1118. This should fix #1121
|
@RubenVerborgh I moved some code into the constructor of the ACLChecker, tests verifies it works nicely ^_^ I've fell a bit out of loop on this PR, were there more feedback you had that I should fix? |
kjetilk
left a comment
There was a problem hiding this comment.
OK, it looks good. What makes me uneasy is the very extensive changes to authentication-oidc-test.js, since a lot of lines have changed, it had very thorough review before this, so I was thinking that not much should change in there.
I suppose your tooling did many of those changes, @megoth , so perhaps it is just that, but it is hard for me to see what has actually changed there.
It was a deliberate choice, because the tests were badly grouped which made them very hard to read. But I can revert those changes and we could live with it instead of having this many changes. |
I'm all for cleaning up, but this ended up being a rather large change, and I find it hard to review. So, perhaps the grouping changes could be done in a separate PR? Would that be a lot of work at this point? |
I'm going to try to revert the big changes to authentication-oidc-test.js, so that you only have to review my added tests ^_^ |
And applying the new tests that were added additionally on the reverted file
This reverts commit 06c5b19.
Trying to limit the number of changes
|
@kjetilk I've reverted a bunch of unnecessary changes, most of the changes are now simply new files. Let me know if you want me to do more 😸 |
|
|
||
| it('should return a 403', () => { | ||
| expect(response).to.have.property('status', 403) | ||
| it('should return a 401', () => { |
There was a problem hiding this comment.
Not terribly important, but as per the comment above the test, I still think 403 is the correct status. How hard would it be to fix?
|
|
||
| it('should return a 403', () => { | ||
| expect(response).to.have.property('status', 403) | ||
| it('should return a 401', () => { |
There was a problem hiding this comment.
Again here I would prefer a 403, since it is good to fend off an attacker at once, but it is even less important than the previous comment, since it is most important to just deny them.
|
Two small comments inline, the rest looks good, thanks a lot. :-) Please feel free to submit a separate PR with the cleanup later! |
We had some faulty handling where we returned 403 even if the user wasn't authenticated. (This fixes #1117.)
Some notes