-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/seed accounts and pods #1165
Feat/seed accounts and pods #1165
Conversation
I first want to talk about what your use case is because I think you're making this more difficult for yourself than this should be. My guess is that you want the server to immediately set up a number of pods, based on a simple list containing just the pod name and the login information right? As mentioned in #1129, the In case you want to add pods to an existing server, the following script would do that for you: const users = [
{ name: 'example', email: 'hello@example.com', password: 'abc123' }
]
const results = [];
for (const user of users) {
const json = {
podName: user.name,
email: user.email,
password: user.password,
confirmPassword: user.password,
createWebId: true,
register: true,
createPod: true,
};
const response = await fetch('http://localhost:3000/idp/register/, {
method: 'POST'
headers: { 'content-type': 'application/json' },
body: JSON.stringify(json);
}
results.push(await response.json());
} After that the results array would contain all the necessary information such as pod URLs and WebIDs. (I typed all this in a text editor so I expect there to be a syntactic error in there). This is still an external script though. In case this is added to the server itself (and I could see the need), it would indeed have to be some kind of Initializer that triggers only once. But its implementation would be quite concise: a loop that registers the users similarly to how the SetupHandler does this https://github.com/solid/community-server/blob/ce754c119fb87dc8a4f79c639e316bd04d40109b/src/init/setup/SetupHandler.ts#L76-L81 Unless I'm missing something else here that needs to be done. Besides all that, the |
@joachimvh thanks for the quick response!
Yes, this is what I wanted to accomplish. I am coming from a Ruby on Rails background where developers can seed data through a single file (seeds.rb) and command ( From #1129 I understood that I could have created an external script like the one you posted to seed data. However, as a developer trying to use this codebase for the first time, I didn't know what the registration endpoint was nor what it's arguments were. So, in trying to understand how the code worked more fully (and as prep for potentially developing with CSS a lot more in the future), I figured I would just modify/extend it to do what I wanted and learn the framework. I hadn't seen/found SetupHttpHandler.ts yet, but I can see how I could have simplified SeededPodInitializer.ts to just use the I think on a more general note it would be beneficial to have more documentation on how developers can get started with CSS. For example, from my 1 day of using the codebase:
|
When you start the server for the first time, there should be a link to the registration page on the main page.
But yes, this is the main point and I fully agree with it. It's the usual issue of needing time for both documentation and features, and features usually winning that competition. There are some more people planning to work on the server in the future so hopefully that will allow us to solve this problem a bit better.
The main part of the server that does have (a small bit of) documentation is the configuration part. The
Not sure what you need here. We happen to use handlebars for the files that are generated in the pods to write some simple fields. Unless you mean a specific list of the fields that are exported?
With routes, do you mean the URLs supported by the server? Because due to Solid that is an infinite amount. Although we should have a documented list for some of the IDP APIs.
When opening a PR the pre-generated comments mention targeting the correct branch. We should probably specify what the options there are (and again, have more documentation about this). So yes, most of it boils down to the fact that more documentation would definitely be helpful. Comments like this also help because they indicate what kind of documentation would be needed so thanks for that. |
Yep, though this is a pretty tedious way to learn how every endpoint works and what arguments it accepts.
Of course, no way to get around time.
Ah yes, I saw and reviewed the README in the top level config folder but may not have seen all the ones in the sub folders.
I guess it's just that I had to inspect
Yeah I mean URLs supported by the server. And yeah, IdP side specifically. I understand how that's not possible for all the URLs available in pods.
Right. I saw that once I opened the PR but by then I had already done all my development based on |
@joachimvh If you/the maintainers are interested in incorporating this feature:
If you don't want to incorporate this feature, what's the process of turning it into an extension? Is there documentation somewhere for that? Also: I'd love to help out where I can with documentation, starting with this feature, if it doesn't already have enough. Do you have a framework/guidelines in place for or references to documentation best practices? |
The discussion here is relevant #1163
I opened issue #1174 so we have something to so we have a place to track this, but as you can see there is not much there yet. Regarding this PR, I do think this could be a useful addition to this repository as other people have also asked how to create a set of pods. I will have a look at the implementation a bit later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most comments are config related. I think this can be made even more flexible. Let me know if you need help with the configuration as I know it can be a hassle sometimes.
@joachimvh To make the tests pass after implementing your suggestions I had to make a few modifications:
|
Looks like I got some commits from |
They have to get in there eventually, but doing it through an unrelated PR is going to potentially cause some git issues/confusion so please remove them and do a force push. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great and pretty much ready to merge besides some minor nits (and the commits from the main branch). I see one integration test is still failing. That is because that one only runs on CI, so the run-with-redlock.json
config will also need the config changes that you added to the other ones.
I have merged the main branch into the 4.0.0 branch in the hopes that makes it easier, I hope that didn't make it more difficult for you. |
ff7dad8
to
184f136
Compare
β¦er directly and make compatible with version/3.0.0
β¦prefilled-root config
β¦d copy and guide, change seeded pod config to array
β¦, code style nit, fix redlock test
184f136
to
feea553
Compare
@joachimvh not sure what's up with the CI tests now. I added the changes to |
CI was acting up, tests succeed after running them again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for this!
Just realized a note should be added to the release notes about this but I'll do it myself in a separate commit.
π Thanks for all the help & review @joachimvh ! Excited to be contributing. |
π Related issues
#1129
βοΈ Description
Adds the ability to seed non root pods and associated accounts. Adds the
--seededPodConfigJson
cli arg when starting the server which defaults to./seeded-pod-config.json
.Adds
SeededPodInitializer.ts
which mimics a lot of the functionality ofRegistrationManager.ts
(Maybe this should be DRYed up?)Can be run using the
file-seeded.json
config file.Wanted to be able to get my dev env setup faster.
β PR check list
Before this pull request can be merged, a core maintainer will check whether