nodeSolidServer / node-solid-server

Solid server on top of the file-system in NodeJS
https://solidproject.org/for-developers/pod-server
Other
1.78k stars 303 forks source link

Fix #1783 #1784

Closed zg009 closed 2 weeks ago

zg009 commented 6 months ago

This is the thread for addressing #1783

Current has some work to register hostname on server creation and apply it to AccountTemplate class as a static variable

Ran some tests with localhost webId resolution.

Integration tests probably need more granularity, also strategy to handle multiuser mapping due to prefix path rather than postfix.

zg009 commented 6 months ago

@jeff-zucker If you'd like to pull this branch and see if it fulfills your needs, let me know. I can fix issues as they appear or don't resolve properly, but this will serve as the starting point.

jeff-zucker commented 6 months ago

@jeff-zucker If you'd like to pull this branch and see if it fulfills your needs, let me know. I can fix issues as they appear or don't resolve properly, but this will serve as the starting point.

The code looks right. I'll download and test tomorrow. Thanks much!

bourgeoa commented 6 months ago

@zg009 Thanks. I think this is correct. You may make :

zg009 commented 6 months ago

@bourgeoa I addressed your first and second point. I need more clarity about what I need to check in the test suite.

bourgeoa commented 6 months ago

Your code works but I think (to be discussed) it does not respect the actual code logic (I did not create it nor help maintain this part)

I thin k your function should be implemented here https://github.com/nodeSolidServer/node-solid-server/blob/07ee53cc3857fa050232cc7723f7a7abd440dc13/lib/models/account-manager.js#L67

To avoid

zg009 commented 6 months ago

@bourgeoa Are you saying in the static from method, move the logic from current changes into the from method and set the 'host' variable in that way?

bourgeoa commented 6 months ago

Yes but I am not sure of me at all

bourgeoa commented 6 months ago

I was thinking that from was returning all data needed from input

zg009 commented 6 months ago

The only places I see AccountManager and AccountTemplate interacting is here https://github.com/nodeSolidServer/node-solid-server/blob/07ee53cc3857fa050232cc7723f7a7abd440dc13/lib/models/account-manager.js#L390-L402

If you trace AccountTemplate.for(), it is the only code which uses AccountTemplate.templateSubstitutionsFor().

I could modify the AccountTemplate.for method to take hostname from AccountManager object from AccountManager.createAccountFor.

EDIT: Actually, looking at the code further, the same end goal is reached. I do not have strong feelings about where to move the host server checking logic. It seems logical to pass hostname to AccountTemplate.for and change webId path based upon that.

bourgeoa commented 6 months ago

To improve cleaning the logic this should be moved : https://github.com/nodeSolidServer/node-solid-server/blob/18b7cb3c0b6506554365be66bcbd1771807d2946/lib/create-app.js#L56 inside function initWebId

And may be passed via accountManager with a new parameter argv.serverUri to the API.accounts.middleware()

app.use('/', API.accounts.middleware(accountManager))
bourgeoa commented 6 months ago

I wonder if there is a situation where there is any difference between registerHostname() and https://github.com/nodeSolidServer/node-solid-server/blob/18b7cb3c0b6506554365be66bcbd1771807d2946/lib/models/account-manager.js#L156

What do you think ? May be with external WebId ?

bourgeoa commented 6 months ago

I marked it as draft because it is not working. I think the logic is more complex between

The podUri is not stored in userAccount. May be look at rootAclUri

zg009 commented 6 months ago

Yeah, I figured this wouldn't be so simple. I'll have some time to take a deeper dive later this week or early June, I am busy with my current work right now.

bourgeoa commented 6 months ago

It is the first time I go in the logic of the account manager of NSS code. Anyway thanks for looking.

jeff-zucker commented 6 months ago

Yeah, I figured this wouldn't be so simple. I'll have some time to take a deeper dive later this week or early June, I am busy with my current work right now.

Thanks much for looking in to it. I do not see this as in any way high priority and can deal with it in other ways, so there is no rush on my account. And I can't think that's priority for others either.

bourgeoa commented 6 months ago

@jeff-zucker I agree it is not high priority. But when you get in, and thinks it is quite simple and don't find the code logic you somehow are frustrated.

@zg009 I think I resolved it. Thanks again for your help. Could you :

zg009 commented 6 months ago

@jeff-zucker I agree it is not high priority. But when you get in, and thinks it is quite simple and don't find the code logic you somehow are frustrated.

@zg009 I think I resolved it. Thanks again for your help. Could you :

  • replace failing tests and add any needed ones
  • /profile/card#me should use predefined constants

You will need to clarify what predefined constants I should be using for these tests.

bourgeoa commented 6 months ago

This is not in the tests, but to improve the code to use https://github.com/nodeSolidServer/node-solid-server/blob/1034123e268365230342894db825f8f419af1b32/lib/models/account-manager.js#L50-L51

in place of /profile/card#me

zg009 commented 6 months ago

@bourgeoa I edited your function a little bit because the webID document was including port. If this is unintended behavior I can revert. I also added one test case. If you want to see other test cases, let me know.

jeff-zucker commented 6 months ago

@bourgeoa I edited your function a little bit because the webID document was including port.

Yes, this is important, users ought to be able to change the port of the server without having to recreate an account.

bourgeoa commented 6 months ago

replaced wirh url.origin and updated tests that should have failed on relative webId and did not.

zg009 commented 6 months ago

@bourgeoa Looks better to me, I had the wrong idea about which tests should pass

zg009 commented 1 month ago

@bourgeoa Is this good to merge?