Skip to content

Server no longer warns when accessing a URL out of scope #1148

Closed

Description

@jvherweg

Description

When you start the server with npm start -- -b http://example.com/ and go to http://localhost:3000/ you will get a 401: Not logged in error. Preferably you should get the error that we specifically made for this. I'm guessing that at some point the architecture changed so that the function that throws this error is not being called any more before checking authorization.

I'm thinking we might just want to check the URL against the baseUrl in the OriginalUrlExtractor so that this triggers for every incoming request. Check would be the same as https://github.com/solid/community-server/blob/5e0f2e1e9582de6f853f60428ca086bccdff178c/src/util/identifiers/BaseIdentifierStrategy.ts#L15-L18

Activity

  1. added
    🐛 bug
    on Feb 9, 2022
  2. self-assigned this
    on Apr 5, 2022
  3. wkerckho commented on Apr 6, 2022

    @wkerckho
    Contributor

    What is the expected behavior for this check when using subdomains? E.g. the test suite test\integration\Subdomains.test.ts fails when implementing a strict check on whether the request URL base matches the configured CSS baseUrl. I can extend the check to also allow subdomains of the configured baseUrl, but this could lead to the server failing to provide the expected warning in some scenarios (even with the check)

    How is the baseUrl supposed to be configured when using subdomains and how do you expect the OriginalUrlExtractor to deal with this for these type of out-of-scope warnings/errors?

  4. jvherweg commented on Apr 6, 2022

    @jvherweg
    MemberAuthor

    Good point. Adding a baseUrl to the class is actually not the solution but I didn't realize that with your previous question. What you need to do is what happens in the code linked above. To do that you need to pass an IdentifierStrategy as input parameter (instead of a baseUrl) and then call strategy.supportsIdentifier. To make your life easier, the identifier of the default strategy is urn:solid-server:default:IdentifierStrategy in the config. When starting up a server with a subdomain config a different a different strategy is used which solves your problem.

  5. wkerckho commented on Apr 6, 2022

    @wkerckho
    Contributor

    Oh right, the second part of the issue description also makes a lot more sense now (I thought you were referencing the type of error to throw). Thanks for the input!

  6. jvherweg commented on Apr 8, 2022

    @jvherweg
    MemberAuthor

    Fixed in #1257

  7. jvherweg commented on May 10, 2022

    @jvherweg
    MemberAuthor

    Reopening as I just discovered this fix does not work as intended. The OriginalUrlExtractor triggers before the accept headers are parsed, meaning that the thrown error will never be converted to HTML. Currently you will always get a plain text response when you trigger this error, even in the browser.

    The solution might be to split off the preference parsing from the rest of the RequestParser, or get those to the error handler in some other way as this is not the first time it is unfortunate those headers are only parsed later.

  8. jvherweg commented on Jun 1, 2022

    @jvherweg
    MemberAuthor

    Done in #1314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🐛 bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions