Skip to content

Upgrade account management architecture - #1677

Merged
jvherweg merged 9 commits into
versions/next-majorfrom
feat/accounts
Oct 6, 2023
Merged

jvherweg merged 9 commits into
versions/next-majorfrom
feat/accounts

Conversation

@jvherweg

@jvherweg jvherweg commented Jul 17, 2023 •

Copy link
Copy Markdown
Member

📁 Related issues

Closes #972, closes #1347, closes #1364

✍️ Description

This PR should not be merged as it completely breaks account information of existing servers! A solution that migrations the data needs to be developed first. Until then this branch can already be used to set up a server with the new account features though.

Completely changes how the account management works and what the related architecture looks like. Included in the PR is documentation that fully describes the architecture and functionality. I'll summarize below.

Where the old registration combined the creation of an account, a pod, and registering a WebID, in the new version these are all separate actions in the JSON API. First a user creates an empty account, then they add an email/password combination to it, and then they can create pods, link WebIDs, create tokens, or add more email/password combinations to the same accont. New HTML pages have been made to support the new functionality, including an account overview page that allows you to see everything linked to an account and update its contents.

The main idea is that due to th enew architecture it should also be easier to extend or replace components to ehnahnce the functionality, such as adding a new login method for example.

Cookies are used for authorization, although a custom authorization header can also be used.

There is still a registration page that combines the creation of an account and adding an email/password for ease of use.

Setup has been removed as its main point was just creating an initial account, and it no longer felt so useful after the account changes. Due to the changes to the static files handler we can now have a static page at the root, which replaces the introductory function of the setup.

Pod seeding has been changed so now multiple pods can be created for a single account.

@jvherweg

Copy link
Copy Markdown
Member Author

Note to self: might still want to add additional storage here that links pods to their owner to solve #1364 in the future as there currently is no way to determine the owner of a pod, only a way to determine if a specific WebID is the owner. Now would be the best time to add this as storage is being modified at this time anyway.

@RubenVerborgh

Copy link
Copy Markdown
Member

Tested this from a user perspective, and that definitely was fun and smooth!
I almost want there to be a waiting time after I create an account, because it's so fast that I don't really believe anything happened 😅

image

After logging in, the API will return a `set-cookie` header.
This cookie is necessary to have access to many of the APIs.
When including this cookie, the controls object will also be extended with new URLs that are now accessible.
When logging in, the response body JSON body will also contain a `cookie` field containing the cookie value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The structure of that field should still be described (css-account=xxx).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also perhaps, in the body (where I got the field value from), we shouldn't call the field cookie but authorization or secret or similar. Or maybe just not have it at all, and move auth entirely to the headers.

@RubenVerborgh

Copy link
Copy Markdown
Member

Pods and WebIDs probably should be links in the template, like logins:

image

@jvherweg

Copy link
Copy Markdown
Member Author

Pods and WebIDs probably should be links in the template, like logins:

The reason only logins are linked is because they are the only one with an update page. Clicking that email address goes to the page to change your password, not to send a mail. Which might be confusing and better to just have an update link separately instead.

@RubenVerborgh

Copy link
Copy Markdown
Member

Pods and WebIDs probably should be links in the template, like logins:

The reason only logins are linked is because they are the only one with an update page. Clicking that email address goes to the page to change your password, not to send a mail. Which might be confusing and better to just have an update link separately instead.

I'd to both; make all URLs links, and then have (update – delete) after them.

@jvherweg

Copy link
Copy Markdown
Member Author

PR has been updated so the new indexed storage is used, simplifying all data-related account classes. Next steps:

  • Fix things requested above
  • Allow adding/removing owners
  • Look into still having an easy option to configure the server to have a pod in the root instead of using registration
  • Migration for previous versions

@jvherweg
jvherweg force-pushed the feat/accounts branch 2 times, most recently from efd5f96 to 7c66836 Compare September 27, 2023 09:45
@RubenVerborgh

RubenVerborgh commented Sep 27, 2023 •

Copy link
Copy Markdown
Member

Seems like conneg broke:

% curl http://localhost:3000/.account/account/29cc2a67-3ea3-4060-9fa3-be7c57866eb5/ -i -s -H "Accept: text/html" | head -n 1
HTTP/1.1 200 OK
% curl http://localhost:3000/.account/account/29cc2a67-3ea3-4060-9fa3-be7c57866eb5/ -i -s -H "Accept: application/json" | head -n 1
HTTP/1.1 404 Not Found

And HEAD:

% curl http://localhost:3000/.account/account/29cc2a67-3ea3-4060-9fa3-be7c57866eb5/ -I -s -H "Accept: text/html" | head -n 1
HTTP/1.1 404 Not Found

5d9d5a9 is the culprit. For JSON, it results in:

2023-09-27T19:32:35.782Z [IdentityProviderHttpHandler] {Primary} debug: No active OIDC interaction found: invalid_request
2023-09-27T19:32:35.784Z [ChainedConverter] {Primary} debug: Converting internal/error -> application/json.

Whereas for HTML, this is:

2023-09-27T19:37:16.769Z [IdentityProviderHttpHandler] {Primary} debug: No active OIDC interaction found: invalid_request
2023-09-27T19:37:16.770Z [ParsingHttpHandler] {Primary} verbose: Parsed GET operation on http://localhost:3000/.account/account/cd9aed23-8d06-4c6f-8a25-a21bd1f94e03/

@jvherweg
jvherweg force-pushed the feat/accounts branch 2 times, most recently from 29c6236 to 3b22cb2 Compare September 28, 2023 14:39
When logging in, the response body JSON body will also contain an `authorization` field
containing the `$VALUE` value mentioned above.
Instead of using cookies,
this value can be used in an `Authorization` header with value `CSS-Account-Cookie $VALUE`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSS-Account-Cookie might not be an appropriate scheme name, or at least a confusing one. Suggestion: CSS-API-Token.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to change it to CSS-Account-Token. CSS-API-Token feels too generic just in case another API gets added at some point.

@jvherweg

jvherweg commented Oct 2, 2023

Copy link
Copy Markdown
Member Author

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants